staging:iio:dds:ad9850 allocate chip state with iio_dev + fix name of attr group.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
8b7163a5f6
commit
7be94372ca
@ -30,7 +30,6 @@ struct ad9850_config {
|
|||||||
|
|
||||||
struct ad9850_state {
|
struct ad9850_state {
|
||||||
struct mutex lock;
|
struct mutex lock;
|
||||||
struct iio_dev *idev;
|
|
||||||
struct spi_device *sdev;
|
struct spi_device *sdev;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ static ssize_t ad9850_set_parameter(struct device *dev,
|
|||||||
int ret;
|
int ret;
|
||||||
struct ad9850_config *config = (struct ad9850_config *)buf;
|
struct ad9850_config *config = (struct ad9850_config *)buf;
|
||||||
struct iio_dev *idev = dev_get_drvdata(dev);
|
struct iio_dev *idev = dev_get_drvdata(dev);
|
||||||
struct ad9850_state *st = idev->dev_data;
|
struct ad9850_state *st = iio_priv(idev);
|
||||||
|
|
||||||
xfer.len = len;
|
xfer.len = len;
|
||||||
xfer.tx_buf = config;
|
xfer.tx_buf = config;
|
||||||
@ -69,7 +68,6 @@ static struct attribute *ad9850_attributes[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const struct attribute_group ad9850_attribute_group = {
|
static const struct attribute_group ad9850_attribute_group = {
|
||||||
.name = DRV_NAME,
|
|
||||||
.attrs = ad9850_attributes,
|
.attrs = ad9850_attributes,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -81,30 +79,24 @@ static const struct iio_info ad9850_info = {
|
|||||||
static int __devinit ad9850_probe(struct spi_device *spi)
|
static int __devinit ad9850_probe(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
struct ad9850_state *st;
|
struct ad9850_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) {
|
idev->info = &ad9850_info;
|
||||||
ret = -ENOMEM;
|
idev->modes = INDIO_DIRECT_MODE;
|
||||||
goto error_free_st;
|
|
||||||
}
|
|
||||||
st->idev->dev.parent = &spi->dev;
|
|
||||||
|
|
||||||
st->idev->info = &ad9850_info;
|
ret = iio_device_register(idev);
|
||||||
st->idev->dev_data = (void *)(st);
|
|
||||||
st->idev->modes = INDIO_DIRECT_MODE;
|
|
||||||
|
|
||||||
ret = iio_device_register(st->idev);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error_free_dev;
|
goto error_free_dev;
|
||||||
spi->max_speed_hz = 2000000;
|
spi->max_speed_hz = 2000000;
|
||||||
@ -115,19 +107,14 @@ static int __devinit ad9850_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 ad9850_remove(struct spi_device *spi)
|
static int __devexit ad9850_remove(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
struct ad9850_state *st = spi_get_drvdata(spi);
|
iio_device_unregister(spi_get_drvdata(spi));
|
||||||
|
|
||||||
iio_device_unregister(st->idev);
|
|
||||||
kfree(st);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user