usb: ehci-exynos: Use devm_clk_get_enabled() helpers
Subsystems (5)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v3 1/5 usb: ehci-exynos: Use devm_clk_get_enabled() helpers
The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids the calls to clk_disable_unprepare().
---
v3: drop dev_err_probe to simplify the error handle.
v2: drop the clk_disable_unprepare in suspend/resume functions
fix the usb_put_hcd return before the devm_clk_get_enabled
--- drivers/usb/host/ehci-exynos.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/usb/host/ehci-exynos.c +3 -11
@@ -159,20 +159,16 @@ static int exynos_ehci_probe(struct platform_device *pdev) err =exynos_ehci_get_phy (&pdev->dev, exynos_ehci);if (err) - goto fail_clk; + goto fail_io; - exynos_ehci->clk =devm_clk_get (&pdev->dev,"usbhost" ); + exynos_ehci->clk =devm_clk_get_enabled (&pdev->dev,"usbhost" );if (IS_ERR (exynos_ehci->clk)) {dev_err (&pdev->dev,"Failed to get usbhost clock\n" ); err =PTR_ERR (exynos_ehci->clk); - goto fail_clk; + goto fail_io; } - err =clk_prepare_enable (exynos_ehci->clk); -if (err) - goto fail_clk; - hcd->regs =devm_platform_get_and_ioremap_resource (pdev,0 , &res);if (IS_ERR (hcd->regs)) { err =PTR_ERR (hcd->regs);
@@ -223,8 +219,6 @@ static int exynos_ehci_probe(struct platform_device *pdev)exynos_ehci_phy_disable (&pdev->dev); pdev->dev.of_node = exynos_ehci->of_node; fail_io: -clk_disable_unprepare (exynos_ehci->clk); -fail_clk:usb_put_hcd (hcd);return err; }
@@ -240,8 +234,6 @@ static void exynos_ehci_remove(struct platform_device *pdev)exynos_ehci_phy_disable (&pdev->dev); -clk_disable_unprepare (exynos_ehci->clk); -usb_put_hcd (hcd); }
Signature · 1 line
2.44.0
Quoted 9 lines · Anand Moon
The
devm_clk_get_enabled()helpers:
- calldevm_clk_get()
- callclk_prepare_enable()and register what is needed in order to callclk_disable_unprepare()when needed, as a managed resource.This simplifies the code and avoids the calls to
clk_disable_unprepare().Signed-off-by Anand Moon <[email protected]>---
For patches 1 - 4:
PATCH v3 2/5 usb: ehci-exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
In reply to a message not in the archiveThis macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to care about when the functions are actually used.
Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM isn't enabled.
---
v3: fix using new DEFINE_SIMPLE_DEV_PM_OPS PM macro hence
change the $subject and the commit message
v2: add __maybe_unused to suspend/resume functions in case CONFIG_PM
is disabled.
dropped RUNTIME_PM_OPS
--- drivers/usb/host/ehci-exynos.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/usb/host/ehci-exynos.c +3 -10
@@ -237,7 +237,6 @@ static void exynos_ehci_remove(struct platform_device *pdev)usb_put_hcd (hcd); } -#ifdef CONFIG_PM static int exynos_ehci_suspend (struct device *dev) {struct usb_hcd *hcd =dev_get_drvdata (dev);
@@ -280,15 +279,9 @@ static int exynos_ehci_resume(struct device *dev)ehci_resume (hcd, false);return 0 ; } -#else -#define exynos_ehci_suspend NULL -#define exynos_ehci_resume NULL -#endif -static const struct dev_pm_ops exynos_ehci_pm_ops = { - .suspend = exynos_ehci_suspend, - .resume = exynos_ehci_resume, -}; +static DEFINE_SIMPLE_DEV_PM_OPS(exynos_ehci_pm_ops, + exynos_ehci_suspend, exynos_ehci_resume);#ifdef CONFIG_OF static const struct of_device_id exynos_ehci_match[] = {
@@ -304,7 +297,7 @@ static struct platform_driver exynos_ehci_driver = { .shutdown = usb_hcd_platform_shutdown, .driver = { .name = "exynos-ehci", - .pm = &exynos_ehci_pm_ops, + .pm = pm_ptr(&exynos_ehci_pm_ops), .of_match_table = of_match_ptr(exynos_ehci_match), } };
Signature · 1 line
2.44.0
PATCH v3 3/5 usb: ohci-exynos: Use devm_clk_get_enabled() helpers
In reply to a message not in the archiveThe devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids the calls to clk_disable_unprepare().
---
v3: drop dev_err_probe to simplify the error handle.
v2: new patch in this series
--- drivers/usb/host/ohci-exynos.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/usb/host/ohci-exynos.c +3 -11
@@ -135,20 +135,16 @@ static int exynos_ohci_probe(struct platform_device *pdev) err =exynos_ohci_get_phy (&pdev->dev, exynos_ohci);if (err) - goto fail_clk; + goto fail_io; - exynos_ohci->clk =devm_clk_get (&pdev->dev,"usbhost" ); + exynos_ohci->clk =devm_clk_get_enabled (&pdev->dev,"usbhost" );if (IS_ERR (exynos_ohci->clk)) {dev_err (&pdev->dev,"Failed to get usbhost clock\n" ); err =PTR_ERR (exynos_ohci->clk); - goto fail_clk; + goto fail_io; } - err =clk_prepare_enable (exynos_ohci->clk); -if (err) - goto fail_clk; - hcd->regs =devm_platform_get_and_ioremap_resource (pdev,0 , &res);if (IS_ERR (hcd->regs)) { err =PTR_ERR (hcd->regs);
@@ -191,8 +187,6 @@ static int exynos_ohci_probe(struct platform_device *pdev)exynos_ohci_phy_disable (&pdev->dev); pdev->dev.of_node = exynos_ohci->of_node; fail_io: -clk_disable_unprepare (exynos_ohci->clk); -fail_clk:usb_put_hcd (hcd);return err; }
@@ -208,8 +202,6 @@ static void exynos_ohci_remove(struct platform_device *pdev)exynos_ohci_phy_disable (&pdev->dev); -clk_disable_unprepare (exynos_ohci->clk); -usb_put_hcd (hcd); }
Signature · 1 line
2.44.0
PATCH v3 4/5 usb: ohci-exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
In reply to a message not in the archiveThis macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to care about when the functions are actually used.
Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM isn't enabled.
---
v3: fix using new DEFINE_SIMPLE_DEV_PM_OPS PM macro hence
change the $subject and the commit message
v2: new file
--- drivers/usb/host/ohci-exynos.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/usb/host/ohci-exynos.c +3 -10
@@ -213,7 +213,6 @@ static void exynos_ohci_shutdown(struct platform_device *pdev) hcd->driver->shutdown (hcd); } -#ifdef CONFIG_PM static int exynos_ohci_suspend (struct device *dev) {struct usb_hcd *hcd =dev_get_drvdata (dev);
@@ -250,19 +249,13 @@ static int exynos_ohci_resume(struct device *dev)return 0 ; } -#else -#define exynos_ohci_suspend NULL -#define exynos_ohci_resume NULL -#endif static const struct ohci_driver_overrides exynos_overrides__initconst = { .extra_priv_size =sizeof (struct exynos_ohci_hcd ), }; -static const struct dev_pm_ops exynos_ohci_pm_ops = { - .suspend = exynos_ohci_suspend, - .resume = exynos_ohci_resume, -}; +static DEFINE_SIMPLE_DEV_PM_OPS(exynos_ohci_pm_ops, + exynos_ohci_suspend, exynos_ohci_resume);#ifdef CONFIG_OF static const struct of_device_id exynos_ohci_match[] = {
@@ -278,7 +271,7 @@ static struct platform_driver exynos_ohci_driver = { .shutdown = exynos_ohci_shutdown, .driver = { .name = "exynos-ohci", - .pm = &exynos_ohci_pm_ops, + .pm = pm_ptr(&exynos_ohci_pm_ops), .of_match_table = of_match_ptr(exynos_ohci_match), } };
Signature · 1 line
2.44.0
PATCH v3 5/5 usb: dwc3: exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
In reply to a message not in the archiveThis macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to care about when the functions are actually used.
Also make use of pm_sleep_ptr() to discard all PM_SLEEP related stuff if CONFIG_PM_SLEEP isn't enabled.
---
v3: fix using new DEFINE_SIMPLE_DEV_PM_OPS PM macro hence
change the $subject and the commit message
v2: add __maybe_unused to suspend/resume functions in case CONFIG_PM
is disabled.
--- drivers/usb/dwc3/dwc3-exynos.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/usb/dwc3/dwc3-exynos.c +3 -10
@@ -187,7 +187,6 @@ static const struct of_device_id exynos_dwc3_match[] = { };MODULE_DEVICE_TABLE (of, exynos_dwc3_match); -#ifdef CONFIG_PM_SLEEP static int dwc3_exynos_suspend (struct device *dev) {struct dwc3_exynos *exynos =dev_get_drvdata (dev);
@@ -230,14 +229,8 @@ static int dwc3_exynos_resume(struct device *dev)return 0 ; } -static const struct dev_pm_ops dwc3_exynos_dev_pm_ops = { -SET_SYSTEM_SLEEP_PM_OPS (dwc3_exynos_suspend, dwc3_exynos_resume) -}; - -#define DEV_PM_OPS (&dwc3_exynos_dev_pm_ops) -#else -#define DEV_PM_OPS NULL -#endif /* CONFIG_PM_SLEEP */ +static DEFINE_SIMPLE_DEV_PM_OPS(dwc3_exynos_dev_pm_ops, + dwc3_exynos_suspend, dwc3_exynos_resume);static struct platform_driver dwc3_exynos_driver = { .probe = dwc3_exynos_probe,
@@ -245,7 +238,7 @@ static struct platform_driver dwc3_exynos_driver = { .driver = { .name = "exynos-dwc3", .of_match_table = exynos_dwc3_match, - .pm = DEV_PM_OPS, + .pm = pm_sleep_ptr(&dwc3_exynos_dev_pm_ops), }, };
Signature · 1 line
2.44.0
Re: [PATCH v3 5/5] usb: dwc3: exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
Quoted 58 lines · Anand Moon
This macro has the advantage over
SIMPLE_DEV_PM_OPSthat we don't have to care about when the functions are actually used.Also make use of
pm_sleep_ptr()to discard allPM_SLEEPrelated stuff ifCONFIG_PM_SLEEPisn't enabled.Signed-off-by Anand Moon <[email protected]>---
v3: fix using newDEFINE_SIMPLE_DEV_PM_OPSPM macro hence
change the $subject and the commit messagev2: add
__maybe_unusedto suspend/resume functions in caseCONFIG_PM
is disabled.--- drivers/usb/dwc3/dwc3-exynos.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)drivers/usb/dwc3/dwc3-exynos.c +3
-10@@ -187,7 +187,6 @@ static const struct of_device_id exynos_dwc3_match[] = { };MODULE_DEVICE_TABLE (of, exynos_dwc3_match); -#ifdef CONFIG_PM_SLEEP static int dwc3_exynos_suspend (struct device *dev) {struct dwc3_exynos *exynos =dev_get_drvdata (dev);@@ -230,14 +229,8 @@ static int dwc3_exynos_resume(struct device *dev)return 0 ; } -static const struct dev_pm_ops dwc3_exynos_dev_pm_ops = { -SET_SYSTEM_SLEEP_PM_OPS (dwc3_exynos_suspend, dwc3_exynos_resume) -}; - -#define DEV_PM_OPS (&dwc3_exynos_dev_pm_ops) -#else -#define DEV_PM_OPS NULL -#endif /* CONFIG_PM_SLEEP */ +static DEFINE_SIMPLE_DEV_PM_OPS(dwc3_exynos_dev_pm_ops, + dwc3_exynos_suspend, dwc3_exynos_resume);static struct platform_driver dwc3_exynos_driver = { .probe = dwc3_exynos_probe,@@ -245,7 +238,7 @@ static struct platform_driver dwc3_exynos_driver = { .driver = { .name = "exynos-dwc3", .of_match_table = exynos_dwc3_match, - .pm = DEV_PM_OPS, + .pm = pm_sleep_ptr(&dwc3_exynos_dev_pm_ops), }, };Signature · 1 line
2.44.0
Thanks,
Thinh
Thinh Nguyen
maintainerRe: [PATCH v3 0/5] Use new helper function for clock and regulator
In reply to a message not in the archivePlease Cc linux-usb.
Quoted 41 lines · Anand Moon
using new helper functions for dev resources for clock and PM to simplify the code changes.
Addressed some review comments.
V3 changes:
1 Use newDEFINE_SIMPLE_DEV_PM_OPSmacro for PM operations
Thanks to Thinh Nguyen for your inputs.
so I have to update the $subject and commit messagee with using new macro.2 Drop the
dev_err_probein return to simplify the error for clocks.3 Dop the
devm_regulator_bulk_get_enablepatch.Tests on Odroid XU4 and Odroid U3.
found no regression with suspend resume functionality.Previous changes:
V2: https://urldefense.com/v3/__https://lore.kernel.org/all/[email protected]/__;!!A4F2R9G_pg!e0WD9azAHK8cfVD0LzhAenRu36MKAQ75iRWUvNLdvd7IxXtKCjPykjkqNDkFcopJHxnkQd50byH7yaupErXZxptcZg$Thanks
-AnandAnand Moon (5):
usb: ehci-exynos: Usedevm_clk_get_enabled()helpers
usb: ehci-exynos: UseDEFINE_SIMPLE_DEV_PM_OPSfor PM functions
usb: ohci-exynos: Usedevm_clk_get_enabled()helpers
usb: ohci-exynos: UseDEFINE_SIMPLE_DEV_PM_OPSfor PM functions
usb: dwc3: exynos: UseDEFINE_SIMPLE_DEV_PM_OPSfor PM functionsdrivers/usb/dwc3/dwc3-exynos.c | 13 +++---------- drivers/usb/host/ehci-exynos.c | 27 ++++++--------------------- drivers/usb/host/ohci-exynos.c | 27 ++++++--------------------- 3 files changed, 15 insertions(+), 52 deletions(-)Signature · 1 line
2.44.0
Re: [PATCH v3 0/5] Use new helper function for clock and regulator
Hi Thinh,
Quoted 3 lines · Thinh Nguyen
Please Cc linux-usb.
Yes, I will do this next time.
Thanks
-Anand