Patchwork [5/9] usb: phy: tegra: Register as an USB PHY.

login
register
mail settings
Submitter Tuomas Tynkkynen
Date June 28, 2013, 9:37 p.m.
Message ID <1372455427-20898-6-git-send-email-ttynkkynen@nvidia.com>
Download mbox | patch
Permalink /patch/255680/
State Superseded, archived
Headers show

Comments

Tuomas Tynkkynen - June 28, 2013, 9:37 p.m.
Register the Tegra PHY device instances with the PHY subsystem so that
the Tegra EHCI driver can locate a PHY via the standard APIs.

Signed-off-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
---
 drivers/usb/phy/phy-tegra-usb.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
Stephen Warren - July 1, 2013, 9:53 p.m.
On 06/28/2013 03:37 PM, Tuomas Tynkkynen wrote:
> Register the Tegra PHY device instances with the PHY subsystem so that
> the Tegra EHCI driver can locate a PHY via the standard APIs.

> diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c

> +	err = usb_add_phy_dev(&tegra_phy->u_phy);
> +	if (err < 0) {
> +		tegra_usb_phy_close(&tegra_phy->u_phy);
> +		return err;
> +	}

Don't you want to do that a bit later? In particular ...

>  	tegra_phy->u_phy.shutdown = tegra_usb_phy_close;
>  	tegra_phy->u_phy.set_suspend = tegra_usb_phy_suspend;
> 
> 	dev_set_drvdata(&pdev->dev, tegra_phy);

... that all happens *after* the call to usb_add_phy_dev() call, yet I
think the USB core could legally call any of the PHY methods after the
call to usb_add_phy_dev(), and that probably requires all those methods
pointers and drvdata to be set up? I suggest moving the call to
usb_add_phy_dev() to the very end of the function.

> +static int tegra_usb_phy_remove(struct platform_device *pdev)
> +{
> +	struct tegra_usb_phy *tegra_phy = platform_get_drvdata(pdev);
> +
> +	usb_remove_phy(&tegra_phy->u_phy);
> +	return 0;
> +}

Nit: I'd typically expect to see a blank line before the return statement.
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index ddcac0b..b81310d 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -927,6 +927,12 @@  static int tegra_usb_phy_probe(struct platform_device *pdev)
 	if (err < 0)
 		return err;
 
+	err = usb_add_phy_dev(&tegra_phy->u_phy);
+	if (err < 0) {
+		tegra_usb_phy_close(&tegra_phy->u_phy);
+		return err;
+	}
+
 	tegra_phy->u_phy.shutdown = tegra_usb_phy_close;
 	tegra_phy->u_phy.set_suspend = tegra_usb_phy_suspend;
 
@@ -934,6 +940,14 @@  static int tegra_usb_phy_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static int tegra_usb_phy_remove(struct platform_device *pdev)
+{
+	struct tegra_usb_phy *tegra_phy = platform_get_drvdata(pdev);
+
+	usb_remove_phy(&tegra_phy->u_phy);
+	return 0;
+}
+
 static struct of_device_id tegra_usb_phy_id_table[] = {
 	{ .compatible = "nvidia,tegra20-usb-phy", },
 	{ },
@@ -942,6 +956,7 @@  MODULE_DEVICE_TABLE(of, tegra_usb_phy_id_table);
 
 static struct platform_driver tegra_usb_phy_driver = {
 	.probe		= tegra_usb_phy_probe,
+	.remove		= tegra_usb_phy_remove,
 	.driver		= {
 		.name	= "tegra-phy",
 		.owner	= THIS_MODULE,