diff options
Diffstat (limited to 'drivers/staging/iio/dds')
-rw-r--r-- | drivers/staging/iio/dds/Kconfig | 4 | ||||
-rw-r--r-- | drivers/staging/iio/dds/ad5930.c | 39 | ||||
-rw-r--r-- | drivers/staging/iio/dds/ad9832.c | 71 | ||||
-rw-r--r-- | drivers/staging/iio/dds/ad9832.h | 2 | ||||
-rw-r--r-- | drivers/staging/iio/dds/ad9834.c | 92 | ||||
-rw-r--r-- | drivers/staging/iio/dds/ad9834.h | 2 | ||||
-rw-r--r-- | drivers/staging/iio/dds/ad9850.c | 39 | ||||
-rw-r--r-- | drivers/staging/iio/dds/ad9852.c | 41 | ||||
-rw-r--r-- | drivers/staging/iio/dds/ad9910.c | 39 | ||||
-rw-r--r-- | drivers/staging/iio/dds/ad9951.c | 39 |
10 files changed, 153 insertions, 215 deletions
diff --git a/drivers/staging/iio/dds/Kconfig b/drivers/staging/iio/dds/Kconfig index e07431d..93b7141 100644 --- a/drivers/staging/iio/dds/Kconfig +++ b/drivers/staging/iio/dds/Kconfig @@ -1,7 +1,7 @@ # # Direct Digital Synthesis drivers # -comment "Direct Digital Synthesis" +menu "Direct Digital Synthesis" config AD5930 tristate "Analog Devices ad5930/5932 driver" @@ -57,3 +57,5 @@ config AD9951 help Say yes here to build support for Analog Devices DDS chip ad9951, provides direct access via sysfs. + +endmenu diff --git a/drivers/staging/iio/dds/ad5930.c b/drivers/staging/iio/dds/ad5930.c index 490c363..f5e368b 100644 --- a/drivers/staging/iio/dds/ad5930.c +++ b/drivers/staging/iio/dds/ad5930.c @@ -14,6 +14,7 @@ #include <linux/spi/spi.h> #include <linux/slab.h> #include <linux/sysfs.h> +#include <linux/module.h> #include "../iio.h" #include "../sysfs.h" @@ -35,7 +36,6 @@ struct ad5903_config { struct ad5930_state { struct mutex lock; - struct iio_dev *idev; struct spi_device *sdev; }; @@ -49,7 +49,7 @@ static ssize_t ad5930_set_parameter(struct device *dev, int ret; struct ad5903_config *config = (struct ad5903_config *)buf; struct iio_dev *idev = dev_get_drvdata(dev); - struct ad5930_state *st = idev->dev_data; + struct ad5930_state *st = iio_priv(idev); config->control = (config->control & ~value_mask); config->incnum = (config->control & ~value_mask) | (1 << addr_shift); @@ -83,42 +83,35 @@ static struct attribute *ad5930_attributes[] = { }; static const struct attribute_group ad5930_attribute_group = { - .name = DRV_NAME, .attrs = ad5930_attributes, }; static const struct iio_info ad5930_info = { .attrs = &ad5930_attribute_group, - .driver_module = THIS_MODULE, }; static int __devinit ad5930_probe(struct spi_device *spi) { struct ad5930_state *st; + struct iio_dev *idev; int ret = 0; - st = kzalloc(sizeof(*st), GFP_KERNEL); - if (st == NULL) { + idev = iio_allocate_device(sizeof(*st)); + if (idev == NULL) { ret = -ENOMEM; goto error_ret; } - spi_set_drvdata(spi, st); + spi_set_drvdata(spi, idev); + st = iio_priv(idev); mutex_init(&st->lock); st->sdev = spi; + idev->dev.parent = &spi->dev; + idev->info = &ad5930_info; + idev->modes = INDIO_DIRECT_MODE; - st->idev = iio_allocate_device(0); - if (st->idev == NULL) { - ret = -ENOMEM; - goto error_free_st; - } - st->idev->dev.parent = &spi->dev; - st->idev->dev_data = (void *)(st); - st->idev->info = &ad5930_info; - st->idev->modes = INDIO_DIRECT_MODE; - - ret = iio_device_register(st->idev); + ret = iio_device_register(idev); if (ret) goto error_free_dev; spi->max_speed_hz = 2000000; @@ -129,19 +122,15 @@ static int __devinit ad5930_probe(struct spi_device *spi) return 0; error_free_dev: - iio_free_device(st->idev); -error_free_st: - kfree(st); + iio_free_device(idev); error_ret: return ret; } static int __devexit ad5930_remove(struct spi_device *spi) { - struct ad5930_state *st = spi_get_drvdata(spi); - - iio_device_unregister(st->idev); - kfree(st); + iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/dds/ad9832.c b/drivers/staging/iio/dds/ad9832.c index e8fe142..9b4ff60 100644 --- a/drivers/staging/iio/dds/ad9832.c +++ b/drivers/staging/iio/dds/ad9832.c @@ -13,6 +13,7 @@ #include <linux/spi/spi.h> #include <linux/regulator/consumer.h> #include <linux/err.h> +#include <linux/module.h> #include <asm/div64.h> #include "../iio.h" @@ -52,7 +53,7 @@ static int ad9832_write_frequency(struct ad9832_state *st, ((addr - 3) << ADD_SHIFT) | ((regval >> 0) & 0xFF)); - return spi_sync(st->spi, &st->freq_msg);; + return spi_sync(st->spi, &st->freq_msg); } static int ad9832_write_phase(struct ad9832_state *st, @@ -76,8 +77,8 @@ static ssize_t ad9832_write(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad9832_state *st = dev_info->dev_data; + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad9832_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret; long val; @@ -86,7 +87,7 @@ static ssize_t ad9832_write(struct device *dev, if (ret) goto error_ret; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); switch (this_attr->address) { case AD9832_FREQ0HM: case AD9832_FREQ1HM: @@ -147,7 +148,7 @@ static ssize_t ad9832_write(struct device *dev, default: ret = -ENODEV; } - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); error_ret: return ret ? ret : len; @@ -203,7 +204,9 @@ static const struct iio_info ad9832_info = { static int __devinit ad9832_probe(struct spi_device *spi) { struct ad9832_platform_data *pdata = spi->dev.platform_data; + struct iio_dev *indio_dev; struct ad9832_state *st; + struct regulator *reg; int ret; if (!pdata) { @@ -211,35 +214,28 @@ static int __devinit ad9832_probe(struct spi_device *spi) return -ENODEV; } - st = kzalloc(sizeof(*st), GFP_KERNEL); - if (st == NULL) { - ret = -ENOMEM; - goto error_ret; - } - - st->reg = regulator_get(&spi->dev, "vcc"); - if (!IS_ERR(st->reg)) { - ret = regulator_enable(st->reg); + reg = regulator_get(&spi->dev, "vcc"); + if (!IS_ERR(reg)) { + ret = regulator_enable(reg); if (ret) goto error_put_reg; } - st->mclk = pdata->mclk; - - spi_set_drvdata(spi, st); - st->spi = spi; - - st->indio_dev = iio_allocate_device(0); - if (st->indio_dev == NULL) { + indio_dev = iio_allocate_device(sizeof(*st)); + if (indio_dev == NULL) { ret = -ENOMEM; goto error_disable_reg; } + spi_set_drvdata(spi, indio_dev); + st = iio_priv(indio_dev); + st->reg = reg; + st->mclk = pdata->mclk; + st->spi = spi; - st->indio_dev->dev.parent = &spi->dev; - st->indio_dev->name = spi_get_device_id(spi)->name; - st->indio_dev->info = &ad9832_info; - st->indio_dev->dev_data = (void *) st; - st->indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->dev.parent = &spi->dev; + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->info = &ad9832_info; + indio_dev->modes = INDIO_DIRECT_MODE; /* Setup default messages */ @@ -310,35 +306,36 @@ static int __devinit ad9832_probe(struct spi_device *spi) if (ret) goto error_free_device; - ret = iio_device_register(st->indio_dev); + ret = iio_device_register(indio_dev); if (ret) goto error_free_device; return 0; error_free_device: - iio_free_device(st->indio_dev); + iio_free_device(indio_dev); error_disable_reg: - if (!IS_ERR(st->reg)) - regulator_disable(st->reg); + if (!IS_ERR(reg)) + regulator_disable(reg); error_put_reg: - if (!IS_ERR(st->reg)) - regulator_put(st->reg); - kfree(st); -error_ret: + if (!IS_ERR(reg)) + regulator_put(reg); + return ret; } static int __devexit ad9832_remove(struct spi_device *spi) { - struct ad9832_state *st = spi_get_drvdata(spi); + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct ad9832_state *st = iio_priv(indio_dev); - iio_device_unregister(st->indio_dev); + iio_device_unregister(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } - kfree(st); + iio_free_device(indio_dev); + return 0; } diff --git a/drivers/staging/iio/dds/ad9832.h b/drivers/staging/iio/dds/ad9832.h index 5d47454..c5b701f 100644 --- a/drivers/staging/iio/dds/ad9832.h +++ b/drivers/staging/iio/dds/ad9832.h @@ -57,7 +57,6 @@ /** * struct ad9832_state - driver instance specific data - * @indio_dev: the industrial I/O device * @spi: spi_device * @reg: supply regulator * @mclk: external master clock @@ -76,7 +75,6 @@ */ struct ad9832_state { - struct iio_dev *indio_dev; struct spi_device *spi; struct regulator *reg; unsigned long mclk; diff --git a/drivers/staging/iio/dds/ad9834.c b/drivers/staging/iio/dds/ad9834.c index 0ebe8d5..c468f69 100644 --- a/drivers/staging/iio/dds/ad9834.c +++ b/drivers/staging/iio/dds/ad9834.c @@ -16,6 +16,7 @@ #include <linux/spi/spi.h> #include <linux/regulator/consumer.h> #include <linux/err.h> +#include <linux/module.h> #include <asm/div64.h> #include "../iio.h" @@ -65,8 +66,8 @@ static ssize_t ad9834_write(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad9834_state *st = dev_info->dev_data; + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad9834_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret; long val; @@ -75,7 +76,7 @@ static ssize_t ad9834_write(struct device *dev, if (ret) goto error_ret; - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); switch (this_attr->address) { case AD9834_REG_FREQ0: case AD9834_REG_FREQ1: @@ -133,7 +134,7 @@ static ssize_t ad9834_write(struct device *dev, default: ret = -ENODEV; } - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); error_ret: return ret ? ret : len; @@ -144,13 +145,13 @@ static ssize_t ad9834_store_wavetype(struct device *dev, const char *buf, size_t len) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad9834_state *st = dev_info->dev_data; + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad9834_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret = 0; bool is_ad9833_7 = (st->devid == ID_AD9833) || (st->devid == ID_AD9837); - mutex_lock(&dev_info->mlock); + mutex_lock(&indio_dev->mlock); switch (this_attr->address) { case 0: @@ -193,7 +194,7 @@ static ssize_t ad9834_store_wavetype(struct device *dev, st->data = cpu_to_be16(AD9834_REG_CMD | st->control); ret = spi_sync(st->spi, &st->msg); } - mutex_unlock(&dev_info->mlock); + mutex_unlock(&indio_dev->mlock); return ret ? ret : len; } @@ -202,8 +203,8 @@ static ssize_t ad9834_show_out0_wavetype_available(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad9834_state *st = iio_dev_get_devdata(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad9834_state *st = iio_priv(indio_dev); char *str; if ((st->devid == ID_AD9833) || (st->devid == ID_AD9837)) @@ -224,8 +225,8 @@ static ssize_t ad9834_show_out1_wavetype_available(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad9834_state *st = iio_dev_get_devdata(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad9834_state *st = iio_priv(indio_dev); char *str; if (st->control & AD9834_MODE) @@ -284,8 +285,8 @@ static mode_t ad9834_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n) { struct device *dev = container_of(kobj, struct device, kobj); - struct iio_dev *dev_info = dev_get_drvdata(dev); - struct ad9834_state *st = iio_dev_get_devdata(dev_info); + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct ad9834_state *st = iio_priv(indio_dev); mode_t mode = attr->mode; @@ -314,6 +315,8 @@ static int __devinit ad9834_probe(struct spi_device *spi) { struct ad9834_platform_data *pdata = spi->dev.platform_data; struct ad9834_state *st; + struct iio_dev *indio_dev; + struct regulator *reg; int ret; if (!pdata) { @@ -321,37 +324,28 @@ static int __devinit ad9834_probe(struct spi_device *spi) return -ENODEV; } - st = kzalloc(sizeof(*st), GFP_KERNEL); - if (st == NULL) { - ret = -ENOMEM; - goto error_ret; - } - - st->reg = regulator_get(&spi->dev, "vcc"); - if (!IS_ERR(st->reg)) { - ret = regulator_enable(st->reg); + reg = regulator_get(&spi->dev, "vcc"); + if (!IS_ERR(reg)) { + ret = regulator_enable(reg); if (ret) goto error_put_reg; } - st->mclk = pdata->mclk; - - spi_set_drvdata(spi, st); - - st->spi = spi; - st->devid = spi_get_device_id(spi)->driver_data; - - st->indio_dev = iio_allocate_device(0); - if (st->indio_dev == NULL) { + indio_dev = iio_allocate_device(sizeof(*st)); + if (indio_dev == NULL) { ret = -ENOMEM; goto error_disable_reg; } - - st->indio_dev->dev.parent = &spi->dev; - st->indio_dev->name = spi_get_device_id(spi)->name; - st->indio_dev->info = &ad9834_info; - st->indio_dev->dev_data = (void *) st; - st->indio_dev->modes = INDIO_DIRECT_MODE; + spi_set_drvdata(spi, indio_dev); + st = iio_priv(indio_dev); + st->mclk = pdata->mclk; + st->spi = spi; + st->devid = spi_get_device_id(spi)->driver_data; + st->reg = reg; + indio_dev->dev.parent = &spi->dev; + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->info = &ad9834_info; + indio_dev->modes = INDIO_DIRECT_MODE; /* Setup default messages */ @@ -402,35 +396,35 @@ static int __devinit ad9834_probe(struct spi_device *spi) if (ret) goto error_free_device; - ret = iio_device_register(st->indio_dev); + ret = iio_device_register(indio_dev); if (ret) goto error_free_device; return 0; error_free_device: - iio_free_device(st->indio_dev); + iio_free_device(indio_dev); error_disable_reg: - if (!IS_ERR(st->reg)) - regulator_disable(st->reg); + if (!IS_ERR(reg)) + regulator_disable(reg); error_put_reg: - if (!IS_ERR(st->reg)) - regulator_put(st->reg); - kfree(st); -error_ret: + if (!IS_ERR(reg)) + regulator_put(reg); return ret; } static int __devexit ad9834_remove(struct spi_device *spi) { - struct ad9834_state *st = spi_get_drvdata(spi); + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct ad9834_state *st = iio_priv(indio_dev); - iio_device_unregister(st->indio_dev); + iio_device_unregister(indio_dev); if (!IS_ERR(st->reg)) { regulator_disable(st->reg); regulator_put(st->reg); } - kfree(st); + iio_free_device(indio_dev); + return 0; } diff --git a/drivers/staging/iio/dds/ad9834.h b/drivers/staging/iio/dds/ad9834.h index 2abd635..ed5ed8d 100644 --- a/drivers/staging/iio/dds/ad9834.h +++ b/drivers/staging/iio/dds/ad9834.h @@ -38,7 +38,6 @@ /** * struct ad9834_state - driver instance specific data - * @indio_dev: the industrial I/O device * @spi: spi_device * @reg: supply regulator * @mclk: external master clock @@ -52,7 +51,6 @@ */ struct ad9834_state { - struct iio_dev *indio_dev; struct spi_device *spi; struct regulator *reg; unsigned int mclk; diff --git a/drivers/staging/iio/dds/ad9850.c b/drivers/staging/iio/dds/ad9850.c index b580d85..a14771b 100644 --- a/drivers/staging/iio/dds/ad9850.c +++ b/drivers/staging/iio/dds/ad9850.c @@ -14,6 +14,7 @@ #include <linux/spi/spi.h> #include <linux/slab.h> #include <linux/sysfs.h> +#include <linux/module.h> #include "../iio.h" #include "../sysfs.h" @@ -30,7 +31,6 @@ struct ad9850_config { struct ad9850_state { struct mutex lock; - struct iio_dev *idev; struct spi_device *sdev; }; @@ -44,7 +44,7 @@ static ssize_t ad9850_set_parameter(struct device *dev, int ret; struct ad9850_config *config = (struct ad9850_config *)buf; 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.tx_buf = config; @@ -69,7 +69,6 @@ static struct attribute *ad9850_attributes[] = { }; static const struct attribute_group ad9850_attribute_group = { - .name = DRV_NAME, .attrs = ad9850_attributes, }; @@ -81,30 +80,24 @@ static const struct iio_info ad9850_info = { static int __devinit ad9850_probe(struct spi_device *spi) { struct ad9850_state *st; + struct iio_dev *idev; int ret = 0; - st = kzalloc(sizeof(*st), GFP_KERNEL); - if (st == NULL) { + idev = iio_allocate_device(sizeof(*st)); + if (idev == NULL) { ret = -ENOMEM; goto error_ret; } - spi_set_drvdata(spi, st); - + spi_set_drvdata(spi, idev); + st = iio_priv(idev); mutex_init(&st->lock); st->sdev = spi; - st->idev = iio_allocate_device(0); - if (st->idev == NULL) { - ret = -ENOMEM; - goto error_free_st; - } - st->idev->dev.parent = &spi->dev; - - st->idev->info = &ad9850_info; - st->idev->dev_data = (void *)(st); - st->idev->modes = INDIO_DIRECT_MODE; + idev->dev.parent = &spi->dev; + idev->info = &ad9850_info; + idev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(st->idev); + ret = iio_device_register(idev); if (ret) goto error_free_dev; spi->max_speed_hz = 2000000; @@ -115,19 +108,15 @@ static int __devinit ad9850_probe(struct spi_device *spi) return 0; error_free_dev: - iio_free_device(st->idev); -error_free_st: - kfree(st); + iio_free_device(idev); error_ret: return ret; } static int __devexit ad9850_remove(struct spi_device *spi) { - struct ad9850_state *st = spi_get_drvdata(spi); - - iio_device_unregister(st->idev); - kfree(st); + iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/dds/ad9852.c b/drivers/staging/iio/dds/ad9852.c index 08020f9..cfceaa6 100644 --- a/drivers/staging/iio/dds/ad9852.c +++ b/drivers/staging/iio/dds/ad9852.c @@ -14,6 +14,7 @@ #include <linux/spi/spi.h> #include <linux/slab.h> #include <linux/sysfs.h> +#include <linux/module.h> #include "../iio.h" #include "../sysfs.h" @@ -58,7 +59,6 @@ struct ad9852_config { struct ad9852_state { struct mutex lock; - struct iio_dev *idev; struct spi_device *sdev; }; @@ -72,7 +72,7 @@ static ssize_t ad9852_set_parameter(struct device *dev, int ret; struct ad9852_config *config = (struct ad9852_config *)buf; struct iio_dev *idev = dev_get_drvdata(dev); - struct ad9852_state *st = idev->dev_data; + struct ad9852_state *st = iio_priv(idev); xfer.len = 3; xfer.tx_buf = &config->phajst0[0]; @@ -218,7 +218,6 @@ static struct attribute *ad9852_attributes[] = { }; static const struct attribute_group ad9852_attribute_group = { - .name = DRV_NAME, .attrs = ad9852_attributes, }; @@ -230,30 +229,24 @@ static const struct iio_info ad9852_info = { static int __devinit ad9852_probe(struct spi_device *spi) { struct ad9852_state *st; + struct iio_dev *idev; int ret = 0; - st = kzalloc(sizeof(*st), GFP_KERNEL); - if (st == NULL) { + idev = iio_allocate_device(sizeof(*st)); + if (idev == NULL) { ret = -ENOMEM; goto error_ret; } - spi_set_drvdata(spi, st); - + st = iio_priv(idev); + spi_set_drvdata(spi, idev); mutex_init(&st->lock); st->sdev = spi; - st->idev = iio_allocate_device(0); - if (st->idev == NULL) { - ret = -ENOMEM; - goto error_free_st; - } - st->idev->dev.parent = &spi->dev; + idev->dev.parent = &spi->dev; + idev->info = &ad9852_info; + idev->modes = INDIO_DIRECT_MODE; - st->idev->info = &ad9852_info; - st->idev->dev_data = (void *)(st); - st->idev->modes = INDIO_DIRECT_MODE; - - ret = iio_device_register(st->idev); + ret = iio_device_register(idev); if (ret) goto error_free_dev; spi->max_speed_hz = 2000000; @@ -261,22 +254,20 @@ static int __devinit ad9852_probe(struct spi_device *spi) spi->bits_per_word = 8; spi_setup(spi); ad9852_init(st); + return 0; error_free_dev: - iio_free_device(st->idev); -error_free_st: - kfree(st); + iio_free_device(idev); + error_ret: return ret; } static int __devexit ad9852_remove(struct spi_device *spi) { - struct ad9852_state *st = spi_get_drvdata(spi); - - iio_device_unregister(st->idev); - kfree(st); + iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/dds/ad9910.c b/drivers/staging/iio/dds/ad9910.c index 97d75d7..da83d2b 100644 --- a/drivers/staging/iio/dds/ad9910.c +++ b/drivers/staging/iio/dds/ad9910.c @@ -14,6 +14,7 @@ #include <linux/spi/spi.h> #include <linux/slab.h> #include <linux/sysfs.h> +#include <linux/module.h> #include "../iio.h" #include "../sysfs.h" @@ -110,7 +111,6 @@ struct ad9910_config { struct ad9910_state { struct mutex lock; - struct iio_dev *idev; struct spi_device *sdev; }; @@ -124,7 +124,7 @@ static ssize_t ad9910_set_parameter(struct device *dev, int ret; struct ad9910_config *config = (struct ad9910_config *)buf; struct iio_dev *idev = dev_get_drvdata(dev); - struct ad9910_state *st = idev->dev_data; + struct ad9910_state *st = iio_priv(idev); xfer.len = 5; xfer.tx_buf = &config->auxdac[0]; @@ -353,7 +353,6 @@ static struct attribute *ad9910_attributes[] = { }; static const struct attribute_group ad9910_attribute_group = { - .name = DRV_NAME, .attrs = ad9910_attributes, }; @@ -365,30 +364,24 @@ static const struct iio_info ad9910_info = { static int __devinit ad9910_probe(struct spi_device *spi) { struct ad9910_state *st; + struct iio_dev *idev; int ret = 0; - st = kzalloc(sizeof(*st), GFP_KERNEL); - if (st == NULL) { + idev = iio_allocate_device(sizeof(*st)); + if (idev == NULL) { ret = -ENOMEM; goto error_ret; } - spi_set_drvdata(spi, st); - + spi_set_drvdata(spi, idev); + st = iio_priv(idev); mutex_init(&st->lock); st->sdev = spi; - st->idev = iio_allocate_device(0); - if (st->idev == NULL) { - ret = -ENOMEM; - goto error_free_st; - } - st->idev->dev.parent = &spi->dev; - - st->idev->info = &ad9910_info; - st->idev->dev_data = (void *)(st); - st->idev->modes = INDIO_DIRECT_MODE; + idev->dev.parent = &spi->dev; + idev->info = &ad9910_info; + idev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(st->idev); + ret = iio_device_register(idev); if (ret) goto error_free_dev; spi->max_speed_hz = 2000000; @@ -399,19 +392,15 @@ static int __devinit ad9910_probe(struct spi_device *spi) return 0; error_free_dev: - iio_free_device(st->idev); -error_free_st: - kfree(st); + iio_free_device(idev); error_ret: return ret; } static int __devexit ad9910_remove(struct spi_device *spi) { - struct ad9910_state *st = spi_get_drvdata(spi); - - iio_device_unregister(st->idev); - kfree(st); + iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } diff --git a/drivers/staging/iio/dds/ad9951.c b/drivers/staging/iio/dds/ad9951.c index d4dfcd4..20c1825 100644 --- a/drivers/staging/iio/dds/ad9951.c +++ b/drivers/staging/iio/dds/ad9951.c @@ -14,6 +14,7 @@ #include <linux/spi/spi.h> #include <linux/slab.h> #include <linux/sysfs.h> +#include <linux/module.h> #include "../iio.h" #include "../sysfs.h" @@ -51,7 +52,6 @@ struct ad9951_config { struct ad9951_state { struct mutex lock; - struct iio_dev *idev; struct spi_device *sdev; }; @@ -65,7 +65,7 @@ static ssize_t ad9951_set_parameter(struct device *dev, int ret; struct ad9951_config *config = (struct ad9951_config *)buf; 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.tx_buf = &config->asf[0]; @@ -162,7 +162,6 @@ static struct attribute *ad9951_attributes[] = { }; static const struct attribute_group ad9951_attribute_group = { - .name = DRV_NAME, .attrs = ad9951_attributes, }; @@ -174,30 +173,25 @@ static const struct iio_info ad9951_info = { static int __devinit ad9951_probe(struct spi_device *spi) { struct ad9951_state *st; + struct iio_dev *idev; int ret = 0; - st = kzalloc(sizeof(*st), GFP_KERNEL); - if (st == NULL) { + idev = iio_allocate_device(sizeof(*st)); + if (idev == NULL) { ret = -ENOMEM; goto error_ret; } - spi_set_drvdata(spi, st); - + spi_set_drvdata(spi, idev); + st = iio_priv(idev); mutex_init(&st->lock); st->sdev = spi; - st->idev = iio_allocate_device(0); - if (st->idev == NULL) { - ret = -ENOMEM; - goto error_free_st; - } - st->idev->dev.parent = &spi->dev; + idev->dev.parent = &spi->dev; - st->idev->info = &ad9951_info; - st->idev->dev_data = (void *)(st); - st->idev->modes = INDIO_DIRECT_MODE; + idev->info = &ad9951_info; + idev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(st->idev); + ret = iio_device_register(idev); if (ret) goto error_free_dev; spi->max_speed_hz = 2000000; @@ -208,19 +202,16 @@ static int __devinit ad9951_probe(struct spi_device *spi) return 0; error_free_dev: - iio_free_device(st->idev); -error_free_st: - kfree(st); + iio_free_device(idev); + error_ret: return ret; } static int __devexit ad9951_remove(struct spi_device *spi) { - struct ad9951_state *st = spi_get_drvdata(spi); - - iio_device_unregister(st->idev); - kfree(st); + iio_device_unregister(spi_get_drvdata(spi)); + iio_free_device(spi_get_drvdata(spi)); return 0; } |