linux/drivers/regulator
Doug Anderson 32b783339f regulator: core: Fix enable GPIO reference counting
commit 29d62ec5f8 upstream.

Normally _regulator_do_enable() isn't called on an already-enabled
rdev.  That's because the main caller, _regulator_enable() always
calls _regulator_is_enabled() and only calls _regulator_do_enable() if
the rdev was not already enabled.

However, there is one caller of _regulator_do_enable() that doesn't
check: regulator_suspend_finish().  While we might want to make
regulator_suspend_finish() behave more like _regulator_enable(), it's
probably also a good idea to make _regulator_do_enable() robust if it
is called on an already enabled rdev.

At the moment, _regulator_do_enable() is _not_ robust for already
enabled rdevs if we're using an ena_pin.  Each time
_regulator_do_enable() is called for an rdev using an ena_pin the
reference count of the ena_pin is incremented even if the rdev was
already enabled.  This is not as intended because the ena_pin is for
something else: for keeping track of how many active rdevs there are
sharing the same ena_pin.

Here's how the reference counting works here:

* Each time _regulator_enable() is called we increment
  rdev->use_count, so _regulator_enable() calls need to be balanced
  with _regulator_disable() calls.

* There is no explicit reference counting in _regulator_do_enable()
  which is normally just a warapper around rdev->desc->ops->enable()
  with code for supporting delays.  It's not expected that the
  "ops->enable()" call do reference counting.

* Since regulator_ena_gpio_ctrl() does have reference counting
  (handling the sharing of the pin amongst multiple rdevs), we
  shouldn't call it if the current rdev is already enabled.

Note that as part of this we cleanup (remove) the initting of
ena_gpio_state in regulator_register().  In _regulator_do_enable(),
_regulator_do_disable() and _regulator_is_enabled() is is clear that
ena_gpio_state should be the state of whether this particular rdev has
requested the GPIO be enabled.  regulator_register() was initting it
as the actual state of the pin.

