From: Lucas Stach <l.stach@pengutronix.de>
To: Tang Bin <tangbin@cmss.chinamobile.com>,
hongxing.zhu@nxp.com, lorenzo.pieralisi@arm.com, robh@kernel.org,
kw@linux.com, shawnguo@kernel.org, bhelgaas@google.com,
s.hauer@pengutronix.de, kernel@pengutronix.de,
festevam@gmail.com, linux-imx@nxp.com
Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: imx6: Fix wrong check in imx6_pcie_attach_pd()
Date: Tue, 13 Sep 2022 09:39:03 +0200 [thread overview]
Message-ID: <0660fff6d29c5f8251ac4f28d4badcfea91e6833.camel@pengutronix.de> (raw)
In-Reply-To: <20220913065910.15348-1-tangbin@cmss.chinamobile.com>
Am Dienstag, dem 13.09.2022 um 14:59 +0800 schrieb Tang Bin:
> In the function imx6_pcie_attach_pd(),
> dev_pm_domain_attach_by_name() may return NULL in some cases,
> so IS_ERR() doesn't meet the requirements. Thus fix it.
>
I don't like this added complexity in the driver. IHMO if there is a
real issue, dev_pm_domain_attach_by_name() should just return a error
code, instead of NULL. The fact that you need to pull a error code out
of thin air in the driver is a big hint that this should be fixed in
the called function, not in the return handling in the driver.
A bit down the callstack genpd_dev_pm_attach_by_id() is called, which
is documented like this "Returns the created virtual device if
successfully attached PM domain, NULL when the device don't need a PM
domain [...]". NULL is a valid return code, where the driver should
_not_ stop probing, as the device should work without the power domain
attached.
Regards,
Lucas
> Fixes: 3f7cceeab895 ("PCI: imx: Add multi-pd support")
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> ---
> drivers/pci/controller/dwc/pci-imx6.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index 6619e3caf..65d6ebbba 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -337,8 +337,8 @@ static int imx6_pcie_attach_pd(struct device *dev)
> return 0;
>
> imx6_pcie->pd_pcie = dev_pm_domain_attach_by_name(dev, "pcie");
> - if (IS_ERR(imx6_pcie->pd_pcie))
> - return PTR_ERR(imx6_pcie->pd_pcie);
> + if (IS_ERR_OR_NULL(imx6_pcie->pd_pcie))
> + return PTR_ERR(imx6_pcie->pd_pcie) ? : -ENODATA;
> /* Do nothing when power domain missing */
> if (!imx6_pcie->pd_pcie)
> return 0;
> @@ -352,8 +352,8 @@ static int imx6_pcie_attach_pd(struct device *dev)
> }
>
> imx6_pcie->pd_pcie_phy = dev_pm_domain_attach_by_name(dev, "pcie_phy");
> - if (IS_ERR(imx6_pcie->pd_pcie_phy))
> - return PTR_ERR(imx6_pcie->pd_pcie_phy);
> + if (IS_ERR_OR_NULL(imx6_pcie->pd_pcie_phy))
> + return PTR_ERR(imx6_pcie->pd_pcie_phy) ? : -ENODATA;
>
> link = device_link_add(dev, imx6_pcie->pd_pcie_phy,
> DL_FLAG_STATELESS |
next prev parent reply other threads:[~2022-09-13 7:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-13 6:59 Tang Bin
2022-09-13 7:31 ` Russell King (Oracle)
2022-09-13 7:36 ` Russell King (Oracle)
2022-09-13 8:29 ` Arnd Bergmann
2022-09-13 7:39 ` Lucas Stach [this message]
2022-09-13 7:46 ` Russell King (Oracle)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0660fff6d29c5f8251ac4f28d4badcfea91e6833.camel@pengutronix.de \
--to=l.stach@pengutronix.de \
--cc=bhelgaas@google.com \
--cc=festevam@gmail.com \
--cc=hongxing.zhu@nxp.com \
--cc=kernel@pengutronix.de \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=tangbin@cmss.chinamobile.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®