Input: mms114 - replace udelay with usleep_range

The driver currently uses udelay(MMS114_I2C_DELAY) (50us) to ensure a
mandatory delay between I2C transfers in __mms114_read_reg() and
mms114_write_reg().

Both functions invoke underlying I2C core operations (i2c_transfer,
i2c_master_send) which acquire mutexes and sleep. Furthermore, the
interrupt handler mms114_interrupt() is registered as a threaded IRQ
handler. Since the entire execution path is fully sleepable,
busy-waiting with udelay() for 50us unnecessarily wastes CPU cycles.

Replace udelay() with usleep_range() to allow the CPU to enter low-power
states or execute other tasks during the delay.

Assisted-by: Antigravity:gemini-3.5-flash
Link: https://patch.msgid.link/20260616050912.1531241-4-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
Dmitry Torokhov
2026-06-22 23:19:21 -07:00
parent ce414fb127
commit 144337eeef
+2 -2
View File
@@ -116,7 +116,7 @@ static int __mms114_read_reg(struct mms114_data *data, u8 reg,
"%s: i2c transfer failed (%d)\n", __func__, error);
return error < 0 ? error : -EIO;
}
udelay(MMS114_I2C_DELAY);
usleep_range(MMS114_I2C_DELAY, MMS114_I2C_DELAY + 50);
return 0;
}
@@ -148,7 +148,7 @@ static int mms114_write_reg(struct mms114_data *data, u8 reg, u8 val)
"%s: i2c send failed (%d)\n", __func__, error);
return error < 0 ? error : -EIO;
}
udelay(MMS114_I2C_DELAY);
usleep_range(MMS114_I2C_DELAY, MMS114_I2C_DELAY + 50);
if (reg == MMS114_MODE_CONTROL)
data->cache_mode_control = val;