Re: [PATCH usb-next] usb: dwc3: Use devm_of_platform_populate

Russell King - ARM Linux admin
2020-11-09T10:34:41Z

On Mon, Nov 09, 2020 at 09:59:53AM +0800, Jisheng Zhang wrote:
> diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
> index 417e05381b5d..83015bb7b926 100644
> --- a/drivers/usb/dwc3/dwc3-meson-g12a.c
> +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
> @@ -702,7 +702,6 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
> {
> struct dwc3_meson_g12a *priv;
> struct device *dev = &pdev->dev;
> - struct device_node *np = dev->of_node;
> void __iomem *base;
> int ret, i;
>
> @@ -794,7 +793,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
> goto err_phys_power;
> }
>
> - ret = of_platform_populate(np, NULL, NULL, dev);
> + ret = devm_of_platform_populate(dev);
> if (ret)
> goto err_phys_power;
>
> @@ -832,8 +831,6 @@ static int dwc3_meson_g12a_remove(struct platform_device *pdev)
> if (priv->drvdata->otg_switch_supported)
> usb_role_switch_unregister(priv->role_switch);
>
> - of_platform_depopulate(dev);
> -
> for (i = 0 ; i < PHY_COUNT ; ++i) {
> phy_power_off(priv->phys[i]);
> phy_exit(priv->phys[i]);

Does it matter that the order that things happen in
dwc3_meson_g12a_remove() is changed as a result of your patch? Was
the code relying on the platform devices being depopulated before
powering off the PHYs?

> diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
> index e62ecd22b3ed..f1c267e39d62 100644
> --- a/drivers/usb/dwc3/dwc3-of-simple.c
> +++ b/drivers/usb/dwc3/dwc3-of-simple.c
> @@ -73,7 +73,7 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
> if (ret)
> goto err_resetc_assert;
>
> - ret = of_platform_populate(np, NULL, NULL, dev);
> + ret = devm_of_platform_populate(dev);
> if (ret)
> goto err_clk_put;
>
> @@ -97,8 +97,6 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
>
> static void __dwc3_of_simple_teardown(struct dwc3_of_simple *simple)
> {
> - of_platform_depopulate(simple->dev);
> -
> clk_bulk_disable_unprepare(simple->num_clocks, simple->clks);
> clk_bulk_put_all(simple->num_clocks, simple->clks);
> simple->num_clocks = 0;

Same here... and for anywhere else in this patch that you're deleting
a of_platform_depopulate().

You effectively are moving the call to of_platform_depopulate() *after*
the driver's .remove function has been called.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!