Skip to content

Commit 58d6fee

Browse files
auchterbrgl
authored andcommitted
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: cd5676d ("misc: eeprom: at24: support pm_runtime control") Signed-off-by: Michael Auchter <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 2c523b3 commit 58d6fee

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/misc/eeprom/at24.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,13 +712,14 @@ static int at24_probe(struct i2c_client *client)
712712
* chip is functional.
713713
*/
714714
err = at24_read(at24, 0, &test_byte, 1);
715-
pm_runtime_idle(dev);
716715
if (err) {
717716
pm_runtime_disable(dev);
718717
regulator_disable(at24->vcc_reg);
719718
return -ENODEV;
720719
}
721720

721+
pm_runtime_idle(dev);
722+
722723
if (writable)
723724
dev_info(dev, "%u byte %s EEPROM, writable, %u bytes/write\n",
724725
byte_len, client->name, at24->write_max);

0 commit comments

Comments
 (0)