Re: [PATCH 1/3] usb: host: ohci-platform: Add basic runtime PM support
From: Alan Stern <hidden>
Date: 2017-05-23 16:53:47
Also in:
linux-omap
On Mon, 22 May 2017, Tony Lindgren wrote:
quoted hunk
This is needed in preparation of adding support for omap3 and later OHCI. The runtime PM will only do something on platforms that implement it. Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Hans de Goede <redacted> Cc: Rob Herring <redacted> Cc: Roger Quadros <redacted> Cc: Sebastian Reichel <sebastian.reichel-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org> Cc: Yoshihiro Shimoda <redacted> Signed-off-by: Tony Lindgren <redacted> --- Alan, do you have some better ideas for the ohci_platform_remove() path below? --- drivers/usb/host/ohci-platform.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c --- a/drivers/usb/host/ohci-platform.c +++ b/drivers/usb/host/ohci-platform.c@@ -24,6 +24,7 @@ #include <linux/err.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/pm_runtime.h> #include <linux/reset.h> #include <linux/usb/ohci_pdriver.h> #include <linux/usb.h>@@ -242,6 +243,8 @@ static int ohci_platform_probe(struct platform_device *dev) } #endif + pm_runtime_set_active(&dev->dev); + pm_runtime_enable(&dev->dev); if (pdata->power_on) { err = pdata->power_on(dev); if (err < 0)@@ -271,6 +274,7 @@ static int ohci_platform_probe(struct platform_device *dev) if (pdata->power_off) pdata->power_off(dev); err_reset: + pm_runtime_disable(&dev->dev); while (--rst >= 0) reset_control_assert(priv->resets[rst]); err_put_clks:@@ -290,7 +294,14 @@ static int ohci_platform_remove(struct platform_device *dev) struct usb_hcd *hcd = platform_get_drvdata(dev); struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); - int clk, rst; + int clk, rst, enabled; + + enabled = pm_runtime_get_sync(&dev->dev); + if (enabled < 0) { + dev_warn(&dev->dev, "pm_runtime_get failed: %i\n", + enabled); + pm_runtime_put_noidle(&dev->dev); + }
I wouldn't worry about checking the return value. There's no particular reason for this call to fail, is there?
quoted hunk
usb_remove_hcd(hcd);@@ -305,6 +316,10 @@ static int ohci_platform_remove(struct platform_device *dev) usb_put_hcd(hcd); + if (enabled >= 0) + pm_runtime_put_sync(&dev->dev); + pm_runtime_disable(&dev->dev);
And here you could just do the put_sync, with no test. If the get_sync failed then this will probably fail too, but you won't be any worse off for the attempt. Alan Stern
+ if (pdata == &ohci_platform_defaults) dev->dev.platform_data = NULL;
-- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html