Commit c44e031b authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Jonathan Cameron

iio: chemical: scd30_core: Switch to use dev_err_probe()

Switch to use dev_err_probe() to simplify the error paths and
unify message template.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230113141917.23725-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent ebda75fb
...@@ -642,10 +642,8 @@ static int scd30_setup_trigger(struct iio_dev *indio_dev) ...@@ -642,10 +642,8 @@ static int scd30_setup_trigger(struct iio_dev *indio_dev)
trig = devm_iio_trigger_alloc(dev, "%s-dev%d", indio_dev->name, trig = devm_iio_trigger_alloc(dev, "%s-dev%d", indio_dev->name,
iio_device_id(indio_dev)); iio_device_id(indio_dev));
if (!trig) { if (!trig)
dev_err(dev, "failed to allocate trigger\n"); return dev_err_probe(dev, -ENOMEM, "failed to allocate trigger\n");
return -ENOMEM;
}
trig->ops = &scd30_trigger_ops; trig->ops = &scd30_trigger_ops;
iio_trigger_set_drvdata(trig, indio_dev); iio_trigger_set_drvdata(trig, indio_dev);
...@@ -667,9 +665,9 @@ static int scd30_setup_trigger(struct iio_dev *indio_dev) ...@@ -667,9 +665,9 @@ static int scd30_setup_trigger(struct iio_dev *indio_dev)
IRQF_NO_AUTOEN, IRQF_NO_AUTOEN,
indio_dev->name, indio_dev); indio_dev->name, indio_dev);
if (ret) if (ret)
dev_err(dev, "failed to request irq\n"); return dev_err_probe(dev, ret, "failed to request irq\n");
return ret; return 0;
} }
int scd30_probe(struct device *dev, int irq, const char *name, void *priv, int scd30_probe(struct device *dev, int irq, const char *name, void *priv,
...@@ -717,17 +715,13 @@ int scd30_probe(struct device *dev, int irq, const char *name, void *priv, ...@@ -717,17 +715,13 @@ int scd30_probe(struct device *dev, int irq, const char *name, void *priv,
return ret; return ret;
ret = scd30_reset(state); ret = scd30_reset(state);
if (ret) { if (ret)
dev_err(dev, "failed to reset device: %d\n", ret); return dev_err_probe(dev, ret, "failed to reset device\n");
return ret;
}
if (state->irq > 0) { if (state->irq > 0) {
ret = scd30_setup_trigger(indio_dev); ret = scd30_setup_trigger(indio_dev);
if (ret) { if (ret)
dev_err(dev, "failed to setup trigger: %d\n", ret); return dev_err_probe(dev, ret, "failed to setup trigger\n");
return ret;
}
} }
ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, scd30_trigger_handler, NULL); ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, scd30_trigger_handler, NULL);
...@@ -735,23 +729,17 @@ int scd30_probe(struct device *dev, int irq, const char *name, void *priv, ...@@ -735,23 +729,17 @@ int scd30_probe(struct device *dev, int irq, const char *name, void *priv,
return ret; return ret;
ret = scd30_command_read(state, CMD_FW_VERSION, &val); ret = scd30_command_read(state, CMD_FW_VERSION, &val);
if (ret) { if (ret)
dev_err(dev, "failed to read firmware version: %d\n", ret); return dev_err_probe(dev, ret, "failed to read firmware version\n");
return ret;
}
dev_info(dev, "firmware version: %d.%d\n", val >> 8, (char)val); dev_info(dev, "firmware version: %d.%d\n", val >> 8, (char)val);
ret = scd30_command_write(state, CMD_MEAS_INTERVAL, state->meas_interval); ret = scd30_command_write(state, CMD_MEAS_INTERVAL, state->meas_interval);
if (ret) { if (ret)
dev_err(dev, "failed to set measurement interval: %d\n", ret); return dev_err_probe(dev, ret, "failed to set measurement interval\n");
return ret;
}
ret = scd30_command_write(state, CMD_START_MEAS, state->pressure_comp); ret = scd30_command_write(state, CMD_START_MEAS, state->pressure_comp);
if (ret) { if (ret)
dev_err(dev, "failed to start measurement: %d\n", ret); return dev_err_probe(dev, ret, "failed to start measurement\n");
return ret;
}
ret = devm_add_action_or_reset(dev, scd30_stop_meas, state); ret = devm_add_action_or_reset(dev, scd30_stop_meas, state);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment