public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Ferry Toth <ftoth@exalondelft.nl>
Subject: [PATCH v1 06/11] iio: light: tsl2563: Simplify with dev_err_probe
Date: Wed,  7 Dec 2022 21:03:43 +0200	[thread overview]
Message-ID: <20221207190348.9347-6-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20221207190348.9347-1-andriy.shevchenko@linux.intel.com>

Code can be a bit simpler with dev_err_probe().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Ferry Toth <ftoth@exalondelft.nl>
---
 drivers/iio/light/tsl2563.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c
index bdd40a5df53d..cce044556293 100644
--- a/drivers/iio/light/tsl2563.c
+++ b/drivers/iio/light/tsl2563.c
@@ -695,12 +695,13 @@ static const struct iio_info tsl2563_info = {
 
 static int tsl2563_probe(struct i2c_client *client)
 {
+	struct device *dev = &client->dev;
 	struct iio_dev *indio_dev;
 	struct tsl2563_chip *chip;
 	struct tsl2563_platform_data *pdata = client->dev.platform_data;
 	unsigned long irq_flags;
-	int err = 0;
 	u8 id = 0;
+	int err;
 
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
 	if (!indio_dev)
@@ -712,16 +713,12 @@ static int tsl2563_probe(struct i2c_client *client)
 	chip->client = client;
 
 	err = tsl2563_detect(chip);
-	if (err) {
-		dev_err(&client->dev, "detect error %d\n", -err);
-		return err;
-	}
+	if (err)
+		return dev_err_probe(dev, err, "detect error\n");
 
 	err = tsl2563_read_id(chip, &id);
-	if (err) {
-		dev_err(&client->dev, "read id error %d\n", -err);
-		return err;
-	}
+	if (err)
+		return dev_err_probe(dev, err, "read id error\n");
 
 	mutex_init(&chip->lock);
 
@@ -765,17 +762,13 @@ static int tsl2563_probe(struct i2c_client *client)
 					   irq_flags,
 					   "tsl2563_event",
 					   indio_dev);
-		if (err) {
-			dev_err(&client->dev, "irq request error %d\n", -err);
-			return err;
-		}
+		if (err)
+			return dev_err_probe(dev, err, "irq request error\n");
 	}
 
 	err = tsl2563_configure(chip);
-	if (err) {
-		dev_err(&client->dev, "configure error %d\n", -err);
-		return err;
-	}
+	if (err)
+		return dev_err_probe(dev, err, "configure error\n");
 
 	INIT_DELAYED_WORK(&chip->poweroff_work, tsl2563_poweroff_work);
 
@@ -784,7 +777,7 @@ static int tsl2563_probe(struct i2c_client *client)
 
 	err = iio_device_register(indio_dev);
 	if (err) {
-		dev_err(&client->dev, "iio registration error %d\n", -err);
+		dev_err_probe(dev, err, "iio registration error\n");
 		goto fail;
 	}
 
-- 
2.35.1


  parent reply	other threads:[~2022-12-07 19:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 19:03 [PATCH v1 01/11] iio: light: tsl2563: Do not hardcode interrupt trigger type Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 02/11] iio: light: tsl2563: Use i2c_smbus_write_word_data() in tsl2563_configure() Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 03/11] iio: light: tsl2563: Configure INT in one place Andy Shevchenko
2022-12-11 13:17   ` Jonathan Cameron
2022-12-07 19:03 ` [PATCH v1 04/11] iio: light: tsl2563: Make use of the macros from bits.h Andy Shevchenko
2022-12-11 13:19   ` Jonathan Cameron
2022-12-07 19:03 ` [PATCH v1 05/11] iio: light: tsl2563: Drop unused defintion(s) Andy Shevchenko
2022-12-07 19:03 ` Andy Shevchenko [this message]
2022-12-07 19:03 ` [PATCH v1 07/11] iio: light: tsl2563: Drop legacy platform data code Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 08/11] iio: light: tsl2563: Utilise temporary variable for struct device Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 09/11] iio: light: tsl2563: Use dev_get_drvdata() directly in PM callbacks Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 10/11] iio: light: tsl2563: sort header inclusion alphabetically Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 11/11] iio: light: tsl2563: Keep Makefile sorted by module name Andy Shevchenko
2022-12-11 13:26 ` [PATCH v1 01/11] iio: light: tsl2563: Do not hardcode interrupt trigger type Jonathan Cameron
2022-12-11 17:14   ` Ferry Toth
2022-12-12 10:59     ` Jonathan Cameron

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=20221207190348.9347-6-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=ftoth@exalondelft.nl \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox