lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240325200625.5a07cec4@jic23-huawei>
Date: Mon, 25 Mar 2024 20:06:25 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: David Lechner <dlechner@...libre.com>, Mark Brown <broonie@...nel.org>
Cc: Julien Stephan <jstephan@...libre.com>, Lars-Peter Clausen
 <lars@...afoo.de>, Michael Hennerich <Michael.Hennerich@...log.com>, Nuno
 Sá <nuno.sa@...log.com>, Rob Herring <robh+dt@...nel.org>,
 Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>, Conor Dooley
 <conor+dt@...nel.org>, Liam Girdwood <lgirdwood@...il.com>,
 linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
 linux-kernel@...r.kernel.org, kernel test robot <lkp@...el.com>
Subject: Re: [PATCH v5 4/7] iio: adc: ad7380: add support for
 pseudo-differential parts


> > > +     /*
> > > +      * pseudo-differential chips have common mode supplies for the negative
> > > +      * input pin.
> > > +      */
> > > +     for (i = 0; i < st->chip_info->num_vcm_supplies; i++) {
> > > +             struct regulator *vcm;
> > > +
> > > +             vcm = devm_regulator_get_optional(&spi->dev,  
> >
> > Why optional?
> >  
> > > +                                               st->chip_info->vcm_supplies[i]);
> > > +             if (IS_ERR(vcm))  
> >
> > This will fail if it's not there, so I'm guessing you are using this to avoid
> > getting to the regulator_get_voltage?  If it's not present I'd rely on that
> > failing rather than the confusing handling here.
> >
> > When the read of voltage wasn't in probe this would have resulted in a problem
> > much later than initial setup, now it is, we are just pushing it down a few lines.
> >
> > Arguably we could have a devm_regulator_get_not_dummy()
> > that had same implementation to as get_optional() but whilst it's called that
> > I think it's confusing to use like this.  
> 
> Despite the misleading naming, I guess I am used to
> devm_regulator_get_optional() by now having used it enough times.
> Since it fails either way though, technically both ways seem fine so I
> can't really argue for one over the other.
> 
> But given that this is a common pattern in many IIO drivers, maybe we
> make a devm_regulator_get_enable_get_voltage()? This would return the
> voltage on success or an error code. (If the regulator subsystem
> doesn't want this maybe we could have
> devm_iio_regulator_get_enable_get_voltage()).
> 
> If the dev_err_probe() calls were included in
> devm_regulator_get_enable_get_voltage(), then the 10+ lines of code
> here and in many other drivers to get the regulator, enable it, add
> the reset action and get the voltage could be reduced to 3 lines.

I like this proposal a lot. RFC, so it's visible outside the depths
of this thread?
Particularly good as it will keep the regulator opaque in the same
fashion as devm_regulator_get_enabled()

As you say, we have a 'lot' of instances of this (quick grep
suggests > 50 in IIO alone and smaller numbers elsewhere).

Jonathan


> 
> >  
> > > +                     return dev_err_probe(&spi->dev, PTR_ERR(vcm),
> > > +                                          "Failed to get %s regulator\n",
> > > +                                          st->chip_info->vcm_supplies[i]);
> > > +
> > > +             ret = regulator_enable(vcm);
> > > +             if (ret)
> > > +                     return ret;
> > > +
> > > +             ret = devm_add_action_or_reset(&spi->dev,
> > > +                                            ad7380_regulator_disable, vcm);
> > > +             if (ret)
> > > +                     return ret;
> > > +
> > > +             ret = regulator_get_voltage(vcm);  
> >
> > I'd let this fail if we have a dummy regulator.
> >  
> > > +             if (ret < 0)
> > > +                     return ret;
> > > +
> > > +             st->vcm_mv[i] = ret / 1000;
> > > +     }
> > > +  
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