mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
staging: iio: ad7746: 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:
parent
538ee7cbff
commit
0eab65c64a
@ -699,11 +699,9 @@ static int ad7746_probe(struct i2c_client *client,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
unsigned char regval = 0;
|
unsigned char regval = 0;
|
||||||
|
|
||||||
indio_dev = iio_device_alloc(sizeof(*chip));
|
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
|
||||||
if (indio_dev == NULL) {
|
if (!indio_dev)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto error_ret;
|
|
||||||
}
|
|
||||||
chip = iio_priv(indio_dev);
|
chip = iio_priv(indio_dev);
|
||||||
/* this is only used for device removal purposes */
|
/* this is only used for device removal purposes */
|
||||||
i2c_set_clientdata(client, indio_dev);
|
i2c_set_clientdata(client, indio_dev);
|
||||||
@ -748,20 +746,15 @@ static int ad7746_probe(struct i2c_client *client,
|
|||||||
ret = i2c_smbus_write_byte_data(chip->client,
|
ret = i2c_smbus_write_byte_data(chip->client,
|
||||||
AD7746_REG_EXC_SETUP, regval);
|
AD7746_REG_EXC_SETUP, regval);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error_free_dev;
|
return ret;
|
||||||
|
|
||||||
ret = iio_device_register(indio_dev);
|
ret = iio_device_register(indio_dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error_free_dev;
|
return ret;
|
||||||
|
|
||||||
dev_info(&client->dev, "%s capacitive sensor registered\n", id->name);
|
dev_info(&client->dev, "%s capacitive sensor registered\n", id->name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_free_dev:
|
|
||||||
iio_device_free(indio_dev);
|
|
||||||
error_ret:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ad7746_remove(struct i2c_client *client)
|
static int ad7746_remove(struct i2c_client *client)
|
||||||
@ -769,7 +762,6 @@ static int ad7746_remove(struct i2c_client *client)
|
|||||||
struct iio_dev *indio_dev = i2c_get_clientdata(client);
|
struct iio_dev *indio_dev = i2c_get_clientdata(client);
|
||||||
|
|
||||||
iio_device_unregister(indio_dev);
|
iio_device_unregister(indio_dev);
|
||||||
iio_device_free(indio_dev);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user