misc: eeprom: at24: fix regulator underflow
authorMichael Auchter <michael.auchter@ni.com>
Tue, 10 Mar 2020 20:58:40 +0000 (15:58 -0500)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Thu, 12 Mar 2020 08:02:34 +0000 (09:02 +0100)
commit58d6fee50e67bb1c69977f1a534ccb17bf58b0f1
treee0585b9a02d5e3a99208e7c0ff8ef399e111bcd6
parent2c523b344dfa65a3738e7039832044aa133c75fb
misc: eeprom: at24: fix regulator underflow

The at24 driver attempts to read a byte from the device to validate that
it's actually present, and if not, disables the vcc regulator and
returns -ENODEV. However, between the read and the error handling path,
pm_runtime_idle() is called and invokes the driver's suspend callback,
which also disables the vcc regulator. This leads to an underflow of the
regulator enable count if the EEPROM is not present.

Move the pm_runtime_suspend() call to be after the error handling path
to resolve this.

Fixes: cd5676db0574 ("misc: eeprom: at24: support pm_runtime control")
Signed-off-by: Michael Auchter <michael.auchter@ni.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
drivers/misc/eeprom/at24.c