diff mbox series

i2c: pnx: Fix timeout in wait functions

Message ID 20241206231937.86408-1-ferr.lambarginio@gmail.com
State New
Headers show
Series i2c: pnx: Fix timeout in wait functions | expand

Commit Message

Vladimir Riabchun Dec. 6, 2024, 11:19 p.m. UTC
Since commit f63b94be6942 ("i2c: pnx: Fix potential deadlock warning
from del_timer_sync() call in isr") jiffies are stored in
i2c_pnx_algo_data.timeout, but wait_timeout and wait_reset are still
using it as milliseconds. Convert jiffies back to milliseconds to wait
for the expected amount of time.

Fixes: f63b94be6942 ("i2c: pnx: Fix potential deadlock warning from del_timer_sync() call in isr")
Signed-off-by: Vladimir Riabchun <ferr.lambarginio@gmail.com>
---
 drivers/i2c/busses/i2c-pnx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Andi Shyti Dec. 10, 2024, 2:51 p.m. UTC | #1
Hi Vladimir,

On Sat, Dec 07, 2024 at 12:19:34AM +0100, Vladimir Riabchun wrote:
> Since commit f63b94be6942 ("i2c: pnx: Fix potential deadlock warning
> from del_timer_sync() call in isr") jiffies are stored in
> i2c_pnx_algo_data.timeout, but wait_timeout and wait_reset are still
> using it as milliseconds. Convert jiffies back to milliseconds to wait
> for the expected amount of time.
> 
> Fixes: f63b94be6942 ("i2c: pnx: Fix potential deadlock warning from del_timer_sync() call in isr")
> Signed-off-by: Vladimir Riabchun <ferr.lambarginio@gmail.com>

good catch! Merged to i2c/i2c-host-fixes.

Thanks,
Andi
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index d4d139b97513..9a1af5bbd604 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -95,7 +95,7 @@  enum {
 
 static inline int wait_timeout(struct i2c_pnx_algo_data *data)
 {
-	long timeout = data->timeout;
+	long timeout = jiffies_to_msecs(data->timeout);
 	while (timeout > 0 &&
 			(ioread32(I2C_REG_STS(data)) & mstatus_active)) {
 		mdelay(1);
@@ -106,7 +106,7 @@  static inline int wait_timeout(struct i2c_pnx_algo_data *data)
 
 static inline int wait_reset(struct i2c_pnx_algo_data *data)
 {
-	long timeout = data->timeout;
+	long timeout = jiffies_to_msecs(data->timeout);
 	while (timeout > 0 &&
 			(ioread32(I2C_REG_CTL(data)) & mcntrl_reset)) {
 		mdelay(1);