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. Jonathan > > 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; > > > + } > > > + } > > >