[PATCH v2 1/4] i2c: muxes: pca954x: fix cleanup ordering in pca954x_cleanup()
From: Pradhan, Sanman
Date: Thu Sep 03 2026 - 19:47:19 EST
From: Sanman Pradhan <psanman@xxxxxxxxxxx>
pca954x_cleanup() disabled the regulator supply before removing the
child mux adapters via i2c_mux_del_adapters(). Removing a child adapter
runs the teardown of the devices behind that channel, and such teardown
may issue I2C transfers through the mux. For example, the lm75 driver
registers a devm action that restores the chip's original configuration
with regmap_write() on removal. Those transfers require the mux to
still be powered.
Remove the child adapters first, then tear down the IRQ domain, and
disable the regulator supply last so the device stays powered while its
children are removed.
Fixes: 6c30ac917a46 ("i2c: muxes: pca954x: Add regulator support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Sanman Pradhan <psanman@xxxxxxxxxxx>
---
drivers/i2c/muxes/i2c-mux-pca954x.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
index b9f370c9f018c..f0b8879ae5fa3 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -466,7 +466,7 @@ static void pca954x_cleanup(struct i2c_mux_core *muxc)
struct pca954x *data = i2c_mux_priv(muxc);
int c, irq;
- regulator_disable(data->supply);
+ i2c_mux_del_adapters(muxc);
if (data->irq) {
for (c = 0; c < data->chip->nchans; c++) {
@@ -475,7 +475,8 @@ static void pca954x_cleanup(struct i2c_mux_core *muxc)
}
irq_domain_remove(data->irq);
}
- i2c_mux_del_adapters(muxc);
+
+ regulator_disable(data->supply);
}
static int pca954x_init(struct i2c_client *client, struct pca954x *data)
--
2.34.1