lkml.org 
[lkml]   [2019]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 07/10] usb: phy: tegra: Use devm_otg_ulpi_create()
Date
The resource-managed variant removes the necessity for the driver to care
about freeing ULPI resources.

Suggested-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/usb/phy/phy-tegra-usb.c | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 9ce6699f40e7..d5739b6e0b6c 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -1170,7 +1170,9 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
return err;
}

- tegra_phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0);
+ tegra_phy->ulpi = devm_otg_ulpi_create(&pdev->dev,
+ &ulpi_viewport_access_ops,
+ 0);
if (!tegra_phy->ulpi) {
dev_err(&pdev->dev, "Failed to create ULPI OTG\n");
err = -ENOMEM;
@@ -1205,18 +1207,10 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, tegra_phy);

err = usb_add_phy_dev(&tegra_phy->u_phy);
- if (err < 0)
- goto free_ulpi;
+ if (err)
+ return err;

return 0;
-
-free_ulpi:
- if (tegra_phy->ulpi) {
- kfree(tegra_phy->ulpi->otg);
- kfree(tegra_phy->ulpi);
- }
-
- return err;
}

static int tegra_usb_phy_remove(struct platform_device *pdev)
@@ -1225,11 +1219,6 @@ static int tegra_usb_phy_remove(struct platform_device *pdev)

usb_remove_phy(&tegra_phy->u_phy);

- if (tegra_phy->ulpi) {
- kfree(tegra_phy->ulpi->otg);
- kfree(tegra_phy->ulpi);
- }
-
return 0;
}

--
2.24.0
\
 
 \ /
  Last update: 2019-12-20 02:56    [W:0.093 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site