Commit 3e772581 authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman

staging:iio:dds:ad9951: allocate chip state with iio_dev

Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Acked-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent fb565f13
...@@ -51,7 +51,6 @@ struct ad9951_config { ...@@ -51,7 +51,6 @@ struct ad9951_config {
struct ad9951_state { struct ad9951_state {
struct mutex lock; struct mutex lock;
struct iio_dev *idev;
struct spi_device *sdev; struct spi_device *sdev;
}; };
...@@ -65,7 +64,7 @@ static ssize_t ad9951_set_parameter(struct device *dev, ...@@ -65,7 +64,7 @@ static ssize_t ad9951_set_parameter(struct device *dev,
int ret; int ret;
struct ad9951_config *config = (struct ad9951_config *)buf; struct ad9951_config *config = (struct ad9951_config *)buf;
struct iio_dev *idev = dev_get_drvdata(dev); struct iio_dev *idev = dev_get_drvdata(dev);
struct ad9951_state *st = idev->dev_data; struct ad9951_state *st = iio_priv(idev);
xfer.len = 3; xfer.len = 3;
xfer.tx_buf = &config->asf[0]; xfer.tx_buf = &config->asf[0];
...@@ -174,30 +173,25 @@ static const struct iio_info ad9951_info = { ...@@ -174,30 +173,25 @@ static const struct iio_info ad9951_info = {
static int __devinit ad9951_probe(struct spi_device *spi) static int __devinit ad9951_probe(struct spi_device *spi)
{ {
struct ad9951_state *st; struct ad9951_state *st;
struct iio_dev *idev;
int ret = 0; int ret = 0;
st = kzalloc(sizeof(*st), GFP_KERNEL); idev = iio_allocate_device(sizeof(*st));
if (st == NULL) { if (idev == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto error_ret; goto error_ret;
} }
spi_set_drvdata(spi, st); spi_set_drvdata(spi, idev);
st = iio_priv(idev);
mutex_init(&st->lock); mutex_init(&st->lock);
st->sdev = spi; st->sdev = spi;
st->idev = iio_allocate_device(0); idev->dev.parent = &spi->dev;
if (st->idev == NULL) {
ret = -ENOMEM;
goto error_free_st;
}
st->idev->dev.parent = &spi->dev;
st->idev->info = &ad9951_info; idev->info = &ad9951_info;
st->idev->dev_data = (void *)(st); idev->modes = INDIO_DIRECT_MODE;
st->idev->modes = INDIO_DIRECT_MODE;
ret = iio_device_register(st->idev); ret = iio_device_register(idev);
if (ret) if (ret)
goto error_free_dev; goto error_free_dev;
spi->max_speed_hz = 2000000; spi->max_speed_hz = 2000000;
...@@ -208,19 +202,15 @@ static int __devinit ad9951_probe(struct spi_device *spi) ...@@ -208,19 +202,15 @@ static int __devinit ad9951_probe(struct spi_device *spi)
return 0; return 0;
error_free_dev: error_free_dev:
iio_free_device(st->idev); iio_free_device(idev);
error_free_st:
kfree(st);
error_ret: error_ret:
return ret; return ret;
} }
static int __devexit ad9951_remove(struct spi_device *spi) static int __devexit ad9951_remove(struct spi_device *spi)
{ {
struct ad9951_state *st = spi_get_drvdata(spi); iio_device_unregister(spi_get_drvdata(spi));
iio_device_unregister(st->idev);
kfree(st);
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