~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise-security

« back to all changes in this revision

Viewing changes to drivers/staging/iio/dds/ad9951.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2011-12-06 15:56:07 UTC
  • Revision ID: package-import@ubuntu.com-20111206155607-pcf44kv5fmhk564f
Tags: 3.2.0-1401.1
[ Paolo Pisati ]

* Rebased on top of Ubuntu-3.2.0-3.8
* Tilt-tracking @ ef2487af4bb15bdd0689631774b5a5e3a59f74e2
* Delete debian.ti-omap4/control, it shoudln't be tracked
* Fix architecture spelling (s/armel/armhf/)
* [Config] Update configs following 3.2 import
* [Config] Fix compilation: disable CODA and ARCH_OMAP3
* [Config] Fix compilation: disable Ethernet Faraday
* Update series to precise

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#include <linux/spi/spi.h>
15
15
#include <linux/slab.h>
16
16
#include <linux/sysfs.h>
 
17
#include <linux/module.h>
17
18
 
18
19
#include "../iio.h"
19
20
#include "../sysfs.h"
51
52
 
52
53
struct ad9951_state {
53
54
        struct mutex lock;
54
 
        struct iio_dev *idev;
55
55
        struct spi_device *sdev;
56
56
};
57
57
 
65
65
        int ret;
66
66
        struct ad9951_config *config = (struct ad9951_config *)buf;
67
67
        struct iio_dev *idev = dev_get_drvdata(dev);
68
 
        struct ad9951_state *st = idev->dev_data;
 
68
        struct ad9951_state *st = iio_priv(idev);
69
69
 
70
70
        xfer.len = 3;
71
71
        xfer.tx_buf = &config->asf[0];
162
162
};
163
163
 
164
164
static const struct attribute_group ad9951_attribute_group = {
165
 
        .name = DRV_NAME,
166
165
        .attrs = ad9951_attributes,
167
166
};
168
167
 
174
173
static int __devinit ad9951_probe(struct spi_device *spi)
175
174
{
176
175
        struct ad9951_state *st;
 
176
        struct iio_dev *idev;
177
177
        int ret = 0;
178
178
 
179
 
        st = kzalloc(sizeof(*st), GFP_KERNEL);
180
 
        if (st == NULL) {
 
179
        idev = iio_allocate_device(sizeof(*st));
 
180
        if (idev == NULL) {
181
181
                ret = -ENOMEM;
182
182
                goto error_ret;
183
183
        }
184
 
        spi_set_drvdata(spi, st);
185
 
 
 
184
        spi_set_drvdata(spi, idev);
 
185
        st = iio_priv(idev);
186
186
        mutex_init(&st->lock);
187
187
        st->sdev = spi;
188
188
 
189
 
        st->idev = iio_allocate_device(0);
190
 
        if (st->idev == NULL) {
191
 
                ret = -ENOMEM;
192
 
                goto error_free_st;
193
 
        }
194
 
        st->idev->dev.parent = &spi->dev;
195
 
 
196
 
        st->idev->info = &ad9951_info;
197
 
        st->idev->dev_data = (void *)(st);
198
 
        st->idev->modes = INDIO_DIRECT_MODE;
199
 
 
200
 
        ret = iio_device_register(st->idev);
 
189
        idev->dev.parent = &spi->dev;
 
190
 
 
191
        idev->info = &ad9951_info;
 
192
        idev->modes = INDIO_DIRECT_MODE;
 
193
 
 
194
        ret = iio_device_register(idev);
201
195
        if (ret)
202
196
                goto error_free_dev;
203
197
        spi->max_speed_hz = 2000000;
208
202
        return 0;
209
203
 
210
204
error_free_dev:
211
 
        iio_free_device(st->idev);
212
 
error_free_st:
213
 
        kfree(st);
 
205
        iio_free_device(idev);
 
206
 
214
207
error_ret:
215
208
        return ret;
216
209
}
217
210
 
218
211
static int __devexit ad9951_remove(struct spi_device *spi)
219
212
{
220
 
        struct ad9951_state *st = spi_get_drvdata(spi);
221
 
 
222
 
        iio_device_unregister(st->idev);
223
 
        kfree(st);
 
213
        iio_device_unregister(spi_get_drvdata(spi));
 
214
        iio_free_device(spi_get_drvdata(spi));
224
215
 
225
216
        return 0;
226
217
}