Skip to content

Commit a160d12

Browse files
bijudaslag-linaro
authored andcommitted
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 <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Biju Das <[email protected]> Reviewed-by: Pavel Machek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 367124e commit a160d12

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

drivers/mfd/rz-mtu3.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,12 @@ static void rz_mtu3_start_stop_ch(struct rz_mtu3_channel *ch, bool start)
252252
u16 offset;
253253
u8 bitpos;
254254

255+
offset = rz_mtu3_get_tstr_offset(ch);
256+
bitpos = rz_mtu3_get_tstr_bit_pos(ch);
257+
255258
/* start stop register shared by multiple timer channels */
256259
raw_spin_lock_irqsave(&priv->lock, flags);
257260

258-
offset = rz_mtu3_get_tstr_offset(ch);
259-
bitpos = rz_mtu3_get_tstr_bit_pos(ch);
260261
tstr = rz_mtu3_shared_reg_read(ch, offset);
261262
__assign_bit(bitpos, &tstr, start);
262263
rz_mtu3_shared_reg_write(ch, offset, tstr);
@@ -269,21 +270,18 @@ bool rz_mtu3_is_enabled(struct rz_mtu3_channel *ch)
269270
struct rz_mtu3 *mtu = dev_get_drvdata(ch->dev->parent);
270271
struct rz_mtu3_priv *priv = mtu->priv_data;
271272
unsigned long flags, tstr;
272-
bool ret = false;
273273
u16 offset;
274274
u8 bitpos;
275275

276-
/* start stop register shared by multiple timer channels */
277-
raw_spin_lock_irqsave(&priv->lock, flags);
278-
279276
offset = rz_mtu3_get_tstr_offset(ch);
280277
bitpos = rz_mtu3_get_tstr_bit_pos(ch);
281-
tstr = rz_mtu3_shared_reg_read(ch, offset);
282-
ret = tstr & BIT(bitpos);
283278

279+
/* start stop register shared by multiple timer channels */
280+
raw_spin_lock_irqsave(&priv->lock, flags);
281+
tstr = rz_mtu3_shared_reg_read(ch, offset);
284282
raw_spin_unlock_irqrestore(&priv->lock, flags);
285283

286-
return ret;
284+
return tstr & BIT(bitpos);
287285
}
288286
EXPORT_SYMBOL_GPL(rz_mtu3_is_enabled);
289287

0 commit comments

Comments
 (0)