Re: [PATCH 11/11] iio: pressure-core: st: Provide correct regulatorsupport

From: Mark Brown
Date: Wed Sep 04 2013 - 09:24:56 EST


On Wed, Sep 04, 2013 at 02:11:11PM +0100, Mark Rutland wrote:
> On Wed, Sep 04, 2013 at 10:31:43AM +0100, Lee Jones wrote:

> > + /* Regulator not mandatory, but if requested we should enable it. */
> > + pdata->regulator = regulator_get(&indio_dev->dev, "vdd");
> > + if (!IS_ERR_OR_NULL(pdata->regulator)) {

> Can regulator_get return NULL? As far as I can see, it either returns a
> valid reulator pointer or an ERR_PTR value.

Yes, NULL is a valid regulator.

> When you say "if requested", do you mean "if described in the dt"? If
> so, the above doesn't distunguish between a regulator not being listed
> and one failing to be got (e.g. if we got EPROBE_DEFER from
> regulator_get).

> I think this would be better handled with something like Mark Brown's
> suggested regulator_get_optional [1,2].

If the regulator may genuinely be absent from the system then it should
be being requested using regulator_get_optional(). Otherwise it should
be being requested using regulator_get(). In both cases it is important
that the driver pays attention to errors.

Attachment: signature.asc
Description: Digital signature