* [PATCH v3 1/5] usb: ehci-exynos: Use devm_clk_get_enabled() helpers
[not found] <20240412142317.5191-1-linux.amoon@gmail.com>
@ 2024-04-12 14:22 ` Anand Moon
2024-04-12 14:58 ` Alan Stern
2024-04-12 14:22 ` [PATCH v3 2/5] usb: ehci-exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Anand Moon
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Anand Moon @ 2024-04-12 14:22 UTC (permalink / raw
To: Alan Stern, Greg Kroah-Hartman, Krzysztof Kozlowski, Alim Akhtar
Cc: Anand Moon, Christophe JAILLET, Johan Hovold, Thinh Nguyen,
linux-usb, linux-arm-kernel, linux-samsung-soc, linux-kernel
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().
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
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(-)
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index f644b131cc0b..e2303757bc0f 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -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);
}
--
2.44.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/5] usb: ehci-exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
[not found] <20240412142317.5191-1-linux.amoon@gmail.com>
2024-04-12 14:22 ` [PATCH v3 1/5] usb: ehci-exynos: Use devm_clk_get_enabled() helpers Anand Moon
@ 2024-04-12 14:22 ` Anand Moon
2024-04-12 14:22 ` [PATCH v3 3/5] usb: ohci-exynos: Use devm_clk_get_enabled() helpers Anand Moon
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Anand Moon @ 2024-04-12 14:22 UTC (permalink / raw
To: Alan Stern, Greg Kroah-Hartman, Krzysztof Kozlowski, Alim Akhtar
Cc: Anand Moon, Christophe JAILLET, Johan Hovold, Thinh Nguyen,
linux-usb, linux-arm-kernel, linux-samsung-soc, linux-kernel
This 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.
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
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(-)
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index e2303757bc0f..f40bc2a7a124 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -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),
}
};
--
2.44.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/5] usb: ohci-exynos: Use devm_clk_get_enabled() helpers
[not found] <20240412142317.5191-1-linux.amoon@gmail.com>
2024-04-12 14:22 ` [PATCH v3 1/5] usb: ehci-exynos: Use devm_clk_get_enabled() helpers Anand Moon
2024-04-12 14:22 ` [PATCH v3 2/5] usb: ehci-exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Anand Moon
@ 2024-04-12 14:22 ` Anand Moon
2024-04-12 14:22 ` [PATCH v3 4/5] usb: ohci-exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Anand Moon
2024-04-12 14:22 ` [PATCH v3 5/5] usb: dwc3: exynos: " Anand Moon
4 siblings, 0 replies; 7+ messages in thread
From: Anand Moon @ 2024-04-12 14:22 UTC (permalink / raw
To: Alan Stern, Greg Kroah-Hartman, Krzysztof Kozlowski, Alim Akhtar
Cc: Anand Moon, Christophe JAILLET, Johan Hovold, Thinh Nguyen,
linux-usb, linux-arm-kernel, linux-samsung-soc, linux-kernel
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().
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
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(-)
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 20e26a474591..89e6587c089b 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -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);
}
--
2.44.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 4/5] usb: ohci-exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
[not found] <20240412142317.5191-1-linux.amoon@gmail.com>
` (2 preceding siblings ...)
2024-04-12 14:22 ` [PATCH v3 3/5] usb: ohci-exynos: Use devm_clk_get_enabled() helpers Anand Moon
@ 2024-04-12 14:22 ` Anand Moon
2024-04-12 14:22 ` [PATCH v3 5/5] usb: dwc3: exynos: " Anand Moon
4 siblings, 0 replies; 7+ messages in thread
From: Anand Moon @ 2024-04-12 14:22 UTC (permalink / raw
To: Alan Stern, Greg Kroah-Hartman, Krzysztof Kozlowski, Alim Akhtar
Cc: Anand Moon, Christophe JAILLET, Johan Hovold, Thinh Nguyen,
linux-usb, linux-arm-kernel, linux-samsung-soc, linux-kernel
This 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.
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
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(-)
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 89e6587c089b..3c4d68fd5c33 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -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),
}
};
--
2.44.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 5/5] usb: dwc3: exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
[not found] <20240412142317.5191-1-linux.amoon@gmail.com>
` (3 preceding siblings ...)
2024-04-12 14:22 ` [PATCH v3 4/5] usb: ohci-exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Anand Moon
@ 2024-04-12 14:22 ` Anand Moon
2024-04-16 0:44 ` Thinh Nguyen
4 siblings, 1 reply; 7+ messages in thread
From: Anand Moon @ 2024-04-12 14:22 UTC (permalink / raw
To: Thinh Nguyen, Greg Kroah-Hartman, Krzysztof Kozlowski,
Alim Akhtar
Cc: Anand Moon, Christophe JAILLET, Johan Hovold, linux-usb,
linux-arm-kernel, linux-samsung-soc, linux-kernel
This 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.
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
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(-)
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index 5d365ca51771..3427522a7c6a 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -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),
},
};
--
2.44.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/5] usb: ehci-exynos: Use devm_clk_get_enabled() helpers
2024-04-12 14:22 ` [PATCH v3 1/5] usb: ehci-exynos: Use devm_clk_get_enabled() helpers Anand Moon
@ 2024-04-12 14:58 ` Alan Stern
0 siblings, 0 replies; 7+ messages in thread
From: Alan Stern @ 2024-04-12 14:58 UTC (permalink / raw
To: Anand Moon
Cc: Greg Kroah-Hartman, Krzysztof Kozlowski, Alim Akhtar,
Christophe JAILLET, Johan Hovold, Thinh Nguyen, linux-usb,
linux-arm-kernel, linux-samsung-soc, linux-kernel
On Fri, Apr 12, 2024 at 07:52:50PM +0530, Anand Moon wrote:
> 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().
>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
For patches 1 - 4:
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 5/5] usb: dwc3: exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
2024-04-12 14:22 ` [PATCH v3 5/5] usb: dwc3: exynos: " Anand Moon
@ 2024-04-16 0:44 ` Thinh Nguyen
0 siblings, 0 replies; 7+ messages in thread
From: Thinh Nguyen @ 2024-04-16 0:44 UTC (permalink / raw
To: Anand Moon
Cc: Thinh Nguyen, Greg Kroah-Hartman, Krzysztof Kozlowski,
Alim Akhtar, Christophe JAILLET, Johan Hovold,
linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org
On Fri, Apr 12, 2024, Anand Moon wrote:
> This 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.
>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
> 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(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
> index 5d365ca51771..3427522a7c6a 100644
> --- a/drivers/usb/dwc3/dwc3-exynos.c
> +++ b/drivers/usb/dwc3/dwc3-exynos.c
> @@ -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),
> },
> };
>
> --
> 2.44.0
>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Thanks,
Thinh
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-04-16 0:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20240412142317.5191-1-linux.amoon@gmail.com>
2024-04-12 14:22 ` [PATCH v3 1/5] usb: ehci-exynos: Use devm_clk_get_enabled() helpers Anand Moon
2024-04-12 14:58 ` Alan Stern
2024-04-12 14:22 ` [PATCH v3 2/5] usb: ehci-exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Anand Moon
2024-04-12 14:22 ` [PATCH v3 3/5] usb: ohci-exynos: Use devm_clk_get_enabled() helpers Anand Moon
2024-04-12 14:22 ` [PATCH v3 4/5] usb: ohci-exynos: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Anand Moon
2024-04-12 14:22 ` [PATCH v3 5/5] usb: dwc3: exynos: " Anand Moon
2024-04-16 0:44 ` Thinh Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).