]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
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)
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

index 031eb64549af51018eefda562f43a67a0d07e85d..282c9ef68ed22dfe73c58f11916fff9c44582228 100644 (file)
@@ -712,13 +712,14 @@ static int at24_probe(struct i2c_client *client)
         * chip is functional.
         */
        err = at24_read(at24, 0, &test_byte, 1);
-       pm_runtime_idle(dev);
        if (err) {
                pm_runtime_disable(dev);
                regulator_disable(at24->vcc_reg);
                return -ENODEV;
        }
 
+       pm_runtime_idle(dev);
+
        if (writable)
                dev_info(dev, "%u byte %s EEPROM, writable, %u bytes/write\n",
                         byte_len, client->name, at24->write_max);