]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
i2c: atr: Fix client detach
authorTomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Fri, 22 Nov 2024 12:26:18 +0000 (14:26 +0200)
committerWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 9 Jan 2025 10:08:01 +0000 (11:08 +0100)
i2c-atr catches the BUS_NOTIFY_DEL_DEVICE event on the bus and removes
the translation by calling i2c_atr_detach_client().

However, BUS_NOTIFY_DEL_DEVICE happens when the device is about to be
removed from this bus, i.e. before removal, and thus before calling
.remove() on the driver. If the driver happens to do any i2c
transactions in its remove(), they will fail.

Fix this by catching BUS_NOTIFY_REMOVED_DEVICE instead, thus removing
the translation only after the device is actually removed.

Fixes: a076a860acae ("media: i2c: add I2C Address Translator (ATR) support")
Cc: stable@vger.kernel.org
Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Romain Gantois <romain.gantois@bootlin.com>
Tested-by: Romain Gantois <romain.gantois@bootlin.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
drivers/i2c/i2c-atr.c

index b7c10ced5a4393cd7a1a2d7448755872a063895d..8fe9ddff8e96f6f613f48d91a09c09b326e6cb01 100644 (file)
@@ -412,7 +412,7 @@ static int i2c_atr_bus_notifier_call(struct notifier_block *nb,
                                dev_name(dev), ret);
                break;
 
-       case BUS_NOTIFY_DEL_DEVICE:
+       case BUS_NOTIFY_REMOVED_DEVICE:
                i2c_atr_detach_client(client->adapter, client);
                break;