iio: max1363: Use devm_iio_device_alloc
Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:

committed by
Jonathan Cameron

parent
ebeb021af2
commit
6917e1d9af
@@ -1498,16 +1498,15 @@ static int max1363_probe(struct i2c_client *client,
|
|||||||
struct iio_dev *indio_dev;
|
struct iio_dev *indio_dev;
|
||||||
struct regulator *vref;
|
struct regulator *vref;
|
||||||
|
|
||||||
indio_dev = iio_device_alloc(sizeof(struct max1363_state));
|
indio_dev = devm_iio_device_alloc(&client->dev,
|
||||||
if (indio_dev == NULL) {
|
sizeof(struct max1363_state));
|
||||||
ret = -ENOMEM;
|
if (!indio_dev)
|
||||||
goto error_out;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
indio_dev->dev.of_node = client->dev.of_node;
|
indio_dev->dev.of_node = client->dev.of_node;
|
||||||
ret = iio_map_array_register(indio_dev, client->dev.platform_data);
|
ret = iio_map_array_register(indio_dev, client->dev.platform_data);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error_free_device;
|
return ret;
|
||||||
|
|
||||||
st = iio_priv(indio_dev);
|
st = iio_priv(indio_dev);
|
||||||
|
|
||||||
@@ -1590,9 +1589,6 @@ error_disable_reg:
|
|||||||
regulator_disable(st->reg);
|
regulator_disable(st->reg);
|
||||||
error_unregister_map:
|
error_unregister_map:
|
||||||
iio_map_array_unregister(indio_dev);
|
iio_map_array_unregister(indio_dev);
|
||||||
error_free_device:
|
|
||||||
iio_device_free(indio_dev);
|
|
||||||
error_out:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1607,7 +1603,6 @@ static int max1363_remove(struct i2c_client *client)
|
|||||||
regulator_disable(st->vref);
|
regulator_disable(st->vref);
|
||||||
regulator_disable(st->reg);
|
regulator_disable(st->reg);
|
||||||
iio_map_array_unregister(indio_dev);
|
iio_map_array_unregister(indio_dev);
|
||||||
iio_device_free(indio_dev);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user