data->ps_contr);
}
+static int ltr501_powerdown(struct ltr501_data *data)
+{
+ return ltr501_write_contr(data->client,
+ data->als_contr & ~LTR501_CONTR_ACTIVE,
+ data->ps_contr & ~LTR501_CONTR_ACTIVE);
+}
+
static int ltr501_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
ret = iio_triggered_buffer_setup(indio_dev, NULL,
ltr501_trigger_handler, NULL);
if (ret)
- return ret;
+ goto powerdown_on_error;
ret = iio_device_register(indio_dev);
if (ret)
error_unreg_buffer:
iio_triggered_buffer_cleanup(indio_dev);
+powerdown_on_error:
+ ltr501_powerdown(data);
return ret;
}
-static int ltr501_powerdown(struct ltr501_data *data)
-{
- return ltr501_write_contr(data->client,
- data->als_contr & ~LTR501_CONTR_ACTIVE,
- data->ps_contr & ~LTR501_CONTR_ACTIVE);
-}
-
static int ltr501_remove(struct i2c_client *client)
{
struct iio_dev *indio_dev = i2c_get_clientdata(client);