Fixes: 967cfb18c0 ("regulator: core: manage enable GPIO list")
Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-26 15:06:56 +01:00
..
88pm800.c regulator: Add REGULATOR_LINEAR_RANGE macro 2013-10-11 12:49:16 +01:00
88pm8607.c regulator: 88pm8607: Convert to devm_regulator_register 2013-09-17 00:27:55 +01:00
Kconfig regulator: Updates for v3.14 2014-01-25 13:19:10 -08:00
Makefile Merge remote-tracking branches 'regulator/topic/db8500', 'regulator/topic/gpio', 'regulator/topic/lp3971', 'regulator/topic/lp3972', 'regulator/topic/max14577', 'regulator/topic/max77693', 'regulator/topic/mc13892', 'regulator/topic/pcf50633' and 'regulator/topic/pfuze100' into regulator-linus 2014-01-23 12:01:27 +00:00
aat2870-regulator.c regulator: aat2870: Convert to devm_regulator_register 2013-09-17 00:27:55 +01:00
ab3100.c regulator: ab3100: cast fix 2014-01-23 19:52:09 +00:00
ab8500-ext.c regulator: ab8500-ext: use devm_regulator_register() 2013-09-30 18:10:52 +01:00
ab8500.c regulator: ab8500: use devm_regulator_register() 2013-12-09 17:38:40 +00:00
act8865-regulator.c regulator: act8865: Fix build error when !OF 2014-01-06 12:12:07 +00:00
ad5398.c regulator: ad5398: Convert to devm_regulator_register 2013-09-17 00:27:55 +01:00
anatop-regulator.c regulator: anatop-regulator: Remove unneeded memset() 2014-01-08 12:50:11 +00:00
arizona-ldo1.c regulator: arizona-ldo1: remove bypass functionality 2014-09-17 09:19:09 -07:00
arizona-micsupp.c Merge remote-tracking branches 'regulator/fix/pfuze100', 'regulator/fix/s5m8767', 'regulator/topic/ab8500', 'regulator/topic/act8865', 'regulator/topic/anatop', 'regulator/topic/arizona' and 'regulator/topic/as3722' into regulator-linus 2014-01-23 12:01:24 +00:00
as3711-regulator.c Merge remote-tracking branch 'regulator/topic/linear' into regulator-next 2013-10-24 11:11:37 +01:00
as3722-regulator.c Merge remote-tracking branches 'regulator/fix/pfuze100', 'regulator/fix/s5m8767', 'regulator/topic/ab8500', 'regulator/topic/act8865', 'regulator/topic/anatop', 'regulator/topic/arizona' and 'regulator/topic/as3722' into regulator-linus 2014-01-23 12:01:24 +00:00
core.c regulator: core: Fix enable GPIO reference counting 2015-03-26 15:06:56 +01:00
da903x.c Merge remote-tracking branch 'regulator/topic/linear' into regulator-next 2013-10-24 11:11:37 +01:00
da9052-regulator.c Merge remote-tracking branch 'regulator/topic/da9052' into regulator-next 2013-10-24 11:11:33 +01:00
da9055-regulator.c regulator: da9055: Remove use of regmap_irq_get_virq() 2014-02-07 16:27:37 +00:00
da9063-regulator.c regulator: da9063: Bug fix when setting max voltage on LDOs 5-11 2014-02-12 15:14:37 +00:00
da9210-regulator.c regulator: da9210: use devm_regulator_register() 2013-09-30 18:11:30 +01:00
da9210-regulator.h regulator: da9210: New driver 2013-08-06 17:46:15 +01:00
db8500-prcmu.c regulator: db8500-prcmu: use devm_regulator_register() 2013-12-09 17:40:57 +00:00
dbx500-prcmu.c regulator: dbx500: Make local symbol static 2013-05-08 13:42:30 +01:00
dbx500-prcmu.h regulator: dbx500-prcmu: Remove operating_point from struct dbx500_regulator_info 2013-04-02 23:05:28 +01:00
devres.c regulator: core: Add ability to create a lookup alias for supply 2013-10-18 00:56:05 +01:00
dummy.c regulator: remove use of __devinit 2012-11-20 10:31:26 +09:00
dummy.h regulator: fix build when CONFIG_REGULATOR_DUMMY=n 2010-10-28 22:40:32 +01:00
fan53555.c regulator: fan53555: Convert to devm_regulator_register 2013-09-17 00:28:40 +01:00
fixed-helper.c regulator: extend the fixed dummy voltage regulator to accept voltage 2012-06-19 23:22:30 +01:00
fixed.c regulator: fixed: Fix checkpatch issue 2013-10-15 13:21:44 +01:00
gpio-regulator.c Merge remote-tracking branches 'regulator/topic/db8500', 'regulator/topic/gpio', 'regulator/topic/lp3971', 'regulator/topic/lp3972', 'regulator/topic/max14577', 'regulator/topic/max77693', 'regulator/topic/mc13892', 'regulator/topic/pcf50633' and 'regulator/topic/pfuze100' into regulator-linus 2014-01-23 12:01:27 +00:00
helpers.c regulator: Remove max_uV from struct regulator_linear_range 2013-10-11 12:49:12 +01:00
internal.h regulator: core: Split devres code out into a separate file 2013-09-17 00:28:45 +01:00
isl6271a-regulator.c regulator: isl6271a-regulator: Use devm_regulator_register 2013-09-17 00:28:42 +01:00
lp872x.c regulator: lp872x: use devm_regulator_register() 2013-09-30 18:10:59 +01:00
lp3971.c regulator: lp3971: Convert to devm_regulator_register 2013-11-13 13:24:44 +00:00
lp3972.c regulator: lp3972: Convert to devm_regulator_register 2013-11-24 14:02:18 +00:00
lp8755.c Merge remote-tracking branch 'regulator/topic/max8660' into regulator-next 2013-09-01 13:50:16 +01:00
lp8788-buck.c regulator: lp8788-buck: use devm_regulator_register() 2013-09-30 18:10:59 +01:00
lp8788-ldo.c regulator: lp8788-ldo: use devm_regulator_register() 2013-09-30 18:10:59 +01:00
max1586.c regulator: max1586: Use devm_regulator_register 2013-09-17 00:28:40 +01:00
max8649.c regulator: max8649: Use devm_regulator_register 2013-09-17 00:28:40 +01:00
max8660.c regulator: max8660: Use devm_regulator_register 2013-09-17 00:28:41 +01:00
max8907-regulator.c regulator: max8907-regulator: Use devm_regulator_register 2013-09-17 00:28:41 +01:00
max8925-regulator.c regulator: max8925: use devm_regulator_register() 2013-09-30 18:10:59 +01:00
max8952.c regulator: use dev_get_platdata() 2013-07-30 12:24:20 +01:00
max8973-regulator.c regulator: max8973-regulator: Use devm_regulator_register 2013-09-17 00:28:41 +01:00
max8997.c Merge remote-tracking branch 'regulator/topic/max8997' into regulator-next 2013-10-24 11:11:38 +01:00
max8998.c regulator: max8998: Use devm_regulator_register 2013-09-17 00:28:41 +01:00
max14577.c regulator: max14577: Fix invalid return value on DT parse success 2014-02-22 11:54:17 +09:00
max77686.c regulator: Remove redundant NULL assignment 2013-09-17 00:28:44 +01:00
max77693.c regulator: max77693: Fix use of uninitialized regulator config 2014-11-14 09:00:13 -08:00
mc13xxx-regulator-core.c regulator: mc13xxx: Add warning of incorrect names of regulators 2013-04-28 02:10:00 +01:00
mc13xxx.h regulator: mc13xxx: Add warning of incorrect names of regulators 2013-04-28 02:10:00 +01:00
mc13783-regulator.c Merge remote-tracking branch 'regulator/topic/mc13783' into regulator-next 2013-10-24 11:11:38 +01:00
mc13892-regulator.c Merge remote-tracking branches 'regulator/topic/db8500', 'regulator/topic/gpio', 'regulator/topic/lp3971', 'regulator/topic/lp3972', 'regulator/topic/max14577', 'regulator/topic/max77693', 'regulator/topic/mc13892', 'regulator/topic/pcf50633' and 'regulator/topic/pfuze100' into regulator-linus 2014-01-23 12:01:27 +00:00
of_regulator.c regulator: core: add support for configuring turn-on time through constraints 2013-09-18 17:13:02 +01:00
palmas-regulator.c Merge remote-tracking branch 'regulator/topic/palmas' into regulator-next 2013-10-24 11:11:39 +01:00
pcap-regulator.c regulator: pcap: use devm_regulator_register() 2013-09-30 18:11:00 +01:00
pcf50633-regulator.c mfd: pcf50633: Correct device name for pcf50633 regulator 2013-12-02 17:58:58 +00:00
pfuze100-regulator.c Merge remote-tracking branches 'regulator/topic/db8500', 'regulator/topic/gpio', 'regulator/topic/lp3971', 'regulator/topic/lp3972', 'regulator/topic/max14577', 'regulator/topic/max77693', 'regulator/topic/mc13892', 'regulator/topic/pcf50633' and 'regulator/topic/pfuze100' into regulator-linus 2014-01-23 12:01:27 +00:00
rc5t583-regulator.c regulator: rc5t583: Use devm_regulator_register 2013-09-17 00:28:42 +01:00
s2mps11.c regulator: s2mps11: Fix NULL pointer of_node value when using platform data 2014-01-31 16:52:03 +00:00
s5m8767.c regulator: s5m8767: Add missing of_node_put 2014-02-13 18:25:40 +00:00
stw481x-vmmc.c regulator: stw481x-vmmc: use devm_regulator_register() 2013-12-09 17:26:29 +00:00
ti-abb-regulator.c Merge remote-tracking branch 'regulator/topic/ti-abb' into regulator-next 2013-10-24 11:11:41 +01:00
tps6105x-regulator.c Merge remote-tracking branch 'regulator/topic/tps6105x' into regulator-next 2013-10-24 11:11:41 +01:00
tps6507x-regulator.c regulator: tps6507x: Use devm_regulator_register 2013-09-17 00:28:43 +01:00
tps6524x-regulator.c regulator: tps6524x: use devm_regulator_register() 2013-09-30 18:11:30 +01:00
tps6586x-regulator.c regulator: tps6586x: Add and use correct voltage table 2014-01-21 08:28:01 +00:00
tps51632-regulator.c regulator: tps51632-regulator: Fix spelling 2013-12-21 14:19:33 +00:00
tps62360-regulator.c regulator: tps62360: Fix up a pointer-integer size mismatch warning 2014-01-06 12:38:11 +00:00
tps65023-regulator.c Merge remote-tracking branch 'regulator/topic/tps65023' into regulator-next 2013-10-24 11:11:42 +01:00
tps65090-regulator.c Merge remote-tracking branch 'regulator/topic/tps65090' into regulator-next 2013-10-24 11:11:42 +01:00
tps65217-regulator.c Merge remote-tracking branch 'regulator/topic/linear' into regulator-next 2013-10-24 11:11:37 +01:00
tps65910-regulator.c regulator: tps65910: Simplify setting enable_mask for regulators 2013-12-30 11:48:43 +00:00
tps65912-regulator.c Merge remote-tracking branch 'regulator/topic/linear' into regulator-next 2013-10-24 11:11:37 +01:00
tps80031-regulator.c regulator: tps80031: Use devm_regulator_register 2013-09-17 00:28:44 +01:00
twl-regulator.c regulator: twl: Fix checkpatch issue 2014-01-08 17:16:07 +00:00
userspace-consumer.c regulator: use dev_get_platdata() 2013-07-30 12:24:20 +01:00
vexpress.c regulator: vexpress: use devm_regulator_register() 2013-09-30 18:11:03 +01:00
virtual.c regulator: use dev_get_platdata() 2013-07-30 12:24:20 +01:00
wm831x-dcdc.c regulator: wm831x-dcdc: Remove unneeded 'err' label 2013-12-31 13:04:37 +00:00
wm831x-isink.c regulator: wm831x-isink: Convert to devm_regulator_register() 2013-09-17 00:27:54 +01:00
wm831x-ldo.c Merge remote-tracking branch 'regulator/topic/linear' into regulator-next 2013-10-24 11:11:37 +01:00
wm8350-regulator.c Merge remote-tracking branch 'regulator/topic/linear' into regulator-next 2013-10-24 11:11:37 +01:00
wm8400-regulator.c Merge remote-tracking branch 'regulator/topic/linear' into regulator-next 2013-10-24 11:11:37 +01:00
wm8994-regulator.c regulator: wm8994: Convert to devm_regulator_register 2013-09-17 00:27:55 +01:00