From: Bartosz Golaszewski <brgl@bgdev.pl>
To: linux-i2c@vger.kernel.org
Cc: Wolfram Sang <wsa@the-dreams.de>,
linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: [PATCH 2/2] eeprom: at24: drop unnecessary label
Date: Sun, 19 May 2019 22:40:12 +0200 [thread overview]
Message-ID: <20190519204012.31861-3-brgl@bgdev.pl> (raw)
In-Reply-To: <20190519204012.31861-1-brgl@bgdev.pl>
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
If we move the nvmem registration above the pm enable calls and the
test read, we can drop the error label and make the code more readable
as there's now only a single place where we must call
pm_runtime_disable() in error path.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/misc/eeprom/at24.c | 43 ++++++++++++++++----------------------
1 file changed, 18 insertions(+), 25 deletions(-)
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 9ea196f0749f..0bc0a45fb98e 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -689,23 +689,6 @@ static int at24_probe(struct i2c_client *client)
return err;
}
- i2c_set_clientdata(client, at24);
-
- /* enable runtime pm */
- pm_runtime_set_active(dev);
- pm_runtime_enable(dev);
-
- /*
- * Perform a one-byte test read to verify that the
- * chip is functional.
- */
- err = at24_read(at24, 0, &test_byte, 1);
- pm_runtime_idle(dev);
- if (err) {
- err = -ENODEV;
- goto err_runtime_pm;
- }
-
nvmem_config.name = dev_name(dev);
nvmem_config.dev = dev;
nvmem_config.read_only = !writable;
@@ -721,9 +704,24 @@ static int at24_probe(struct i2c_client *client)
nvmem_config.size = byte_len;
at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
- if (IS_ERR(at24->nvmem)) {
- err = PTR_ERR(at24->nvmem);
- goto err_runtime_pm;
+ if (IS_ERR(at24->nvmem))
+ return PTR_ERR(at24->nvmem);
+
+ i2c_set_clientdata(client, at24);
+
+ /* enable runtime pm */
+ pm_runtime_set_active(dev);
+ pm_runtime_enable(dev);
+
+ /*
+ * Perform a one-byte test read to verify that the
+ * chip is functional.
+ */
+ err = at24_read(at24, 0, &test_byte, 1);
+ pm_runtime_idle(dev);
+ if (err) {
+ pm_runtime_disable(dev);
+ return -ENODEV;
}
dev_info(dev, "%u byte %s EEPROM, %s, %u bytes/write\n",
@@ -731,11 +729,6 @@ static int at24_probe(struct i2c_client *client)
writable ? "writable" : "read-only", at24->write_max);
return 0;
-
-err_runtime_pm:
- pm_runtime_disable(dev);
-
- return err;
}
static int at24_remove(struct i2c_client *client)
--
2.21.0
prev parent reply other threads:[~2019-05-19 20:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-19 20:40 [PATCH 0/2] at24: use devm_i2c_new_dummy_device() Bartosz Golaszewski
2019-05-19 20:40 ` [PATCH 1/2] eeprom: " Bartosz Golaszewski
2019-05-19 20:52 ` Wolfram Sang
2019-05-20 6:14 ` Bartosz Golaszewski
2019-05-19 20:40 ` Bartosz Golaszewski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190519204012.31861-3-brgl@bgdev.pl \
--to=brgl@bgdev.pl \
--cc=bgolaszewski@baylibre.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.