[PATCH] usb: uhci-platform: Make the clock really optional

Alexey Charkov posted 1 patch 7 months, 3 weeks ago
drivers/usb/host/uhci-platform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] usb: uhci-platform: Make the clock really optional
Posted by Alexey Charkov 7 months, 3 weeks ago
Device tree bindings state that the clock is optional for UHCI platform
controllers, and some existing device trees don't provide those - such
as those for VIA/WonderMedia devices.

The driver however fails to probe now if no clock is provided, because
devm_clk_get returns an error pointer in such case.

Switch to devm_clk_get_optional instead, so that it could probe again
on those platforms where no clocks are given.

Cc: stable@vger.kernel.org
Fixes: 26c502701c52 ("usb: uhci: Add clk support to uhci-platform")
Signed-off-by: Alexey Charkov <alchark@gmail.com>
---
 drivers/usb/host/uhci-platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c
index a7c934404ebc7ed74f64265fafa7830809979ba5..62318291f5664c9ec94f24535c71d962e28354f3 100644
--- a/drivers/usb/host/uhci-platform.c
+++ b/drivers/usb/host/uhci-platform.c
@@ -121,7 +121,7 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev)
 	}
 
 	/* Get and enable clock if any specified */
-	uhci->clk = devm_clk_get(&pdev->dev, NULL);
+	uhci->clk = devm_clk_get_optional(&pdev->dev, NULL);
 	if (IS_ERR(uhci->clk)) {
 		ret = PTR_ERR(uhci->clk);
 		goto err_rmr;

---
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
change-id: 20250425-uhci-clock-optional-9a9d09560e17

Best regards,
-- 
Alexey Charkov <alchark@gmail.com>
Re: [PATCH] usb: uhci-platform: Make the clock really optional
Posted by Greg Kroah-Hartman 7 months, 3 weeks ago
On Fri, Apr 25, 2025 at 06:11:11PM +0400, Alexey Charkov wrote:
> Device tree bindings state that the clock is optional for UHCI platform
> controllers, and some existing device trees don't provide those - such
> as those for VIA/WonderMedia devices.
> 
> The driver however fails to probe now if no clock is provided, because
> devm_clk_get returns an error pointer in such case.
> 
> Switch to devm_clk_get_optional instead, so that it could probe again
> on those platforms where no clocks are given.
> 
> Cc: stable@vger.kernel.org
> Fixes: 26c502701c52 ("usb: uhci: Add clk support to uhci-platform")
> Signed-off-by: Alexey Charkov <alchark@gmail.com>
> ---
>  drivers/usb/host/uhci-platform.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c
> index a7c934404ebc7ed74f64265fafa7830809979ba5..62318291f5664c9ec94f24535c71d962e28354f3 100644
> --- a/drivers/usb/host/uhci-platform.c
> +++ b/drivers/usb/host/uhci-platform.c
> @@ -121,7 +121,7 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev)
>  	}
>  
>  	/* Get and enable clock if any specified */
> -	uhci->clk = devm_clk_get(&pdev->dev, NULL);
> +	uhci->clk = devm_clk_get_optional(&pdev->dev, NULL);

Why does this need to go to all stable trees all of a sudden?  This has
been "broken" for years, what changed recently to cause this to show up?

thanks,

greg k-h
Re: [PATCH] usb: uhci-platform: Make the clock really optional
Posted by Alexey Charkov 7 months, 3 weeks ago
On Fri, Apr 25, 2025 at 6:20 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Fri, Apr 25, 2025 at 06:11:11PM +0400, Alexey Charkov wrote:
> > Device tree bindings state that the clock is optional for UHCI platform
> > controllers, and some existing device trees don't provide those - such
> > as those for VIA/WonderMedia devices.
> >
> > The driver however fails to probe now if no clock is provided, because
> > devm_clk_get returns an error pointer in such case.
> >
> > Switch to devm_clk_get_optional instead, so that it could probe again
> > on those platforms where no clocks are given.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: 26c502701c52 ("usb: uhci: Add clk support to uhci-platform")
> > Signed-off-by: Alexey Charkov <alchark@gmail.com>
> > ---
> >  drivers/usb/host/uhci-platform.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c
> > index a7c934404ebc7ed74f64265fafa7830809979ba5..62318291f5664c9ec94f24535c71d962e28354f3 100644
> > --- a/drivers/usb/host/uhci-platform.c
> > +++ b/drivers/usb/host/uhci-platform.c
> > @@ -121,7 +121,7 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev)
> >       }
> >
> >       /* Get and enable clock if any specified */
> > -     uhci->clk = devm_clk_get(&pdev->dev, NULL);
> > +     uhci->clk = devm_clk_get_optional(&pdev->dev, NULL);
>
> Why does this need to go to all stable trees all of a sudden?  This has
> been "broken" for years, what changed recently to cause this to show up?

Users who suffer from nonfunctional built-in keyboards on WM8650 and
WM8850 based laptops complain. It used to work on even older kernels,
but not on current ones. What changed is that I found the time to
investigate :)

The way 26c502701c52 ("usb: uhci: Add clk support to uhci-platform")
described the change implies that "optional" was the intended behavior
from the outset, so I believe it deserves a backport. Don't know if
the age of a regression prevents it from being considered a regression
or not.

Best regards,
Alexey