[PATCH] usb: i.MX: improve regulator handling

Sascha Hauer s.hauer at pengutronix.de
Wed Oct 21 08:31:35 EDT 2020


On Wed, Oct 21, 2020 at 02:03:43PM +0200, Uwe Kleine-König wrote:
> On Wed, Oct 21, 2020 at 12:05:48PM +0200, Sascha Hauer wrote:
> > On Tue, Oct 20, 2020 at 01:15:37PM +0200, Uwe Kleine-König wrote:
> > > Instead of just ignoring errors related to regulator getting error out.
> > > In case there is no regulator in the device tree, regulator_get() returns
> > > the dummy regulator and not an error code, so the change is right for
> > > this situation, too.
> > > 
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
> > > ---
> > >  drivers/usb/imx/chipidea-imx.c | 7 +++++--
> > >  1 file changed, 5 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c
> > > index 786beede6d89..dd0e3c1a2a58 100644
> > > --- a/drivers/usb/imx/chipidea-imx.c
> > > +++ b/drivers/usb/imx/chipidea-imx.c
> > > @@ -267,8 +267,11 @@ static int imx_chipidea_probe(struct device_d *dev)
> > >  	}
> > >  
> > >  	ci->vbus = regulator_get(dev, "vbus");
> > > -	if (IS_ERR(ci->vbus))
> > > -		ci->vbus = NULL;
> > > +	if (IS_ERR(ci->vbus)) {
> > > +		ret = ERR_PTR(ci->vbus);
> > > +		dev_err(dev, "Cannot get vbus regulator: %s\n", strerror(-ret));
> > > +		return ret;
> > > +	}
> > 
> > Ok, as Marco noted we had regressions in similar cases where we didn't
> > have a driver for the regulator, but knew that it was default enabled.
> > Therefore I am dropping this patch.
> 
> So you prefer "fails on some boards with a missleading (or at least
> little helpful) error message" over "fails on some (other) boards with
> an obvious error indication"?
> 
> I think I would have decided this differently. And IMHO then this should
> at least result in a runtime warning instead of being silently
> optimistic.

Have a look at what I suggested in my other mail. With an additional
device tree property saying "barebox: Ignore absent regulator" I would
have a way telling people how to fix the regression. With that
implemented we could merge your patch.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list