[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACMJSet1Zvm5-yHTxfnk43=g+DMyKUKSH0XzYkiAJDTvMr9C+A@mail.gmail.com>
Date: Wed, 23 Oct 2024 12:25:13 +0200
From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
To: manivannan.sadhasivam@...aro.org
Cc: Bjorn Helgaas <bhelgaas@...gle.com>, linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org, Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
Johan Hovold <johan+linaro@...nel.org>, Abel Vesa <abel.vesa@...aro.org>,
Stephan Gerhold <stephan.gerhold@...aro.org>,
Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
Bjorn Andersson <bjorn.andersson@....qualcomm.com>
Subject: Re: [PATCH 5/5] PCI/pwrctl: Remove pwrctl device without iterating
over all children of pwrctl parent
On Tue, 22 Oct 2024 at 12:28, Manivannan Sadhasivam via B4 Relay
<devnull+manivannan.sadhasivam.linaro.org@...nel.org> wrote:
>
> From: Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>
>
> There is no need to iterate over all children of the pwrctl device parent
> to remove the pwrctl device. Since the pwrctl device associated with the
> PCI device can be found using of_find_device_by_node() API, use it directly
> instead.
>
> If any pwrctl devices lying around without getting associated with the PCI
> devices, then those will be removed once their parent device gets removed.
>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>
> ---
> drivers/pci/remove.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
> index e4ce1145aa3e..3dd9b3024956 100644
> --- a/drivers/pci/remove.c
> +++ b/drivers/pci/remove.c
> @@ -17,16 +17,16 @@ static void pci_free_resources(struct pci_dev *dev)
> }
> }
>
> -static int pci_pwrctl_unregister(struct device *dev, void *data)
> +static void pci_pwrctl_unregister(struct device *dev)
> {
> - struct device_node *pci_node = data, *plat_node = dev_of_node(dev);
> + struct platform_device *pdev;
>
> - if (dev_is_platform(dev) && plat_node && plat_node == pci_node) {
> - of_device_unregister(to_platform_device(dev));
> - of_node_clear_flag(plat_node, OF_POPULATED);
> - }
> + pdev = of_find_device_by_node(dev_of_node(dev));
> + if (!pdev)
> + return;
>
> - return 0;
> + of_device_unregister(pdev);
> + of_node_clear_flag(dev_of_node(dev), OF_POPULATED);
> }
>
> static void pci_stop_dev(struct pci_dev *dev)
> @@ -34,8 +34,7 @@ static void pci_stop_dev(struct pci_dev *dev)
> pci_pme_active(dev, false);
>
> if (pci_dev_is_added(dev)) {
> - device_for_each_child(dev->dev.parent, dev_of_node(&dev->dev),
> - pci_pwrctl_unregister);
> + pci_pwrctl_unregister(&dev->dev);
> device_release_driver(&dev->dev);
> pci_proc_detach_device(dev);
> pci_remove_sysfs_dev_files(dev);
>
> --
> 2.25.1
>
>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Powered by blists - more mailing lists