* [PATCH] USB: pxa27x_udc: check return value of clk_enable
@ 2026-03-01 16:23 Zhaoyang Yu
2026-03-01 16:37 ` Sergey Shtylyov
0 siblings, 1 reply; 4+ messages in thread
From: Zhaoyang Yu @ 2026-03-01 16:23 UTC (permalink / raw)
To: daniel, haojian.zhuang, robert.jarzmik, gregkh
Cc: linux-arm-kernel, linux-usb, linux-kernel, Zhaoyang Yu
clk_enable() may fail according to the API contract.
Previously, udc_enable() ignored its return value.
This patch checks the return value and logs an error
without continuing initialization if clk_enable fails.
Signed-off-by: Zhaoyang Yu <2426767509@qq.com>
---
drivers/usb/gadget/udc/pxa27x_udc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c
index 897f53601b5b..69fcecaf6061 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -1696,7 +1696,13 @@ static void udc_enable(struct pxa_udc *udc)
if (udc->enabled)
return;
- clk_enable(udc->clk);
+ int ret;
+
+ ret = clk_enable(udc->clk);
+ if (ret) {
+ dev_err(udc->dev, "clk_enable failed: %d\n", ret);
+ return;
+ }
udc_writel(udc, UDCICR0, 0);
udc_writel(udc, UDCICR1, 0);
udc_clear_mask_UDCCR(udc, UDCCR_UDE);
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] USB: pxa27x_udc: check return value of clk_enable
2026-03-01 16:23 [PATCH] USB: pxa27x_udc: check return value of clk_enable Zhaoyang Yu
@ 2026-03-01 16:37 ` Sergey Shtylyov
0 siblings, 0 replies; 4+ messages in thread
From: Sergey Shtylyov @ 2026-03-01 16:37 UTC (permalink / raw)
To: Zhaoyang Yu, daniel, haojian.zhuang, robert.jarzmik, gregkh
Cc: linux-arm-kernel, linux-usb, linux-kernel
On 3/1/26 7:23 PM, Zhaoyang Yu wrote:
> clk_enable() may fail according to the API contract.
> Previously, udc_enable() ignored its return value.
> This patch checks the return value and logs an error
> without continuing initialization if clk_enable fails.
>
> Signed-off-by: Zhaoyang Yu <2426767509@qq.com>
> ---
> drivers/usb/gadget/udc/pxa27x_udc.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c
> index 897f53601b5b..69fcecaf6061 100644
> --- a/drivers/usb/gadget/udc/pxa27x_udc.c
> +++ b/drivers/usb/gadget/udc/pxa27x_udc.c
> @@ -1696,7 +1696,13 @@ static void udc_enable(struct pxa_udc *udc)
> if (udc->enabled)
> return;
>
> - clk_enable(udc->clk);
> + int ret;
Please don't declare variables amidst of a function. IIRC, the Linux coding
style doesn't allow for this C++-ism...
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] USB: pxa27x_udc: check return value of clk_enable
@ 2026-03-01 16:55 Zhaoyang Yu
2026-03-11 12:49 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Zhaoyang Yu @ 2026-03-01 16:55 UTC (permalink / raw)
To: sergei.shtylyov, daniel, haojian.zhuang, robert.jarzmik, gregkh
Cc: linux-arm-kernel, linux-usb, linux-kernel, Zhaoyang Yu
clk_enable() may fail according to the API contract.
Previously, udc_enable() ignored its return value.
This patch checks the return value and logs an error
without continuing initialization if clk_enable fails.
Signed-off-by: Zhaoyang Yu <2426767509@qq.com>
---
drivers/usb/gadget/udc/pxa27x_udc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c
index 897f53601b5b..006d6d0a5f9a 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -1693,10 +1693,16 @@ static void udc_init_data(struct pxa_udc *dev)
*/
static void udc_enable(struct pxa_udc *udc)
{
+ int ret;
+
if (udc->enabled)
return;
- clk_enable(udc->clk);
+ ret = clk_enable(udc->clk);
+ if (ret) {
+ dev_err(udc->dev, "clk_enable failed: %d\n", ret);
+ return;
+ }
udc_writel(udc, UDCICR0, 0);
udc_writel(udc, UDCICR1, 0);
udc_clear_mask_UDCCR(udc, UDCCR_UDE);
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] USB: pxa27x_udc: check return value of clk_enable
2026-03-01 16:55 Zhaoyang Yu
@ 2026-03-11 12:49 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2026-03-11 12:49 UTC (permalink / raw)
To: Zhaoyang Yu
Cc: sergei.shtylyov, daniel, haojian.zhuang, robert.jarzmik,
linux-arm-kernel, linux-usb, linux-kernel
On Sun, Mar 01, 2026 at 04:55:53PM +0000, Zhaoyang Yu wrote:
> clk_enable() may fail according to the API contract.
> Previously, udc_enable() ignored its return value.
> This patch checks the return value and logs an error
> without continuing initialization if clk_enable fails.
>
> Signed-off-by: Zhaoyang Yu <2426767509@qq.com>
> ---
> drivers/usb/gadget/udc/pxa27x_udc.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c
> index 897f53601b5b..006d6d0a5f9a 100644
> --- a/drivers/usb/gadget/udc/pxa27x_udc.c
> +++ b/drivers/usb/gadget/udc/pxa27x_udc.c
> @@ -1693,10 +1693,16 @@ static void udc_init_data(struct pxa_udc *dev)
> */
> static void udc_enable(struct pxa_udc *udc)
> {
> + int ret;
> +
> if (udc->enabled)
> return;
>
> - clk_enable(udc->clk);
> + ret = clk_enable(udc->clk);
> + if (ret) {
> + dev_err(udc->dev, "clk_enable failed: %d\n", ret);
> + return;
> + }
If this can fail, it should return an error to the caller and it should
be handled properly there.
Also, this is a v2 patch, but you did not label it as such :(
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-11 12:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-01 16:23 [PATCH] USB: pxa27x_udc: check return value of clk_enable Zhaoyang Yu
2026-03-01 16:37 ` Sergey Shtylyov
-- strict thread matches above, loose matches on Subject: below --
2026-03-01 16:55 Zhaoyang Yu
2026-03-11 12:49 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox