* [PATCH v1] usb: phy: tegra: Add clarifying comments about the shared registers
@ 2020-02-02 22:42 Dmitry Osipenko
[not found] ` <20200202224259.29187-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Osipenko @ 2020-02-02 22:42 UTC (permalink / raw)
To: Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter, Felipe Balbi
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Tools like Coccinelle may erroneously recommend to use the
devm_platform_ioremap_resource() API for the registers mapping because
these tools are not aware about the implementation details of the driver.
Let's add a clarifying comments to the code, which should help to stop
future attempts to break the driver.
Signed-off-by: Dmitry Osipenko <digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/usb/phy/phy-tegra-usb.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 037e8eee737d..6153cc35aba0 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -969,6 +969,10 @@ static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy,
return -ENXIO;
}
+ /*
+ * Note that UTMI pad registers are shared by all PHYs, therefore
+ * devm_platform_ioremap_resource() can't be used here.
+ */
tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start,
resource_size(res));
if (!tegra_phy->pad_regs) {
@@ -1087,6 +1091,10 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
return -ENXIO;
}
+ /*
+ * Note that PHY and USB controller are using shared registers,
+ * therefore devm_platform_ioremap_resource() can't be used here.
+ */
tegra_phy->regs = devm_ioremap(&pdev->dev, res->start,
resource_size(res));
if (!tegra_phy->regs) {
--
2.24.0
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <20200202224259.29187-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v1] usb: phy: tegra: Add clarifying comments about the shared registers [not found] ` <20200202224259.29187-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2020-02-03 11:28 ` Thierry Reding 2020-02-03 16:26 ` Dmitry Osipenko 0 siblings, 1 reply; 3+ messages in thread From: Thierry Reding @ 2020-02-03 11:28 UTC (permalink / raw) To: Dmitry Osipenko Cc: Greg Kroah-Hartman, Jonathan Hunter, Felipe Balbi, linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-tegra-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1832 bytes --] On Mon, Feb 03, 2020 at 01:42:59AM +0300, Dmitry Osipenko wrote: > Tools like Coccinelle may erroneously recommend to use the > devm_platform_ioremap_resource() API for the registers mapping because > these tools are not aware about the implementation details of the driver. > Let's add a clarifying comments to the code, which should help to stop > future attempts to break the driver. > > Signed-off-by: Dmitry Osipenko <digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > drivers/usb/phy/phy-tegra-usb.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c > index 037e8eee737d..6153cc35aba0 100644 > --- a/drivers/usb/phy/phy-tegra-usb.c > +++ b/drivers/usb/phy/phy-tegra-usb.c > @@ -969,6 +969,10 @@ static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy, > return -ENXIO; > } > > + /* > + * Note that UTMI pad registers are shared by all PHYs, therefore > + * devm_platform_ioremap_resource() can't be used here. > + */ > tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start, > resource_size(res)); > if (!tegra_phy->pad_regs) { > @@ -1087,6 +1091,10 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) > return -ENXIO; > } > > + /* > + * Note that PHY and USB controller are using shared registers, > + * therefore devm_platform_ioremap_resource() can't be used here. > + */ > tegra_phy->regs = devm_ioremap(&pdev->dev, res->start, > resource_size(res)); > if (!tegra_phy->regs) { I'm not sure it's really going to stop *all* attempts. But at least for people that go through the trouble of reading the comments, yes, this should do the trick, so: Acked-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] usb: phy: tegra: Add clarifying comments about the shared registers 2020-02-03 11:28 ` Thierry Reding @ 2020-02-03 16:26 ` Dmitry Osipenko 0 siblings, 0 replies; 3+ messages in thread From: Dmitry Osipenko @ 2020-02-03 16:26 UTC (permalink / raw) To: Thierry Reding Cc: Greg Kroah-Hartman, Jonathan Hunter, Felipe Balbi, linux-usb, linux-tegra, linux-kernel 03.02.2020 14:28, Thierry Reding пишет: > On Mon, Feb 03, 2020 at 01:42:59AM +0300, Dmitry Osipenko wrote: >> Tools like Coccinelle may erroneously recommend to use the >> devm_platform_ioremap_resource() API for the registers mapping because >> these tools are not aware about the implementation details of the driver. >> Let's add a clarifying comments to the code, which should help to stop >> future attempts to break the driver. >> >> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> >> --- >> drivers/usb/phy/phy-tegra-usb.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c >> index 037e8eee737d..6153cc35aba0 100644 >> --- a/drivers/usb/phy/phy-tegra-usb.c >> +++ b/drivers/usb/phy/phy-tegra-usb.c >> @@ -969,6 +969,10 @@ static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy, >> return -ENXIO; >> } >> >> + /* >> + * Note that UTMI pad registers are shared by all PHYs, therefore >> + * devm_platform_ioremap_resource() can't be used here. >> + */ >> tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start, >> resource_size(res)); >> if (!tegra_phy->pad_regs) { >> @@ -1087,6 +1091,10 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) >> return -ENXIO; >> } >> >> + /* >> + * Note that PHY and USB controller are using shared registers, >> + * therefore devm_platform_ioremap_resource() can't be used here. >> + */ >> tegra_phy->regs = devm_ioremap(&pdev->dev, res->start, >> resource_size(res)); >> if (!tegra_phy->regs) { > > I'm not sure it's really going to stop *all* attempts. But at least for > people that go through the trouble of reading the comments, yes, this > should do the trick, so: > > Acked-by: Thierry Reding <treding@nvidia.com> Will see, thanks :) ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-03 16:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-02 22:42 [PATCH v1] usb: phy: tegra: Add clarifying comments about the shared registers Dmitry Osipenko
[not found] ` <20200202224259.29187-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2020-02-03 11:28 ` Thierry Reding
2020-02-03 16:26 ` Dmitry Osipenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox