Re: [PATCH v3 1/2] iio:adc:ad7476: Handle the different regulators used by various parts.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 24 Apr 2021 20:20:41 +0200
Lars-Peter Clausen <lars@xxxxxxxxxx> wrote:

> On 4/24/21 7:03 PM, Jonathan Cameron wrote:
> > [...]
> >   
> > +	/* Either vcc or vref (below) as appropriate */
> > +	if (!st->chip_info->int_vref_uv)
> > +		st->ref_reg = reg;
> > +
> > +	if (st->chip_info->has_vref) {
> > +
> > +		/* If a device has an internal reference vref is optional */
> > +		if (st->chip_info->int_vref_uv) {
> > +			reg = devm_regulator_get_optional(&spi->dev, "vref");
> > +		} else {
> > +			reg = devm_regulator_get(&spi->dev, "vref");
> > +			if (IS_ERR(reg))
> > +				return PTR_ERR(reg);
> > +		}
> > +
> > +		if (!IS_ERR(reg)) {
> > +			ret = regulator_enable(reg);
> > +			if (ret)
> > +				return ret;
> > +
> > +			ret = devm_add_action_or_reset(&spi->dev,
> > +						       ad7476_reg_disable,
> > +						       reg);
> > +			if (ret)
> > +				return ret;
> > +			st->ref_reg = reg;
> > +		} else {  
> We still need to check for errors, e.g. to support EPROBE_DEFER. The 
> only error that can be ignored is ENOENT, which means no regulator is 
> specified.
Good point.  I got fixated on all the different combinations and forgot the
simple 'error' case :)

V4 coming up.

Jonathan

> > +			/*
> > +			 * Can only get here if device supports both internal
> > +			 * and external reference, but the regulator connected
> > +			 * to the external reference is not connected.
> > +			 * Set the reference regulator pointer to NULL to
> > +			 * indicate this.
> > +			 */
> > +			st->ref_reg = NULL;
> > +		}
> > +	}  
> 




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux