Skip to content

Commit 45df80d

Browse files
vkochan-plvbrgl
authored andcommitted
misc: eeprom: at24: register nvmem only after eeprom is ready to use
During nvmem_register() the nvmem core sends notifications when: - cell added - nvmem added and during these notifications some callback func may access the nvmem device, which will fail in case of at24 eeprom because regulator and pm are enabled after nvmem_register(). Fixes: cd5676d ("misc: eeprom: at24: support pm_runtime control") Fixes: b20eb4c ("eeprom: at24: drop unnecessary label") Cc: [email protected] Signed-off-by: Vadym Kochan <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 9123e3a commit 45df80d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/misc/eeprom/at24.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,6 @@ static int at24_probe(struct i2c_client *client)
692692
nvmem_config.word_size = 1;
693693
nvmem_config.size = byte_len;
694694

695-
at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
696-
if (IS_ERR(at24->nvmem))
697-
return PTR_ERR(at24->nvmem);
698-
699695
i2c_set_clientdata(client, at24);
700696

701697
err = regulator_enable(at24->vcc_reg);
@@ -708,6 +704,13 @@ static int at24_probe(struct i2c_client *client)
708704
pm_runtime_set_active(dev);
709705
pm_runtime_enable(dev);
710706

707+
at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
708+
if (IS_ERR(at24->nvmem)) {
709+
pm_runtime_disable(dev);
710+
regulator_disable(at24->vcc_reg);
711+
return PTR_ERR(at24->nvmem);
712+
}
713+
711714
/*
712715
* Perform a one-byte test read to verify that the
713716
* chip is functional.

0 commit comments

Comments
 (0)