Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: rz-mtu3: Reduce critical sections

Reduce critical sections on rz_mtu3_start_stop_ch() and
rz_mtu3_is_enabled() by moving offset and bitpos computation
outside the critical section and drop the 'ret' variable on
rz_mtu3_is_enabled() and return 'tstr & BIT(bitpos)' directly.

Reported-by: Pavel Machek <pavel@denx.de>
Closes: https://lore.kernel.org/all/ZIMAse1ikTuycJ02@duo.ucw.cz/
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Pavel Machek <pavel@denx.de>
Link: https://lore.kernel.org/r/20230815073445.9579-2-biju.das.jz@bp.renesas.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Biju Das and committed by
Lee Jones
a160d128 367124eb

+7 -9
+7 -9
drivers/mfd/rz-mtu3.c
··· 252 252 u16 offset; 253 253 u8 bitpos; 254 254 255 + offset = rz_mtu3_get_tstr_offset(ch); 256 + bitpos = rz_mtu3_get_tstr_bit_pos(ch); 257 + 255 258 /* start stop register shared by multiple timer channels */ 256 259 raw_spin_lock_irqsave(&priv->lock, flags); 257 260 258 - offset = rz_mtu3_get_tstr_offset(ch); 259 - bitpos = rz_mtu3_get_tstr_bit_pos(ch); 260 261 tstr = rz_mtu3_shared_reg_read(ch, offset); 261 262 __assign_bit(bitpos, &tstr, start); 262 263 rz_mtu3_shared_reg_write(ch, offset, tstr); ··· 270 269 struct rz_mtu3 *mtu = dev_get_drvdata(ch->dev->parent); 271 270 struct rz_mtu3_priv *priv = mtu->priv_data; 272 271 unsigned long flags, tstr; 273 - bool ret = false; 274 272 u16 offset; 275 273 u8 bitpos; 276 274 277 - /* start stop register shared by multiple timer channels */ 278 - raw_spin_lock_irqsave(&priv->lock, flags); 279 - 280 275 offset = rz_mtu3_get_tstr_offset(ch); 281 276 bitpos = rz_mtu3_get_tstr_bit_pos(ch); 282 - tstr = rz_mtu3_shared_reg_read(ch, offset); 283 - ret = tstr & BIT(bitpos); 284 277 278 + /* start stop register shared by multiple timer channels */ 279 + raw_spin_lock_irqsave(&priv->lock, flags); 280 + tstr = rz_mtu3_shared_reg_read(ch, offset); 285 281 raw_spin_unlock_irqrestore(&priv->lock, flags); 286 282 287 - return ret; 283 + return tstr & BIT(bitpos); 288 284 } 289 285 EXPORT_SYMBOL_GPL(rz_mtu3_is_enabled); 290 286