Commit 53c6b0d5 authored by Alexandru Ardelean's avatar Alexandru Ardelean Committed by Jonathan Cameron

iio: adc: ad7298: check regulator for null in ad7298_get_ref_voltage()

'st->ext_ref' & 'st->reg' are both non-zero/non-null at the same time, so
logically the code isn't broken.
But it is more correct to check that 'st->reg' is non-null, since we make
sure that the regulator is NULL (in probe) in case one isn't defined.
Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
Cc: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20201127094038.91714-2-alexandru.ardelean@analog.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent b6a3f832
...@@ -214,7 +214,7 @@ static int ad7298_get_ref_voltage(struct ad7298_state *st) ...@@ -214,7 +214,7 @@ static int ad7298_get_ref_voltage(struct ad7298_state *st)
{ {
int vref; int vref;
if (st->ext_ref) { if (st->reg) {
vref = regulator_get_voltage(st->reg); vref = regulator_get_voltage(st->reg);
if (vref < 0) if (vref < 0)
return vref; return vref;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment