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 4/25/21 6:02 PM, Jonathan Cameron wrote:
On Sun, 25 Apr 2021 16:18:02 +0100
Jonathan Cameron <jic23@xxxxxxxxxx> wrote:

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 :)
As far as I can tell -ENODEV is the return for no regulator specified.

Yes. We even have a few examples like the ad7124 driver.




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux