From 144337eeefbec6bbc7e9b51a6d58551baad03d40 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 22 Jun 2026 22:36:01 -0700 Subject: 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 --- drivers/input/touchscreen/mms114.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c index c2e006ac1196..c59aec8f2feb 100644 --- a/drivers/input/touchscreen/mms114.c +++ b/drivers/input/touchscreen/mms114.c @@ -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; -- cgit