]> git.karo-electronics.de Git - linux-beck.git/commit
staging: iio: rework regulator handling
authorEva Rachel Retuya <eraretuya@gmail.com>
Mon, 31 Oct 2016 17:04:31 +0000 (01:04 +0800)
committerJonathan Cameron <jic23@kernel.org>
Sat, 5 Nov 2016 16:17:14 +0000 (16:17 +0000)
commit3925ff0fcba71a27be14b19b01c0b67efbab0be9
treec883307ec50eed96f53ad463a603d4445250860d
parentc834e1718aae6150936af718db9e483993d2c63f
staging: iio: rework regulator handling

Currently, the affected drivers ignore all errors from regulator_get().
The way it is now, it also breaks probe deferral (EPROBE_DEFER). The
correct behavior is to propagate the error to the upper layers so they
can handle it accordingly.

Rework the regulator handling so that it matches the standard behavior.
If the specific design uses a static always-on regulator and does not
explicitly specify it, regulator_get() will return the dummy regulator.

The following semantic patch was used to apply the change:
@r1@
expression reg, dev, en, volt;
@@

reg = \(devm_regulator_get\|regulator_get\)(dev, ...);
if (
- !
   IS_ERR(reg))
+ return PTR_ERR(reg);
(
- { en = regulator_enable(reg);
- if (en) return en; }
+
+ en = regulator_enable(reg);
+ if (en) {
+ dev_err(dev, "Failed to enable specified supply\n");
+ return en; }
|
+
- { en = regulator_enable(reg);
- if (en) return en;
- volt = regulator_get_voltage(reg); }
+ en = regulator_enable(reg);
+ if (en) {
+ dev_err(dev, "Failed to enable specified supply\n");
+ return en;
+ }
+ volt = regulator_get_voltage(reg);
)

@r2@
expression arg;
@@

- if (!IS_ERR(arg)) regulator_disable(arg);
+ regulator_disable(arg);

Hand-edit the debugging prints with the supply name to become more
specific.

Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/adc/ad7192.c
drivers/staging/iio/adc/ad7780.c
drivers/staging/iio/frequency/ad9832.c
drivers/staging/iio/frequency/ad9834.c
drivers/staging/iio/impedance-analyzer/ad5933.c