staging: iio: ad799x_core: Use devm_* APIs

devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
Sachin Kamat 2013-08-31 18:12:00 +01:00 committed by Jonathan Cameron
parent e5bf4f5b7d
commit 6a88fa4826
1 changed files with 5 additions and 11 deletions

View File

@ -586,8 +586,9 @@ static int ad799x_probe(struct i2c_client *client,
int ret;
struct ad799x_platform_data *pdata = client->dev.platform_data;
struct ad799x_state *st;
struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
struct iio_dev *indio_dev;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
@ -606,11 +607,11 @@ static int ad799x_probe(struct i2c_client *client,
st->int_vref_mv = pdata->vref_mv;
st->reg = regulator_get(&client->dev, "vcc");
st->reg = devm_regulator_get(&client->dev, "vcc");
if (!IS_ERR(st->reg)) {
ret = regulator_enable(st->reg);
if (ret)
goto error_put_reg;
return ret;
}
st->client = client;
@ -650,10 +651,6 @@ error_cleanup_ring:
error_disable_reg:
if (!IS_ERR(st->reg))
regulator_disable(st->reg);
error_put_reg:
if (!IS_ERR(st->reg))
regulator_put(st->reg);
iio_device_free(indio_dev);
return ret;
}
@ -668,12 +665,9 @@ static int ad799x_remove(struct i2c_client *client)
free_irq(client->irq, indio_dev);
ad799x_ring_cleanup(indio_dev);
if (!IS_ERR(st->reg)) {
if (!IS_ERR(st->reg))
regulator_disable(st->reg);
regulator_put(st->reg);
}
kfree(st->rx_buf);
iio_device_free(indio_dev);
return 0;
}