Commit 6dba0c39 authored by Nuno Sa's avatar Nuno Sa Committed by Jonathan Cameron

iio: common: scmi_iio: convert to dev_err_probe()

Make use of dev_err_probe() and dev_err_ptr_probe() to simplify error paths
during probe.
Signed-off-by: default avatarNuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240606-dev-add_dev_errp_probe-v3-4-51bb229edd79@analog.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent ac518929
...@@ -626,12 +626,10 @@ scmi_alloc_iiodev(struct scmi_device *sdev, ...@@ -626,12 +626,10 @@ scmi_alloc_iiodev(struct scmi_device *sdev,
SCMI_PROTOCOL_SENSOR, SCMI_EVENT_SENSOR_UPDATE, SCMI_PROTOCOL_SENSOR, SCMI_EVENT_SENSOR_UPDATE,
&sensor->sensor_info->id, &sensor->sensor_info->id,
&sensor->sensor_update_nb); &sensor->sensor_update_nb);
if (ret) { if (ret)
dev_err(&iiodev->dev, return dev_err_ptr_probe(&iiodev->dev, ret,
"Error in registering sensor update notifier for sensor %s err %d", "Error in registering sensor update notifier for sensor %s\n",
sensor->sensor_info->name, ret); sensor->sensor_info->name);
return ERR_PTR(ret);
}
scmi_iio_set_timestamp_channel(&iio_channels[i], i); scmi_iio_set_timestamp_channel(&iio_channels[i], i);
iiodev->channels = iio_channels; iiodev->channels = iio_channels;
...@@ -653,10 +651,9 @@ static int scmi_iio_dev_probe(struct scmi_device *sdev) ...@@ -653,10 +651,9 @@ static int scmi_iio_dev_probe(struct scmi_device *sdev)
return -ENODEV; return -ENODEV;
sensor_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_SENSOR, &ph); sensor_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_SENSOR, &ph);
if (IS_ERR(sensor_ops)) { if (IS_ERR(sensor_ops))
dev_err(dev, "SCMI device has no sensor interface\n"); return dev_err_probe(dev, PTR_ERR(sensor_ops),
return PTR_ERR(sensor_ops); "SCMI device has no sensor interface\n");
}
nr_sensors = sensor_ops->count_get(ph); nr_sensors = sensor_ops->count_get(ph);
if (!nr_sensors) { if (!nr_sensors) {
...@@ -667,8 +664,8 @@ static int scmi_iio_dev_probe(struct scmi_device *sdev) ...@@ -667,8 +664,8 @@ static int scmi_iio_dev_probe(struct scmi_device *sdev)
for (i = 0; i < nr_sensors; i++) { for (i = 0; i < nr_sensors; i++) {
sensor_info = sensor_ops->info_get(ph, i); sensor_info = sensor_ops->info_get(ph, i);
if (!sensor_info) { if (!sensor_info) {
dev_err(dev, "SCMI sensor %d has missing info\n", i); return dev_err_probe(dev, -EINVAL,
return -EINVAL; "SCMI sensor %d has missing info\n", i);
} }
/* This driver only supports 3-axis accel and gyro, skipping other sensors */ /* This driver only supports 3-axis accel and gyro, skipping other sensors */
...@@ -683,29 +680,25 @@ static int scmi_iio_dev_probe(struct scmi_device *sdev) ...@@ -683,29 +680,25 @@ static int scmi_iio_dev_probe(struct scmi_device *sdev)
scmi_iio_dev = scmi_alloc_iiodev(sdev, sensor_ops, ph, scmi_iio_dev = scmi_alloc_iiodev(sdev, sensor_ops, ph,
sensor_info); sensor_info);
if (IS_ERR(scmi_iio_dev)) { if (IS_ERR(scmi_iio_dev)) {
dev_err(dev, return dev_err_probe(dev, PTR_ERR(scmi_iio_dev),
"failed to allocate IIO device for sensor %s: %ld\n", "failed to allocate IIO device for sensor %s\n",
sensor_info->name, PTR_ERR(scmi_iio_dev)); sensor_info->name);
return PTR_ERR(scmi_iio_dev);
} }
err = devm_iio_kfifo_buffer_setup(&scmi_iio_dev->dev, err = devm_iio_kfifo_buffer_setup(&scmi_iio_dev->dev,
scmi_iio_dev, scmi_iio_dev,
&scmi_iio_buffer_ops); &scmi_iio_buffer_ops);
if (err < 0) { if (err < 0) {
dev_err(dev, return dev_err_probe(dev, err,
"IIO buffer setup error at sensor %s: %d\n", "IIO buffer setup error at sensor %s\n",
sensor_info->name, err); sensor_info->name);
return err;
} }
err = devm_iio_device_register(dev, scmi_iio_dev); err = devm_iio_device_register(dev, scmi_iio_dev);
if (err) { if (err)
dev_err(dev, return dev_err_probe(dev, err,
"IIO device registration failed at sensor %s: %d\n", "IIO device registration failed at sensor %s\n",
sensor_info->name, err); sensor_info->name);
return err;
}
} }
return err; return err;
} }
......
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