Commit 267a29b9 authored by Lee Jones's avatar Lee Jones Committed by Jonathan Cameron

iio: magn-core: st: Clean up error handling in probe()

Reduce the amount of those unnecessary goto calls, as in most cases
we can simply return immediately. We also only call for the IRQ number
once and use that value throughout.
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent f01a140a
...@@ -348,8 +348,9 @@ static const struct iio_info magn_info = { ...@@ -348,8 +348,9 @@ static const struct iio_info magn_info = {
int st_magn_common_probe(struct iio_dev *indio_dev, int st_magn_common_probe(struct iio_dev *indio_dev,
struct st_sensors_platform_data *pdata) struct st_sensors_platform_data *pdata)
{ {
int err;
struct st_sensor_data *mdata = iio_priv(indio_dev); struct st_sensor_data *mdata = iio_priv(indio_dev);
int irq = mdata->get_irq_data_ready(indio_dev);
int err;
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &magn_info; indio_dev->info = &magn_info;
...@@ -357,7 +358,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev, ...@@ -357,7 +358,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev,
err = st_sensors_check_device_support(indio_dev, err = st_sensors_check_device_support(indio_dev,
ARRAY_SIZE(st_magn_sensors), st_magn_sensors); ARRAY_SIZE(st_magn_sensors), st_magn_sensors);
if (err < 0) if (err < 0)
goto st_magn_common_probe_error; return err;
mdata->num_data_channels = ST_MAGN_NUMBER_DATA_CHANNELS; mdata->num_data_channels = ST_MAGN_NUMBER_DATA_CHANNELS;
mdata->multiread_bit = mdata->sensor->multi_read_bit; mdata->multiread_bit = mdata->sensor->multi_read_bit;
...@@ -370,12 +371,12 @@ int st_magn_common_probe(struct iio_dev *indio_dev, ...@@ -370,12 +371,12 @@ int st_magn_common_probe(struct iio_dev *indio_dev,
err = st_sensors_init_sensor(indio_dev, pdata); err = st_sensors_init_sensor(indio_dev, pdata);
if (err < 0) if (err < 0)
goto st_magn_common_probe_error; return err;
if (mdata->get_irq_data_ready(indio_dev) > 0) { if (irq > 0) {
err = st_magn_allocate_ring(indio_dev); err = st_magn_allocate_ring(indio_dev);
if (err < 0) if (err < 0)
goto st_magn_common_probe_error; return err;
err = st_sensors_allocate_trigger(indio_dev, NULL); err = st_sensors_allocate_trigger(indio_dev, NULL);
if (err < 0) if (err < 0)
goto st_magn_probe_trigger_error; goto st_magn_probe_trigger_error;
...@@ -385,15 +386,15 @@ int st_magn_common_probe(struct iio_dev *indio_dev, ...@@ -385,15 +386,15 @@ int st_magn_common_probe(struct iio_dev *indio_dev,
if (err) if (err)
goto st_magn_device_register_error; goto st_magn_device_register_error;
return err; return 0;
st_magn_device_register_error: st_magn_device_register_error:
if (mdata->get_irq_data_ready(indio_dev) > 0) if (irq > 0)
st_sensors_deallocate_trigger(indio_dev); st_sensors_deallocate_trigger(indio_dev);
st_magn_probe_trigger_error: st_magn_probe_trigger_error:
if (mdata->get_irq_data_ready(indio_dev) > 0) if (irq > 0)
st_magn_deallocate_ring(indio_dev); st_magn_deallocate_ring(indio_dev);
st_magn_common_probe_error:
return err; return err;
} }
EXPORT_SYMBOL(st_magn_common_probe); EXPORT_SYMBOL(st_magn_common_probe);
......
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