summaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2022-12-07 21:03:43 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2022-12-28 17:19:45 +0000
commit2080c8d34602a6ad86286a04e5b8b40f40505215 (patch)
tree3cf2025fc2f6b824a840f6b63586606a07144eed /drivers/iio
parentbbabf9199126d7eb950ccc369543c462cc58e1b7 (diff)
downloadlinux-stable-2080c8d34602a6ad86286a04e5b8b40f40505215.tar.gz
linux-stable-2080c8d34602a6ad86286a04e5b8b40f40505215.tar.bz2
linux-stable-2080c8d34602a6ad86286a04e5b8b40f40505215.zip
iio: light: tsl2563: Simplify with dev_err_probe
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> Link: https://lore.kernel.org/r/20221207190348.9347-6-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/light/tsl2563.c29
1 files 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;
}