]> www.infradead.org Git - users/hch/xfs.git/commitdiff
i2c: testunit: avoid re-issued work after read message
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 11 Jul 2024 12:08:19 +0000 (14:08 +0200)
committerWolfram Sang <wsa+renesas@sang-engineering.com>
Fri, 12 Jul 2024 06:52:01 +0000 (08:52 +0200)
The to-be-fixed commit rightfully prevented that the registers will be
cleared. However, the index must be cleared. Otherwise a read message
will re-issue the last work. Fix it and add a comment describing the
situation.

Fixes: c422b6a63024 ("i2c: testunit: don't erase registers after STOP")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
drivers/i2c/i2c-slave-testunit.c

index ca43e98cae1b22069e9080d325c4e1f23b9a8ee2..23a11e4e925672bc99c65911e64a070c8bae9378 100644 (file)
@@ -118,6 +118,13 @@ static int i2c_slave_testunit_slave_cb(struct i2c_client *client,
                        queue_delayed_work(system_long_wq, &tu->worker,
                                           msecs_to_jiffies(10 * tu->regs[TU_REG_DELAY]));
                }
+
+               /*
+                * Reset reg_idx to avoid that work gets queued again in case of
+                * STOP after a following read message. But do not clear TU regs
+                * here because we still need them in the workqueue!
+                */
+               tu->reg_idx = 0;
                break;
 
        case I2C_SLAVE_WRITE_REQUESTED: