diff options
author | Lee Jones <lee.jones@linaro.org> | 2013-09-16 12:02:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-09-21 14:24:06 -0400 |
commit | f01a140ad30cb99eb3a15a6c43fde80207ce2681 (patch) | |
tree | 5ffd7b536197282c4e4780011938f8b2ab2f1423 /drivers/iio/gyro | |
parent | cf4dd430c4cfeb2b41e2de43f3463d0a3dba2463 (diff) |
iio: gyro-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: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/gyro')
-rw-r--r-- | drivers/iio/gyro/st_gyro_core.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index e13c2b0bf3d1..9f80817182cf 100644 --- a/drivers/iio/gyro/st_gyro_core.c +++ b/drivers/iio/gyro/st_gyro_core.c | |||
@@ -305,8 +305,9 @@ static const struct iio_trigger_ops st_gyro_trigger_ops = { | |||
305 | int st_gyro_common_probe(struct iio_dev *indio_dev, | 305 | int st_gyro_common_probe(struct iio_dev *indio_dev, |
306 | struct st_sensors_platform_data *pdata) | 306 | struct st_sensors_platform_data *pdata) |
307 | { | 307 | { |
308 | int err; | ||
309 | struct st_sensor_data *gdata = iio_priv(indio_dev); | 308 | struct st_sensor_data *gdata = iio_priv(indio_dev); |
309 | int irq = gdata->get_irq_data_ready(indio_dev); | ||
310 | int err; | ||
310 | 311 | ||
311 | indio_dev->modes = INDIO_DIRECT_MODE; | 312 | indio_dev->modes = INDIO_DIRECT_MODE; |
312 | indio_dev->info = &gyro_info; | 313 | indio_dev->info = &gyro_info; |
@@ -314,7 +315,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev, | |||
314 | err = st_sensors_check_device_support(indio_dev, | 315 | err = st_sensors_check_device_support(indio_dev, |
315 | ARRAY_SIZE(st_gyro_sensors), st_gyro_sensors); | 316 | ARRAY_SIZE(st_gyro_sensors), st_gyro_sensors); |
316 | if (err < 0) | 317 | if (err < 0) |
317 | goto st_gyro_common_probe_error; | 318 | return err; |
318 | 319 | ||
319 | gdata->num_data_channels = ST_GYRO_NUMBER_DATA_CHANNELS; | 320 | gdata->num_data_channels = ST_GYRO_NUMBER_DATA_CHANNELS; |
320 | gdata->multiread_bit = gdata->sensor->multi_read_bit; | 321 | gdata->multiread_bit = gdata->sensor->multi_read_bit; |
@@ -327,12 +328,12 @@ int st_gyro_common_probe(struct iio_dev *indio_dev, | |||
327 | 328 | ||
328 | err = st_sensors_init_sensor(indio_dev, pdata); | 329 | err = st_sensors_init_sensor(indio_dev, pdata); |
329 | if (err < 0) | 330 | if (err < 0) |
330 | goto st_gyro_common_probe_error; | 331 | return err; |
331 | 332 | ||
332 | if (gdata->get_irq_data_ready(indio_dev) > 0) { | 333 | if (irq > 0) { |
333 | err = st_gyro_allocate_ring(indio_dev); | 334 | err = st_gyro_allocate_ring(indio_dev); |
334 | if (err < 0) | 335 | if (err < 0) |
335 | goto st_gyro_common_probe_error; | 336 | return err; |
336 | 337 | ||
337 | err = st_sensors_allocate_trigger(indio_dev, | 338 | err = st_sensors_allocate_trigger(indio_dev, |
338 | ST_GYRO_TRIGGER_OPS); | 339 | ST_GYRO_TRIGGER_OPS); |
@@ -344,15 +345,15 @@ int st_gyro_common_probe(struct iio_dev *indio_dev, | |||
344 | if (err) | 345 | if (err) |
345 | goto st_gyro_device_register_error; | 346 | goto st_gyro_device_register_error; |
346 | 347 | ||
347 | return err; | 348 | return 0; |
348 | 349 | ||
349 | st_gyro_device_register_error: | 350 | st_gyro_device_register_error: |
350 | if (gdata->get_irq_data_ready(indio_dev) > 0) | 351 | if (irq > 0) |
351 | st_sensors_deallocate_trigger(indio_dev); | 352 | st_sensors_deallocate_trigger(indio_dev); |
352 | st_gyro_probe_trigger_error: | 353 | st_gyro_probe_trigger_error: |
353 | if (gdata->get_irq_data_ready(indio_dev) > 0) | 354 | if (irq > 0) |
354 | st_gyro_deallocate_ring(indio_dev); | 355 | st_gyro_deallocate_ring(indio_dev); |
355 | st_gyro_common_probe_error: | 356 | |
356 | return err; | 357 | return err; |
357 | } | 358 | } |
358 | EXPORT_SYMBOL(st_gyro_common_probe); | 359 | EXPORT_SYMBOL(st_gyro_common_probe); |