summaryrefslogtreecommitdiff
path: root/drivers/misc
diff options
context:
space:
mode:
authorVadym Kochan <vadym.kochan@plvision.eu>2020-08-31 04:55:39 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-09-17 14:55:41 +0300
commit87f0ffddae01d9587f58cfa70830c6470be8b7b0 (patch)
tree93d411d4be344f93e36e48d2aab970f3a32b21e0 /drivers/misc
parent94abb06dc753434c0e1d230a269de05f441fc217 (diff)
downloadlinux-87f0ffddae01d9587f58cfa70830c6470be8b7b0.tar.xz
misc: eeprom: at24: register nvmem only after eeprom is ready to use
commit 45df80d7605c25055a85fbc5a8446c81c6c0ca24 upstream. 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: cd5676db0574 ("misc: eeprom: at24: support pm_runtime control") Fixes: b20eb4c1f026 ("eeprom: at24: drop unnecessary label") Cc: stable@vger.kernel.org Signed-off-by: Vadym Kochan <vadym.kochan@plvision.eu> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/eeprom/at24.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 9ff18d4961ce..5561075f7a1b 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -692,10 +692,6 @@ static int at24_probe(struct i2c_client *client)
nvmem_config.word_size = 1;
nvmem_config.size = byte_len;
- at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
- if (IS_ERR(at24->nvmem))
- return PTR_ERR(at24->nvmem);
-
i2c_set_clientdata(client, at24);
err = regulator_enable(at24->vcc_reg);
@@ -708,6 +704,13 @@ static int at24_probe(struct i2c_client *client)
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
+ at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
+ if (IS_ERR(at24->nvmem)) {
+ pm_runtime_disable(dev);
+ regulator_disable(at24->vcc_reg);
+ return PTR_ERR(at24->nvmem);
+ }
+
/*
* Perform a one-byte test read to verify that the
* chip is functional.