All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Dmitry Osipenko <digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Greg Kroah-Hartman
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	Jonathan Hunter
	<jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
	Felipe Balbi <balbi-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v1] usb: phy: tegra: Add clarifying comments about the shared registers
Date: Mon, 3 Feb 2020 12:28:18 +0100	[thread overview]
Message-ID: <20200203112818.GA3506060@ulmo> (raw)
In-Reply-To: <20200202224259.29187-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

[-- 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 --]

WARNING: multiple messages have this Message-ID (diff)
From: Thierry Reding <thierry.reding@gmail.com>
To: Dmitry Osipenko <digetx@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Felipe Balbi <balbi@kernel.org>,
	linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] usb: phy: tegra: Add clarifying comments about the shared registers
Date: Mon, 3 Feb 2020 12:28:18 +0100	[thread overview]
Message-ID: <20200203112818.GA3506060@ulmo> (raw)
In-Reply-To: <20200202224259.29187-1-digetx@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1773 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@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>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2020-02-03 11:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-02 22:42 [PATCH v1] usb: phy: tegra: Add clarifying comments about the shared registers Dmitry Osipenko
2020-02-02 22:42 ` Dmitry Osipenko
     [not found] ` <20200202224259.29187-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2020-02-03 11:28   ` Thierry Reding [this message]
2020-02-03 11:28     ` Thierry Reding
2020-02-03 16:26     ` Dmitry Osipenko

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=20200203112818.GA3506060@ulmo \
    --to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=balbi-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.