From: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
To: Tuomas Tynkkynen <ttynkkynen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: balbi-l0cyMroinI0@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH 9/9] usb: phy: tegra: Use DT helpers for dr_mode
Date: Mon, 01 Jul 2013 16:02:51 -0600 [thread overview]
Message-ID: <51D1FC8B.1030505@wwwdotorg.org> (raw)
In-Reply-To: <1372455427-20898-10-git-send-email-ttynkkynen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
On 06/28/2013 03:37 PM, Tuomas Tynkkynen wrote:
> Use the new of_usb_get_dr_mode helper function for parsing dr_mode
> from the device tree. Also replace the usage of the custom
> tegra_usb_phy_mode enum with the standard enum.
> diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
> + tegra_phy->mode = of_usb_get_dr_mode(np);
> + if (tegra_phy->mode == USB_DR_MODE_UNKNOWN) {
> + dev_err(&pdev->dev, "dr_mode is invalid\n");
> + return -EINVAL;
> + }
Unfortunately, of_usb_get_dr_mode() returns USB_DR_MODE_UNKNOWN if the
property is missing, rather than defaulting to host mode as the original
code here did. I would suggest solving this by:
> diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c
> index 675384d..6391de5 100644
> --- a/drivers/usb/usb-common.c
> +++ b/drivers/usb/usb-common.c
> @@ -103,7 +103,7 @@ enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
>
> err = of_property_read_string(np, "dr_mode", &dr_mode);
> if (err < 0)
> - return USB_DR_MODE_UNKNOWN;
> + return USB_DR_MODE_HOST;
>
> for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
> if (!strcmp(dr_mode, usb_dr_modes[i]))
This can't be done by the caller, since of_usb_get_dr_mode() returns
UNKNOWN in two cases, which the caller can't distinguish without
manually checking whether the property exists first:
a) Property is not present (which should default to HOST mode at least
for the Tegra binding, as in the patch I show above).
b) Property is present, but contains an invalid value, which probably
should cause the driver to error-out.
This is only a problem for dr_mode in the Tegra binding: dr_mode is an
optional property, whereas the phy_type property as parsed by patch 8/9
is mandatory, so this issue doesn't come up.
WARNING: multiple messages have this Message-ID (diff)
From: Stephen Warren <swarren@wwwdotorg.org>
To: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
Cc: balbi@ti.com, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
gregkh@linuxfoundation.org
Subject: Re: [PATCH 9/9] usb: phy: tegra: Use DT helpers for dr_mode
Date: Mon, 01 Jul 2013 16:02:51 -0600 [thread overview]
Message-ID: <51D1FC8B.1030505@wwwdotorg.org> (raw)
In-Reply-To: <1372455427-20898-10-git-send-email-ttynkkynen@nvidia.com>
On 06/28/2013 03:37 PM, Tuomas Tynkkynen wrote:
> Use the new of_usb_get_dr_mode helper function for parsing dr_mode
> from the device tree. Also replace the usage of the custom
> tegra_usb_phy_mode enum with the standard enum.
> diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
> + tegra_phy->mode = of_usb_get_dr_mode(np);
> + if (tegra_phy->mode == USB_DR_MODE_UNKNOWN) {
> + dev_err(&pdev->dev, "dr_mode is invalid\n");
> + return -EINVAL;
> + }
Unfortunately, of_usb_get_dr_mode() returns USB_DR_MODE_UNKNOWN if the
property is missing, rather than defaulting to host mode as the original
code here did. I would suggest solving this by:
> diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c
> index 675384d..6391de5 100644
> --- a/drivers/usb/usb-common.c
> +++ b/drivers/usb/usb-common.c
> @@ -103,7 +103,7 @@ enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
>
> err = of_property_read_string(np, "dr_mode", &dr_mode);
> if (err < 0)
> - return USB_DR_MODE_UNKNOWN;
> + return USB_DR_MODE_HOST;
>
> for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
> if (!strcmp(dr_mode, usb_dr_modes[i]))
This can't be done by the caller, since of_usb_get_dr_mode() returns
UNKNOWN in two cases, which the caller can't distinguish without
manually checking whether the property exists first:
a) Property is not present (which should default to HOST mode at least
for the Tegra binding, as in the patch I show above).
b) Property is present, but contains an invalid value, which probably
should cause the driver to error-out.
This is only a problem for dr_mode in the Tegra binding: dr_mode is an
optional property, whereas the phy_type property as parsed by patch 8/9
is mandatory, so this issue doesn't come up.
next prev parent reply other threads:[~2013-07-01 22:02 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-28 21:36 [PATCH 0/9] Tegra USB cleanup series Tuomas Tynkkynen
2013-06-28 21:36 ` Tuomas Tynkkynen
2013-06-28 21:37 ` [PATCH 2/9] usb: host: tegra: Remove leftover code Tuomas Tynkkynen
2013-06-28 21:37 ` Tuomas Tynkkynen
2013-06-28 21:37 ` [PATCH 3/9] usb: tegra: host: Remove references to plat data Tuomas Tynkkynen
2013-06-28 21:37 ` Tuomas Tynkkynen
2013-06-28 21:37 ` [PATCH 4/9] ARM: tegra: Remove USB platform data Tuomas Tynkkynen
2013-06-28 21:37 ` Tuomas Tynkkynen
2013-07-01 21:51 ` Stephen Warren
2013-06-28 21:37 ` [PATCH 6/9] usb: host: tegra: Locate a PHY via standard API Tuomas Tynkkynen
2013-06-28 21:37 ` Tuomas Tynkkynen
2013-06-28 21:37 ` [PATCH 7/9] usb: phy: tegra: Remove custom PHY locating APIs Tuomas Tynkkynen
2013-06-28 21:37 ` Tuomas Tynkkynen
[not found] ` <1372455427-20898-1-git-send-email-ttynkkynen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-06-28 21:36 ` [PATCH 1/9] usb: phy: tegra: Remove unnecessary 'dev' field Tuomas Tynkkynen
2013-06-28 21:36 ` Tuomas Tynkkynen
2013-06-28 21:37 ` [PATCH 5/9] usb: phy: tegra: Register as an USB PHY Tuomas Tynkkynen
2013-06-28 21:37 ` Tuomas Tynkkynen
2013-07-01 21:53 ` Stephen Warren
2013-06-28 21:37 ` [PATCH 8/9] usb: phy: tegra: Use DT helpers for phy_type Tuomas Tynkkynen
2013-06-28 21:37 ` Tuomas Tynkkynen
2013-06-28 21:37 ` [PATCH 9/9] usb: phy: tegra: Use DT helpers for dr_mode Tuomas Tynkkynen
2013-06-28 21:37 ` Tuomas Tynkkynen
[not found] ` <1372455427-20898-10-git-send-email-ttynkkynen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-07-01 22:02 ` Stephen Warren [this message]
2013-07-01 22:02 ` Stephen Warren
2013-07-01 22:03 ` [PATCH 0/9] Tegra USB cleanup series Stephen Warren
2013-07-24 12:32 ` Felipe Balbi
2013-07-24 12:32 ` Felipe Balbi
2013-07-24 17:03 ` Stephen Warren
2013-07-24 17:03 ` Stephen Warren
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=51D1FC8B.1030505@wwwdotorg.org \
--to=swarren-3lzwwm7+weoh9zmkesr00q@public.gmane.org \
--cc=balbi-l0cyMroinI0@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ttynkkynen-DDmLM1+adcrQT0dZR+AlfA@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.