summaryrefslogtreecommitdiff
path: root/drivers/i2c/i2c-slave-testunit.c
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2024-06-27 14:14:48 +0300
committerWolfram Sang <wsa+renesas@sang-engineering.com>2024-06-28 21:44:38 +0300
commitc116deafd1a5cc1e9739099eb32114e90623209c (patch)
tree47bc3d206cedf276a726c0144ed65c0e4e63d68d /drivers/i2c/i2c-slave-testunit.c
parentc422b6a630240f706063e0ecbb894aa8491b1fa1 (diff)
downloadlinux-c116deafd1a5cc1e9739099eb32114e90623209c.tar.xz
i2c: testunit: discard write requests while old command is running
When clearing registers on new write requests was added, the protection for currently running commands was missed leading to concurrent access to the testunit registers. Check the flag beforehand. Fixes: b39ab96aa894 ("i2c: testunit: add support for block process calls") Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Diffstat (limited to 'drivers/i2c/i2c-slave-testunit.c')
-rw-r--r--drivers/i2c/i2c-slave-testunit.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-slave-testunit.c b/drivers/i2c/i2c-slave-testunit.c
index a5dcbc3c2c14..ca43e98cae1b 100644
--- a/drivers/i2c/i2c-slave-testunit.c
+++ b/drivers/i2c/i2c-slave-testunit.c
@@ -121,6 +121,9 @@ static int i2c_slave_testunit_slave_cb(struct i2c_client *client,
break;
case I2C_SLAVE_WRITE_REQUESTED:
+ if (test_bit(TU_FLAG_IN_PROCESS, &tu->flags))
+ return -EBUSY;
+
memset(tu->regs, 0, TU_NUM_REGS);
tu->reg_idx = 0;
break;