drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
The i2c subsystem currently blocks during adapter deregistration
whenever there are consumers holding a reference.
Switch to using of_get_i2c_adapter_by_node() which also takes a
reference to the adapter module so that an attempt to unload the module
while in use fails gracefully instead of blocking uninterruptibly.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
index 1555e8a9b3ca..e6a8abd9da8e 100644
--- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
+++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
@@ -548,7 +548,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev)
return dev_err_probe(dev, ret, "Failed to read i2c-parent property\n");
i2c_node = of_parse_phandle(dev->of_node, "i2c-parent", 0);
- tc9563->adapter = of_find_i2c_adapter_by_node(i2c_node);
+ tc9563->adapter = of_get_i2c_adapter_by_node(i2c_node);
of_node_put(i2c_node);
if (!tc9563->adapter)
return dev_err_probe(dev, -EPROBE_DEFER, "Failed to find I2C adapter\n");
@@ -556,7 +556,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev)
tc9563->client = i2c_new_dummy_device(tc9563->adapter, addr);
if (IS_ERR(tc9563->client)) {
dev_err(dev, "Failed to create I2C client\n");
- put_device(&tc9563->adapter->dev);
+ i2c_put_adapter(tc9563->adapter);
return PTR_ERR(tc9563->client);
}
@@ -624,7 +624,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev)
tc9563_pwrctrl_power_off(&tc9563->pwrctrl);
remove_i2c:
i2c_unregister_device(tc9563->client);
- put_device(&tc9563->adapter->dev);
+ i2c_put_adapter(tc9563->adapter);
return ret;
}
@@ -636,7 +636,7 @@ static void tc9563_pwrctrl_remove(struct platform_device *pdev)
tc9563_pwrctrl_power_off(&tc9563->pwrctrl);
i2c_unregister_device(tc9563->client);
- put_device(&tc9563->adapter->dev);
+ i2c_put_adapter(tc9563->adapter);
}
static const struct of_device_id tc9563_pwrctrl_of_match[] = {
--
2.54.0
On Thu, Jul 16, 2026 at 03:25:32PM +0200, Johan Hovold wrote:
> The i2c subsystem currently blocks during adapter deregistration
> whenever there are consumers holding a reference.
>
> Switch to using of_get_i2c_adapter_by_node() which also takes a
> reference to the adapter module so that an attempt to unload the module
> while in use fails gracefully instead of blocking uninterruptibly.
>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Applied to pci/pwrctrl for v7.3, thanks!
Gemini suggested minor commit log rewording, let me know if it makes it
worse. I do like the impact being mentioned in the subject:
PCI/pwrctrl: tc9563: Avoid uninterruptible hang on in-use I2C module unload
The I2C subsystem blocks during adapter deregistration if there are
consumers actively holding a reference.
Switch to of_get_i2c_adapter_by_node(), which also takes a reference to the
adapter module, so an attempt to unload the module while in use will fail
gracefully instead of blocking uninterruptibly.
> ---
> drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
> index 1555e8a9b3ca..e6a8abd9da8e 100644
> --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
> +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
> @@ -548,7 +548,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev)
> return dev_err_probe(dev, ret, "Failed to read i2c-parent property\n");
>
> i2c_node = of_parse_phandle(dev->of_node, "i2c-parent", 0);
> - tc9563->adapter = of_find_i2c_adapter_by_node(i2c_node);
> + tc9563->adapter = of_get_i2c_adapter_by_node(i2c_node);
> of_node_put(i2c_node);
> if (!tc9563->adapter)
> return dev_err_probe(dev, -EPROBE_DEFER, "Failed to find I2C adapter\n");
> @@ -556,7 +556,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev)
> tc9563->client = i2c_new_dummy_device(tc9563->adapter, addr);
> if (IS_ERR(tc9563->client)) {
> dev_err(dev, "Failed to create I2C client\n");
> - put_device(&tc9563->adapter->dev);
> + i2c_put_adapter(tc9563->adapter);
> return PTR_ERR(tc9563->client);
> }
>
> @@ -624,7 +624,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev)
> tc9563_pwrctrl_power_off(&tc9563->pwrctrl);
> remove_i2c:
> i2c_unregister_device(tc9563->client);
> - put_device(&tc9563->adapter->dev);
> + i2c_put_adapter(tc9563->adapter);
> return ret;
> }
>
> @@ -636,7 +636,7 @@ static void tc9563_pwrctrl_remove(struct platform_device *pdev)
>
> tc9563_pwrctrl_power_off(&tc9563->pwrctrl);
> i2c_unregister_device(tc9563->client);
> - put_device(&tc9563->adapter->dev);
> + i2c_put_adapter(tc9563->adapter);
> }
>
> static const struct of_device_id tc9563_pwrctrl_of_match[] = {
> --
> 2.54.0
>
On Fri, Jul 17, 2026 at 11:58:41AM -0500, Bjorn Helgaas wrote: > On Thu, Jul 16, 2026 at 03:25:32PM +0200, Johan Hovold wrote: > > The i2c subsystem currently blocks during adapter deregistration > > whenever there are consumers holding a reference. > > > > Switch to using of_get_i2c_adapter_by_node() which also takes a > > reference to the adapter module so that an attempt to unload the module > > while in use fails gracefully instead of blocking uninterruptibly. > > > > Signed-off-by: Johan Hovold <johan@kernel.org> > > Applied to pci/pwrctrl for v7.3, thanks! > > Gemini suggested minor commit log rewording, let me know if it makes it > worse. I do like the impact being mentioned in the subject: > > PCI/pwrctrl: tc9563: Avoid uninterruptible hang on in-use I2C module unload > > The I2C subsystem blocks during adapter deregistration if there are > consumers actively holding a reference. > > Switch to of_get_i2c_adapter_by_node(), which also takes a reference to the > adapter module, so an attempt to unload the module while in use will fail > gracefully instead of blocking uninterruptibly. No, please don't rewrite my commit messages (and especially not without clearly documenting that you've done). If you have any concerns about the wording, I can try to accommodate those in a v2. If I had considered this to be a fix (the line is admittedly blurry) I would also have tried to be more explicit about the impact in the summary. But here I think the existing summary is sufficient. Note that I've sent similar changes for other subsystems and there is some value in using the same patch summary (modulo subsystem preferences for capitalisation, etc). Johan
On Mon, Jul 20, 2026 at 12:12:39PM +0200, Johan Hovold wrote: > On Fri, Jul 17, 2026 at 11:58:41AM -0500, Bjorn Helgaas wrote: > > On Thu, Jul 16, 2026 at 03:25:32PM +0200, Johan Hovold wrote: > > > The i2c subsystem currently blocks during adapter deregistration > > > whenever there are consumers holding a reference. > > > > > > Switch to using of_get_i2c_adapter_by_node() which also takes a > > > reference to the adapter module so that an attempt to unload the module > > > while in use fails gracefully instead of blocking uninterruptibly. > > > > > > Signed-off-by: Johan Hovold <johan@kernel.org> > > > > Applied to pci/pwrctrl for v7.3, thanks! > > > > Gemini suggested minor commit log rewording, let me know if it makes it > > worse. I do like the impact being mentioned in the subject: > > > > PCI/pwrctrl: tc9563: Avoid uninterruptible hang on in-use I2C module unload > > > > The I2C subsystem blocks during adapter deregistration if there are > > consumers actively holding a reference. > > > > Switch to of_get_i2c_adapter_by_node(), which also takes a reference to the > > adapter module, so an attempt to unload the module while in use will fail > > gracefully instead of blocking uninterruptibly. > > No, please don't rewrite my commit messages (and especially not without > clearly documenting that you've done). > > If you have any concerns about the wording, I can try to accommodate > those in a v2. > > If I had considered this to be a fix (the line is admittedly blurry) I > would also have tried to be more explicit about the impact in the > summary. But here I think the existing summary is sufficient. > > Note that I've sent similar changes for other subsystems and there is > some value in using the same patch summary (modulo subsystem preferences > for capitalisation, etc). You're right, I'm sorry. I used your original commit message. I assumed this was for v7.3, but let me know if it should be for v7.2.
On Mon, Jul 20, 2026 at 06:04:17AM -0500, Bjorn Helgaas wrote: > You're right, I'm sorry. I used your original commit message. I > assumed this was for v7.3, but let me know if it should be for v7.2. Thanks. And yes, this was intended for 7.3. Johan
On Thu, 16 Jul 2026 15:25:32 +0200, Johan Hovold <johan@kernel.org> said: > The i2c subsystem currently blocks during adapter deregistration > whenever there are consumers holding a reference. > > Switch to using of_get_i2c_adapter_by_node() which also takes a > reference to the adapter module so that an attempt to unload the module > while in use fails gracefully instead of blocking uninterruptibly. > > Signed-off-by: Johan Hovold <johan@kernel.org> > --- Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
On Thu, Jul 16, 2026 at 03:25:32PM +0200, Johan Hovold wrote:
> The i2c subsystem currently blocks during adapter deregistration
> whenever there are consumers holding a reference.
>
> Switch to using of_get_i2c_adapter_by_node() which also takes a
> reference to the adapter module so that an attempt to unload the module
> while in use fails gracefully instead of blocking uninterruptibly.
>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
- Mani
> ---
> drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
> index 1555e8a9b3ca..e6a8abd9da8e 100644
> --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
> +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
> @@ -548,7 +548,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev)
> return dev_err_probe(dev, ret, "Failed to read i2c-parent property\n");
>
> i2c_node = of_parse_phandle(dev->of_node, "i2c-parent", 0);
> - tc9563->adapter = of_find_i2c_adapter_by_node(i2c_node);
> + tc9563->adapter = of_get_i2c_adapter_by_node(i2c_node);
> of_node_put(i2c_node);
> if (!tc9563->adapter)
> return dev_err_probe(dev, -EPROBE_DEFER, "Failed to find I2C adapter\n");
> @@ -556,7 +556,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev)
> tc9563->client = i2c_new_dummy_device(tc9563->adapter, addr);
> if (IS_ERR(tc9563->client)) {
> dev_err(dev, "Failed to create I2C client\n");
> - put_device(&tc9563->adapter->dev);
> + i2c_put_adapter(tc9563->adapter);
> return PTR_ERR(tc9563->client);
> }
>
> @@ -624,7 +624,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev)
> tc9563_pwrctrl_power_off(&tc9563->pwrctrl);
> remove_i2c:
> i2c_unregister_device(tc9563->client);
> - put_device(&tc9563->adapter->dev);
> + i2c_put_adapter(tc9563->adapter);
> return ret;
> }
>
> @@ -636,7 +636,7 @@ static void tc9563_pwrctrl_remove(struct platform_device *pdev)
>
> tc9563_pwrctrl_power_off(&tc9563->pwrctrl);
> i2c_unregister_device(tc9563->client);
> - put_device(&tc9563->adapter->dev);
> + i2c_put_adapter(tc9563->adapter);
> }
>
> static const struct of_device_id tc9563_pwrctrl_of_match[] = {
> --
> 2.54.0
>
--
மணிவண்ணன் சதாசிவம்
© 2016 - 2026 Red Hat, Inc.