From 0c7b5379322e2e616bc7a820284430cfa770bb42 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 27 Jun 2011 13:07:40 +0100 Subject: [PATCH] --- yaml --- r: 259623 b: refs/heads/master c: a28299114b2035ef4cf356c590ab946b73a9268e h: refs/heads/master i: 259621: 05a785ba6202e1929da5e659193c3adf465a71ad 259619: cfca820ec2274d2a89e5a2ddd7716e8441de277a 259615: 43def534e01278940c20349ff3166beab2fda8b8 v: v3 --- [refs] | 2 +- trunk/drivers/staging/iio/dds/ad9852.c | 38 ++++++++++---------------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/[refs] b/[refs] index e60a18b510aa..a13333983e45 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 7be94372cac8dcb23d6ed06960b75a1f63970d39 +refs/heads/master: a28299114b2035ef4cf356c590ab946b73a9268e diff --git a/trunk/drivers/staging/iio/dds/ad9852.c b/trunk/drivers/staging/iio/dds/ad9852.c index 08020f96300a..0184585425d8 100644 --- a/trunk/drivers/staging/iio/dds/ad9852.c +++ b/trunk/drivers/staging/iio/dds/ad9852.c @@ -58,7 +58,6 @@ struct ad9852_config { struct ad9852_state { struct mutex lock; - struct iio_dev *idev; struct spi_device *sdev; }; @@ -72,7 +71,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]; @@ -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,19 @@ 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)); return 0; }