Commit d243b3c0 authored by Sachin Kamat's avatar Sachin Kamat Committed by Jonathan Cameron

iio: gyro: itg3200_core: Use devm_iio_device_alloc

Using devm_iio_device_alloc makes code simpler.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Cc: Christian Strobel <christian.strobel@iis.fraunhofer.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 6694cf96
...@@ -309,11 +309,9 @@ static int itg3200_probe(struct i2c_client *client, ...@@ -309,11 +309,9 @@ static int itg3200_probe(struct i2c_client *client,
dev_dbg(&client->dev, "probe I2C dev with IRQ %i", client->irq); dev_dbg(&client->dev, "probe I2C dev with IRQ %i", client->irq);
indio_dev = iio_device_alloc(sizeof(*st)); indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
if (indio_dev == NULL) { if (!indio_dev)
ret = -ENOMEM; return -ENOMEM;
goto error_ret;
}
st = iio_priv(indio_dev); st = iio_priv(indio_dev);
...@@ -330,7 +328,7 @@ static int itg3200_probe(struct i2c_client *client, ...@@ -330,7 +328,7 @@ static int itg3200_probe(struct i2c_client *client,
ret = itg3200_buffer_configure(indio_dev); ret = itg3200_buffer_configure(indio_dev);
if (ret) if (ret)
goto error_free_dev; return ret;
if (client->irq) { if (client->irq) {
ret = itg3200_probe_trigger(indio_dev); ret = itg3200_probe_trigger(indio_dev);
...@@ -353,9 +351,6 @@ static int itg3200_probe(struct i2c_client *client, ...@@ -353,9 +351,6 @@ static int itg3200_probe(struct i2c_client *client,
itg3200_remove_trigger(indio_dev); itg3200_remove_trigger(indio_dev);
error_unconfigure_buffer: error_unconfigure_buffer:
itg3200_buffer_unconfigure(indio_dev); itg3200_buffer_unconfigure(indio_dev);
error_free_dev:
iio_device_free(indio_dev);
error_ret:
return ret; return ret;
} }
...@@ -370,8 +365,6 @@ static int itg3200_remove(struct i2c_client *client) ...@@ -370,8 +365,6 @@ static int itg3200_remove(struct i2c_client *client)
itg3200_buffer_unconfigure(indio_dev); itg3200_buffer_unconfigure(indio_dev);
iio_device_free(indio_dev);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment