From 6735f6dcf71e722ee2fc4fb38ed14ae0e2c119b4 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Sat, 3 Mar 2018 00:50:29 +0100 Subject: rtc: isl12026: fixup nvmem registration The probe function must not fail after rtc_register_device. Also, rename the nvmem device so it is easily identifiable in /sys/bus/nvmem. Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-isl12026.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/rtc/rtc-isl12026.c b/drivers/rtc/rtc-isl12026.c index ada9849d8d97..97f594f9667c 100644 --- a/drivers/rtc/rtc-isl12026.c +++ b/drivers/rtc/rtc-isl12026.c @@ -433,7 +433,15 @@ static int isl12026_probe_new(struct i2c_client *client) { struct isl12026 *priv; int ret; - struct nvmem_config nvm_cfg; + struct nvmem_config nvm_cfg = { + .name = "isl12026-", + .base_dev = &client->dev, + .stride = 1, + .word_size = 1, + .size = 512, + .reg_read = isl12026_nvm_read, + .reg_write = isl12026_nvm_write, + }; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) return -ENODEV; @@ -456,24 +464,12 @@ static int isl12026_probe_new(struct i2c_client *client) return ret; priv->rtc->ops = &isl12026_rtc_ops; - priv->rtc->nvram_old_abi = false; - ret = rtc_register_device(priv->rtc); + nvm_cfg.priv = priv; + ret = rtc_nvmem_register(priv->rtc, &nvm_cfg); if (ret) return ret; - memset(&nvm_cfg, 0, sizeof(nvm_cfg)); - nvm_cfg.name = "eeprom"; - nvm_cfg.read_only = false; - nvm_cfg.root_only = true; - nvm_cfg.base_dev = &client->dev; - nvm_cfg.priv = priv; - nvm_cfg.stride = 1; - nvm_cfg.word_size = 1; - nvm_cfg.size = 512; - nvm_cfg.reg_read = isl12026_nvm_read; - nvm_cfg.reg_write = isl12026_nvm_write; - - return rtc_nvmem_register(priv->rtc, &nvm_cfg); + return rtc_register_device(priv->rtc); } static int isl12026_remove(struct i2c_client *client) -- cgit v1.2.3