misc: eeprom: at24: Make VCC supply description requirement optional
Subsystems (2)
PATCH 1/1 misc: eeprom: at24: Make VCC supply description requirement optional
Some platforms (e.g. IBM Power System S822LC (8335-GCA POWER8)) do not describe the EEPROM’s VCC supply in firmware-provided device trees. Using devm_regulator_get() on such systems falls back to a dummy regulator with a kernel warning:
at24 0-0051: supply vcc not found, using dummy regulator
at24 0-0051: 16384 byte 24c128 EEPROM, writable, 1 bytes/write
at24 0-0052: supply vcc not found, using dummy regulator
at24 0-0052: 256 byte 24c02 EEPROM, writable, 1 bytes/write
at24 0-0053: supply vcc not found, using dummy regulator
at24 0-0053: 256 byte 24c02 EEPROM, writable, 1 bytes/write
at24 0-0054: supply vcc not found, using dummy regulator
at24 0-0054: 256 byte 24c02 EEPROM, writable, 1 bytes/write
[…]
at24 12-0050: supply vcc not found, using dummy regulator
at24 12-0050: 16384 byte 24c128 EEPROM, writable, 1 bytes/write
at24 12-0051: supply vcc not found, using dummy regulator
at24 12-0051: 16384 byte 24c128 EEPROM, writable, 1 bytes/writeSwitch to devm_regulator_get_optional() and treat -ENODEV as “no supply described”. When vcc_reg is NULL, skip all regulator_enable/disable calls; the hardware is assumed to be always powered. Linux now logs:
at24 0-0051: 16384 byte 24c128 EEPROM, writable, 1 bytes/write
at24 0-0052: 256 byte 24c02 EEPROM, writable, 1 bytes/write
at24 0-0053: 256 byte 24c02 EEPROM, writable, 1 bytes/write
at24 0-0054: 256 byte 24c02 EEPROM, writable, 1 bytes/write
at24 0-0055: 256 byte 24c02 EEPROM, writable, 1 bytes/write
[…]
at24 12-0050: 16384 byte 24c128 EEPROM, writable, 1 bytes/write
at24 12-0051: 16384 byte 24c128 EEPROM, writable, 1 bytes/write--- drivers/misc/eeprom/at24.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/misc/eeprom/at24.c +18 -8
@@ -699,9 +699,12 @@ static int at24_probe(struct i2c_client *client) at24->offset_adj =at24_get_offset_adj (flags, byte_len); at24->client_regmaps[0 ] = regmap; - at24->vcc_reg =devm_regulator_get (dev,"vcc" ); -if (IS_ERR (at24->vcc_reg)) -return PTR_ERR (at24->vcc_reg); + at24->vcc_reg =devm_regulator_get_optional (dev,"vcc" ); +if (IS_ERR (at24->vcc_reg)) { +if (PTR_ERR (at24->vcc_reg) != -ENODEV ) +return PTR_ERR (at24->vcc_reg); + at24->vcc_reg =NULL ; + } writable = !(flags &AT24_FLAG_READONLY );if (writable) {
@@ -754,9 +757,12 @@ static int at24_probe(struct i2c_client *client) full_power =acpi_dev_state_d0 (&client->dev);if (full_power) { - err =regulator_enable (at24->vcc_reg); -if (err) -return dev_err_probe (dev, err,"Failed to enable vcc regulator\n" ); +if (at24->vcc_reg) { + err =regulator_enable (at24->vcc_reg); +if (err) { +return dev_err_probe (dev, err,"Failed to enable vcc regulator\n" ); + } + }pm_runtime_set_active (dev); }
@@ -771,7 +777,7 @@ static int at24_probe(struct i2c_client *client) err =at24_read (at24,0 , &test_byte,1 );if (err) {pm_runtime_disable (dev); -if (!pm_runtime_status_suspended (dev)) +if (!pm_runtime_status_suspended (dev) && at24->vcc_reg)regulator_disable (at24->vcc_reg);return -ENODEV ; }
@@ -808,7 +814,7 @@ static void at24_remove(struct i2c_client *client)pm_runtime_disable (&client->dev);if (acpi_dev_state_d0 (&client->dev)) { -if (!pm_runtime_status_suspended (&client->dev)) +if (!pm_runtime_status_suspended (&client->dev) && at24->vcc_reg)regulator_disable (at24->vcc_reg);pm_runtime_set_suspended (&client->dev); }
@@ -819,6 +825,8 @@ static int __maybe_unused at24_suspend(struct device *dev)struct i2c_client *client =to_i2c_client (dev);struct at24_data *at24 =i2c_get_clientdata (client); +if (!at24->vcc_reg) +return 0 ;return regulator_disable (at24->vcc_reg); }
@@ -827,6 +835,8 @@ static int __maybe_unused at24_resume(struct device *dev)struct i2c_client *client =to_i2c_client (dev);struct at24_data *at24 =i2c_get_clientdata (client); +if (!at24->vcc_reg) +return 0 ;return regulator_enable (at24->vcc_reg); }
Signature · 1 line
2.53.0
Quoted 9 lines · Paul Menzel
Some platforms (e.g. IBM Power System S822LC (8335-GCA POWER8)) do not describe the EEPROM’s VCC supply in firmware-provided device trees. Using
devm_regulator_get()on such systems falls back to a dummy regulator with a kernel warning:Switch to
devm_regulator_get_optional()and treat-ENODEVas “no supply described”. Whenvcc_regis NULL, skip all regulator_enable/disable calls; the hardware is assumed to be always powered. Linux now logs:
This is not appropriate unless the device can actually operate without power, any driver could be used in a system where the firmware does not describe the regultors and it'd obviously be pointless and error prone to scatter bodges like this on every single call to a regulator API function.
Dear Mark,
Thank you for taking the time to review and respond.
Am 25.05.26 um 00:07 schrieb Mark Brown:
Quoted 12 lines · Paul Menzel
Quoted 10 lines
Some platforms (e.g. IBM Power System S822LC (8335-GCA POWER8)) do not describe the EEPROM’s VCC supply in firmware-provided device trees. Using
devm_regulator_get()on such systems falls back to a dummy regulator with a kernel warning:Switch to
devm_regulator_get_optional()and treat-ENODEVas “no supply described”. Whenvcc_regis NULL, skip all regulator_enable/disable calls; the hardware is assumed to be always powered. Linux now logs:
Quoted 5 lines
This is not appropriate unless the device can actually operate without power, any driver could be used in a system where the firmware does not describe the regultors and it'd obviously be pointless and error prone to scatter bodges like this on every single call to a regulator API function.
How should the warning on the POWER server be addressed then?
Kind regards,
Paul
Quoted 9 lines · Paul Menzel
Am 25.05.26 um 00:07 schrieb Mark Brown:
Quoted 5 lines
This is not appropriate unless the device can actually operate without power, any driver could be used in a system where the firmware does not describe the regultors and it'd obviously be pointless and error prone to scatter bodges like this on every single call to a regulator API function.
How should the warning on the POWER server be addressed then?
They should fix their DT, or you should arrange some way of identifying that for some reason their DT is like this and dummy regulators are the expected case.