GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / staging / iio / imu / adis16350_core.c
blob1575b7b5d44faf0006798e45f1288e1c59262e41
1 /*
2 * ADIS16350/54/55/60/62/64/65 high precision tri-axis inertial sensor
4 * Copyright 2010 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
7 */
9 #include <linux/interrupt.h>
10 #include <linux/irq.h>
11 #include <linux/gpio.h>
12 #include <linux/delay.h>
13 #include <linux/mutex.h>
14 #include <linux/device.h>
15 #include <linux/kernel.h>
16 #include <linux/spi/spi.h>
17 #include <linux/slab.h>
18 #include <linux/sysfs.h>
19 #include <linux/list.h>
21 #include "../iio.h"
22 #include "../sysfs.h"
23 #include "../ring_generic.h"
24 #include "../accel/accel.h"
25 #include "../adc/adc.h"
26 #include "../gyro/gyro.h"
28 #include "adis16350.h"
30 #define DRIVER_NAME "adis16350"
32 static int adis16350_check_status(struct device *dev);
34 /**
35 * adis16350_spi_write_reg_8() - write single byte to a register
36 * @dev: device associated with child of actual device (iio_dev or iio_trig)
37 * @reg_address: the address of the register to be written
38 * @val: the value to write
39 **/
40 static int adis16350_spi_write_reg_8(struct device *dev,
41 u8 reg_address,
42 u8 val)
44 int ret;
45 struct iio_dev *indio_dev = dev_get_drvdata(dev);
46 struct adis16350_state *st = iio_dev_get_devdata(indio_dev);
48 mutex_lock(&st->buf_lock);
49 st->tx[0] = ADIS16350_WRITE_REG(reg_address);
50 st->tx[1] = val;
52 ret = spi_write(st->us, st->tx, 2);
53 mutex_unlock(&st->buf_lock);
55 return ret;
58 /**
59 * adis16350_spi_write_reg_16() - write 2 bytes to a pair of registers
60 * @dev: device associated with child of actual device (iio_dev or iio_trig)
61 * @reg_address: the address of the lower of the two registers. Second register
62 * is assumed to have address one greater.
63 * @val: value to be written
64 **/
65 static int adis16350_spi_write_reg_16(struct device *dev,
66 u8 lower_reg_address,
67 u16 value)
69 int ret;
70 struct spi_message msg;
71 struct iio_dev *indio_dev = dev_get_drvdata(dev);
72 struct adis16350_state *st = iio_dev_get_devdata(indio_dev);
73 struct spi_transfer xfers[] = {
75 .tx_buf = st->tx,
76 .bits_per_word = 8,
77 .len = 2,
78 .cs_change = 1,
79 .delay_usecs = 35,
80 }, {
81 .tx_buf = st->tx + 2,
82 .bits_per_word = 8,
83 .len = 2,
84 .cs_change = 1,
85 .delay_usecs = 35,
89 mutex_lock(&st->buf_lock);
90 st->tx[0] = ADIS16350_WRITE_REG(lower_reg_address);
91 st->tx[1] = value & 0xFF;
92 st->tx[2] = ADIS16350_WRITE_REG(lower_reg_address + 1);
93 st->tx[3] = (value >> 8) & 0xFF;
95 spi_message_init(&msg);
96 spi_message_add_tail(&xfers[0], &msg);
97 spi_message_add_tail(&xfers[1], &msg);
98 ret = spi_sync(st->us, &msg);
99 mutex_unlock(&st->buf_lock);
101 return ret;
105 * adis16350_spi_read_reg_16() - read 2 bytes from a 16-bit register
106 * @dev: device associated with child of actual device (iio_dev or iio_trig)
107 * @reg_address: the address of the lower of the two registers. Second register
108 * is assumed to have address one greater.
109 * @val: somewhere to pass back the value read
111 static int adis16350_spi_read_reg_16(struct device *dev,
112 u8 lower_reg_address,
113 u16 *val)
115 struct spi_message msg;
116 struct iio_dev *indio_dev = dev_get_drvdata(dev);
117 struct adis16350_state *st = iio_dev_get_devdata(indio_dev);
118 int ret;
119 struct spi_transfer xfers[] = {
121 .tx_buf = st->tx,
122 .bits_per_word = 8,
123 .len = 2,
124 .cs_change = 1,
125 .delay_usecs = 35,
126 }, {
127 .rx_buf = st->rx,
128 .bits_per_word = 8,
129 .len = 2,
130 .cs_change = 1,
131 .delay_usecs = 35,
135 mutex_lock(&st->buf_lock);
136 st->tx[0] = ADIS16350_READ_REG(lower_reg_address);
137 st->tx[1] = 0;
138 st->tx[2] = 0;
139 st->tx[3] = 0;
141 spi_message_init(&msg);
142 spi_message_add_tail(&xfers[0], &msg);
143 spi_message_add_tail(&xfers[1], &msg);
144 ret = spi_sync(st->us, &msg);
145 if (ret) {
146 dev_err(&st->us->dev,
147 "problem when reading 16 bit register 0x%02X",
148 lower_reg_address);
149 goto error_ret;
151 *val = (st->rx[0] << 8) | st->rx[1];
153 error_ret:
154 mutex_unlock(&st->buf_lock);
155 return ret;
159 static ssize_t adis16350_spi_read_signed(struct device *dev,
160 struct device_attribute *attr,
161 char *buf,
162 unsigned bits)
164 int ret;
165 s16 val = 0;
166 unsigned shift = 16 - bits;
167 struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
169 ret = adis16350_spi_read_reg_16(dev, this_attr->address, (u16 *)&val);
170 if (ret)
171 return ret;
173 if (val & ADIS16350_ERROR_ACTIVE)
174 adis16350_check_status(dev);
175 val = ((s16)(val << shift) >> shift);
176 return sprintf(buf, "%d\n", val);
179 static ssize_t adis16350_read_12bit_unsigned(struct device *dev,
180 struct device_attribute *attr,
181 char *buf)
183 int ret;
184 u16 val = 0;
185 struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
187 ret = adis16350_spi_read_reg_16(dev, this_attr->address, &val);
188 if (ret)
189 return ret;
191 if (val & ADIS16350_ERROR_ACTIVE)
192 adis16350_check_status(dev);
194 return sprintf(buf, "%u\n", val & 0x0FFF);
197 static ssize_t adis16350_read_14bit_signed(struct device *dev,
198 struct device_attribute *attr,
199 char *buf)
201 struct iio_dev *indio_dev = dev_get_drvdata(dev);
202 ssize_t ret;
204 /* Take the iio_dev status lock */
205 mutex_lock(&indio_dev->mlock);
206 ret = adis16350_spi_read_signed(dev, attr, buf, 14);
207 mutex_unlock(&indio_dev->mlock);
209 return ret;
212 static ssize_t adis16350_read_12bit_signed(struct device *dev,
213 struct device_attribute *attr,
214 char *buf)
216 struct iio_dev *indio_dev = dev_get_drvdata(dev);
217 ssize_t ret;
219 /* Take the iio_dev status lock */
220 mutex_lock(&indio_dev->mlock);
221 ret = adis16350_spi_read_signed(dev, attr, buf, 12);
222 mutex_unlock(&indio_dev->mlock);
224 return ret;
227 static ssize_t adis16350_write_16bit(struct device *dev,
228 struct device_attribute *attr,
229 const char *buf,
230 size_t len)
232 struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
233 int ret;
234 long val;
236 ret = strict_strtol(buf, 10, &val);
237 if (ret)
238 goto error_ret;
239 ret = adis16350_spi_write_reg_16(dev, this_attr->address, val);
241 error_ret:
242 return ret ? ret : len;
245 static ssize_t adis16350_read_frequency(struct device *dev,
246 struct device_attribute *attr,
247 char *buf)
249 int ret, len = 0;
250 u16 t;
251 int sps;
252 ret = adis16350_spi_read_reg_16(dev,
253 ADIS16350_SMPL_PRD,
254 &t);
255 if (ret)
256 return ret;
257 sps = (t & ADIS16350_SMPL_PRD_TIME_BASE) ? 53 : 1638;
258 sps /= (t & ADIS16350_SMPL_PRD_DIV_MASK) + 1;
259 len = sprintf(buf, "%d SPS\n", sps);
260 return len;
263 static ssize_t adis16350_write_frequency(struct device *dev,
264 struct device_attribute *attr,
265 const char *buf,
266 size_t len)
268 struct iio_dev *indio_dev = dev_get_drvdata(dev);
269 struct adis16350_state *st = iio_dev_get_devdata(indio_dev);
270 long val;
271 int ret;
272 u8 t;
274 ret = strict_strtol(buf, 10, &val);
275 if (ret)
276 return ret;
278 mutex_lock(&indio_dev->mlock);
280 t = (1638 / val);
281 if (t > 0)
282 t--;
283 t &= ADIS16350_SMPL_PRD_DIV_MASK;
284 if ((t & ADIS16350_SMPL_PRD_DIV_MASK) >= 0x0A)
285 st->us->max_speed_hz = ADIS16350_SPI_SLOW;
286 else
287 st->us->max_speed_hz = ADIS16350_SPI_FAST;
289 ret = adis16350_spi_write_reg_8(dev,
290 ADIS16350_SMPL_PRD,
293 mutex_unlock(&indio_dev->mlock);
295 return ret ? ret : len;
298 static int adis16350_reset(struct device *dev)
300 int ret;
301 ret = adis16350_spi_write_reg_8(dev,
302 ADIS16350_GLOB_CMD,
303 ADIS16350_GLOB_CMD_SW_RESET);
304 if (ret)
305 dev_err(dev, "problem resetting device");
307 return ret;
310 static ssize_t adis16350_write_reset(struct device *dev,
311 struct device_attribute *attr,
312 const char *buf, size_t len)
314 if (len < 1)
315 return -1;
316 switch (buf[0]) {
317 case '1':
318 case 'y':
319 case 'Y':
320 return adis16350_reset(dev);
322 return -1;
325 int adis16350_set_irq(struct device *dev, bool enable)
327 int ret;
328 u16 msc;
329 ret = adis16350_spi_read_reg_16(dev, ADIS16350_MSC_CTRL, &msc);
330 if (ret)
331 goto error_ret;
333 msc |= ADIS16350_MSC_CTRL_DATA_RDY_POL_HIGH;
334 msc &= ~ADIS16350_MSC_CTRL_DATA_RDY_DIO2;
336 if (enable)
337 msc |= ADIS16350_MSC_CTRL_DATA_RDY_EN;
338 else
339 msc &= ~ADIS16350_MSC_CTRL_DATA_RDY_EN;
341 ret = adis16350_spi_write_reg_16(dev, ADIS16350_MSC_CTRL, msc);
342 if (ret)
343 goto error_ret;
345 error_ret:
346 return ret;
349 /* Power down the device */
350 static int adis16350_stop_device(struct device *dev)
352 int ret;
353 u16 val = ADIS16350_SLP_CNT_POWER_OFF;
355 ret = adis16350_spi_write_reg_16(dev, ADIS16350_SLP_CNT, val);
356 if (ret)
357 dev_err(dev, "problem with turning device off: SLP_CNT");
359 return ret;
362 static int adis16350_self_test(struct device *dev)
364 int ret;
365 ret = adis16350_spi_write_reg_16(dev,
366 ADIS16350_MSC_CTRL,
367 ADIS16350_MSC_CTRL_MEM_TEST);
368 if (ret) {
369 dev_err(dev, "problem starting self test");
370 goto err_ret;
373 adis16350_check_status(dev);
375 err_ret:
376 return ret;
379 static int adis16350_check_status(struct device *dev)
381 u16 status;
382 int ret;
384 ret = adis16350_spi_read_reg_16(dev, ADIS16350_DIAG_STAT, &status);
386 if (ret < 0) {
387 dev_err(dev, "Reading status failed\n");
388 goto error_ret;
390 ret = status;
391 if (status & ADIS16350_DIAG_STAT_ZACCL_FAIL)
392 dev_err(dev, "Z-axis accelerometer self-test failure\n");
393 if (status & ADIS16350_DIAG_STAT_YACCL_FAIL)
394 dev_err(dev, "Y-axis accelerometer self-test failure\n");
395 if (status & ADIS16350_DIAG_STAT_XACCL_FAIL)
396 dev_err(dev, "X-axis accelerometer self-test failure\n");
397 if (status & ADIS16350_DIAG_STAT_XGYRO_FAIL)
398 dev_err(dev, "X-axis gyroscope self-test failure\n");
399 if (status & ADIS16350_DIAG_STAT_YGYRO_FAIL)
400 dev_err(dev, "Y-axis gyroscope self-test failure\n");
401 if (status & ADIS16350_DIAG_STAT_ZGYRO_FAIL)
402 dev_err(dev, "Z-axis gyroscope self-test failure\n");
403 if (status & ADIS16350_DIAG_STAT_ALARM2)
404 dev_err(dev, "Alarm 2 active\n");
405 if (status & ADIS16350_DIAG_STAT_ALARM1)
406 dev_err(dev, "Alarm 1 active\n");
407 if (status & ADIS16350_DIAG_STAT_FLASH_CHK)
408 dev_err(dev, "Flash checksum error\n");
409 if (status & ADIS16350_DIAG_STAT_SELF_TEST)
410 dev_err(dev, "Self test error\n");
411 if (status & ADIS16350_DIAG_STAT_OVERFLOW)
412 dev_err(dev, "Sensor overrange\n");
413 if (status & ADIS16350_DIAG_STAT_SPI_FAIL)
414 dev_err(dev, "SPI failure\n");
415 if (status & ADIS16350_DIAG_STAT_FLASH_UPT)
416 dev_err(dev, "Flash update failed\n");
417 if (status & ADIS16350_DIAG_STAT_POWER_HIGH)
418 dev_err(dev, "Power supply above 5.25V\n");
419 if (status & ADIS16350_DIAG_STAT_POWER_LOW)
420 dev_err(dev, "Power supply below 4.75V\n");
422 error_ret:
423 return ret;
426 static int adis16350_initial_setup(struct adis16350_state *st)
428 int ret;
429 u16 smp_prd;
430 struct device *dev = &st->indio_dev->dev;
432 /* use low spi speed for init */
433 st->us->max_speed_hz = ADIS16350_SPI_SLOW;
434 st->us->mode = SPI_MODE_3;
435 spi_setup(st->us);
437 /* Disable IRQ */
438 ret = adis16350_set_irq(dev, false);
439 if (ret) {
440 dev_err(dev, "disable irq failed");
441 goto err_ret;
444 /* Do self test */
445 ret = adis16350_self_test(dev);
446 if (ret) {
447 dev_err(dev, "self test failure");
448 goto err_ret;
451 /* Read status register to check the result */
452 ret = adis16350_check_status(dev);
453 if (ret) {
454 adis16350_reset(dev);
455 dev_err(dev, "device not playing ball -> reset");
456 msleep(ADIS16350_STARTUP_DELAY);
457 ret = adis16350_check_status(dev);
458 if (ret) {
459 dev_err(dev, "giving up");
460 goto err_ret;
464 printk(KERN_INFO DRIVER_NAME ": at CS%d (irq %d)\n",
465 st->us->chip_select, st->us->irq);
467 /* use high spi speed if possible */
468 ret = adis16350_spi_read_reg_16(dev, ADIS16350_SMPL_PRD, &smp_prd);
469 if (!ret && (smp_prd & ADIS16350_SMPL_PRD_DIV_MASK) < 0x0A) {
470 st->us->max_speed_hz = ADIS16350_SPI_SLOW;
471 spi_setup(st->us);
474 err_ret:
475 return ret;
478 static IIO_DEV_ATTR_ACCEL_X_OFFSET(S_IWUSR | S_IRUGO,
479 adis16350_read_12bit_signed,
480 adis16350_write_16bit,
481 ADIS16350_XACCL_OFF);
483 static IIO_DEV_ATTR_ACCEL_Y_OFFSET(S_IWUSR | S_IRUGO,
484 adis16350_read_12bit_signed,
485 adis16350_write_16bit,
486 ADIS16350_YACCL_OFF);
488 static IIO_DEV_ATTR_ACCEL_Z_OFFSET(S_IWUSR | S_IRUGO,
489 adis16350_read_12bit_signed,
490 adis16350_write_16bit,
491 ADIS16350_ZACCL_OFF);
493 static IIO_DEV_ATTR_IN_NAMED_RAW(supply, adis16350_read_12bit_unsigned,
494 ADIS16350_SUPPLY_OUT);
495 static IIO_CONST_ATTR(in_supply_scale, "0.002418");
497 static IIO_DEV_ATTR_GYRO_X(adis16350_read_14bit_signed,
498 ADIS16350_XGYRO_OUT);
499 static IIO_DEV_ATTR_GYRO_Y(adis16350_read_14bit_signed,
500 ADIS16350_YGYRO_OUT);
501 static IIO_DEV_ATTR_GYRO_Z(adis16350_read_14bit_signed,
502 ADIS16350_ZGYRO_OUT);
503 static IIO_CONST_ATTR(gyro_scale, "0.05");
505 static IIO_DEV_ATTR_ACCEL_X(adis16350_read_14bit_signed,
506 ADIS16350_XACCL_OUT);
507 static IIO_DEV_ATTR_ACCEL_Y(adis16350_read_14bit_signed,
508 ADIS16350_YACCL_OUT);
509 static IIO_DEV_ATTR_ACCEL_Z(adis16350_read_14bit_signed,
510 ADIS16350_ZACCL_OUT);
511 static IIO_CONST_ATTR(accel_scale, "0.00333");
513 static IIO_DEVICE_ATTR(temp_x_raw, S_IRUGO, adis16350_read_12bit_signed,
514 NULL, ADIS16350_XTEMP_OUT);
515 static IIO_DEVICE_ATTR(temp_y_raw, S_IRUGO, adis16350_read_12bit_signed,
516 NULL, ADIS16350_YTEMP_OUT);
517 static IIO_DEVICE_ATTR(temp_z_raw, S_IRUGO, adis16350_read_12bit_signed,
518 NULL, ADIS16350_ZTEMP_OUT);
519 static IIO_CONST_ATTR(temp_scale, "0.0005");
521 static IIO_DEV_ATTR_IN_RAW(0, adis16350_read_12bit_unsigned,
522 ADIS16350_AUX_ADC);
523 static IIO_CONST_ATTR(in0_scale, "0.000806");
525 static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
526 adis16350_read_frequency,
527 adis16350_write_frequency);
529 static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL,
530 adis16350_write_reset, 0);
532 static IIO_CONST_ATTR_AVAIL_SAMP_FREQ("409 546 819 1638");
534 static IIO_CONST_ATTR(name, "adis16350");
536 static struct attribute *adis16350_attributes[] = {
537 &iio_dev_attr_accel_x_offset.dev_attr.attr,
538 &iio_dev_attr_accel_y_offset.dev_attr.attr,
539 &iio_dev_attr_accel_z_offset.dev_attr.attr,
540 &iio_dev_attr_in_supply_raw.dev_attr.attr,
541 &iio_const_attr_in_supply_scale.dev_attr.attr,
542 &iio_dev_attr_gyro_x_raw.dev_attr.attr,
543 &iio_dev_attr_gyro_y_raw.dev_attr.attr,
544 &iio_dev_attr_gyro_z_raw.dev_attr.attr,
545 &iio_const_attr_gyro_scale.dev_attr.attr,
546 &iio_dev_attr_accel_x_raw.dev_attr.attr,
547 &iio_dev_attr_accel_y_raw.dev_attr.attr,
548 &iio_dev_attr_accel_z_raw.dev_attr.attr,
549 &iio_const_attr_accel_scale.dev_attr.attr,
550 &iio_dev_attr_temp_x_raw.dev_attr.attr,
551 &iio_dev_attr_temp_y_raw.dev_attr.attr,
552 &iio_dev_attr_temp_z_raw.dev_attr.attr,
553 &iio_const_attr_temp_scale.dev_attr.attr,
554 &iio_dev_attr_in0_raw.dev_attr.attr,
555 &iio_const_attr_in0_scale.dev_attr.attr,
556 &iio_dev_attr_sampling_frequency.dev_attr.attr,
557 &iio_const_attr_available_sampling_frequency.dev_attr.attr,
558 &iio_dev_attr_reset.dev_attr.attr,
559 &iio_const_attr_name.dev_attr.attr,
560 NULL
563 static const struct attribute_group adis16350_attribute_group = {
564 .attrs = adis16350_attributes,
567 static struct attribute *adis16350_event_attributes[] = {
568 NULL,
571 static struct attribute_group adis16350_event_attribute_group = {
572 .attrs = adis16350_event_attributes,
575 static int __devinit adis16350_probe(struct spi_device *spi)
577 int ret, regdone = 0;
578 struct adis16350_state *st = kzalloc(sizeof *st, GFP_KERNEL);
579 if (!st) {
580 ret = -ENOMEM;
581 goto error_ret;
583 /* this is only used for removal purposes */
584 spi_set_drvdata(spi, st);
586 /* Allocate the comms buffers */
587 st->rx = kzalloc(sizeof(*st->rx)*ADIS16350_MAX_RX, GFP_KERNEL);
588 if (st->rx == NULL) {
589 ret = -ENOMEM;
590 goto error_free_st;
592 st->tx = kzalloc(sizeof(*st->tx)*ADIS16350_MAX_TX, GFP_KERNEL);
593 if (st->tx == NULL) {
594 ret = -ENOMEM;
595 goto error_free_rx;
597 st->us = spi;
598 mutex_init(&st->buf_lock);
599 /* setup the industrialio driver allocated elements */
600 st->indio_dev = iio_allocate_device();
601 if (st->indio_dev == NULL) {
602 ret = -ENOMEM;
603 goto error_free_tx;
606 st->indio_dev->dev.parent = &spi->dev;
607 st->indio_dev->num_interrupt_lines = 1;
608 st->indio_dev->event_attrs = &adis16350_event_attribute_group;
609 st->indio_dev->attrs = &adis16350_attribute_group;
610 st->indio_dev->dev_data = (void *)(st);
611 st->indio_dev->driver_module = THIS_MODULE;
612 st->indio_dev->modes = INDIO_DIRECT_MODE;
614 ret = adis16350_configure_ring(st->indio_dev);
615 if (ret)
616 goto error_free_dev;
618 ret = iio_device_register(st->indio_dev);
619 if (ret)
620 goto error_unreg_ring_funcs;
621 regdone = 1;
623 ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
624 if (ret) {
625 printk(KERN_ERR "failed to initialize the ring\n");
626 goto error_unreg_ring_funcs;
629 if (spi->irq) {
630 ret = iio_register_interrupt_line(spi->irq,
631 st->indio_dev,
633 IRQF_TRIGGER_RISING,
634 "adis16350");
635 if (ret)
636 goto error_uninitialize_ring;
638 ret = adis16350_probe_trigger(st->indio_dev);
639 if (ret)
640 goto error_unregister_line;
643 /* Get the device into a sane initial state */
644 ret = adis16350_initial_setup(st);
645 if (ret)
646 goto error_remove_trigger;
647 return 0;
649 error_remove_trigger:
650 adis16350_remove_trigger(st->indio_dev);
651 error_unregister_line:
652 if (spi->irq)
653 iio_unregister_interrupt_line(st->indio_dev, 0);
654 error_uninitialize_ring:
655 iio_ring_buffer_unregister(st->indio_dev->ring);
656 error_unreg_ring_funcs:
657 adis16350_unconfigure_ring(st->indio_dev);
658 error_free_dev:
659 if (regdone)
660 iio_device_unregister(st->indio_dev);
661 else
662 iio_free_device(st->indio_dev);
663 error_free_tx:
664 kfree(st->tx);
665 error_free_rx:
666 kfree(st->rx);
667 error_free_st:
668 kfree(st);
669 error_ret:
670 return ret;
673 static int adis16350_remove(struct spi_device *spi)
675 int ret;
676 struct adis16350_state *st = spi_get_drvdata(spi);
677 struct iio_dev *indio_dev = st->indio_dev;
679 ret = adis16350_stop_device(&(indio_dev->dev));
680 if (ret)
681 goto err_ret;
683 flush_scheduled_work();
685 adis16350_remove_trigger(indio_dev);
686 if (spi->irq)
687 iio_unregister_interrupt_line(indio_dev, 0);
689 iio_ring_buffer_unregister(indio_dev->ring);
690 iio_device_unregister(indio_dev);
691 adis16350_unconfigure_ring(indio_dev);
692 kfree(st->tx);
693 kfree(st->rx);
694 kfree(st);
696 return 0;
698 err_ret:
699 return ret;
702 static const struct spi_device_id adis16350_id[] = {
703 {"adis16350", 0},
704 {"adis16354", 0},
705 {"adis16355", 0},
706 {"adis16360", 0},
707 {"adis16362", 0},
708 {"adis16364", 0},
709 {"adis16365", 0},
713 static struct spi_driver adis16350_driver = {
714 .driver = {
715 .name = "adis16350",
716 .owner = THIS_MODULE,
718 .probe = adis16350_probe,
719 .remove = __devexit_p(adis16350_remove),
720 .id_table = adis16350_id,
723 static __init int adis16350_init(void)
725 return spi_register_driver(&adis16350_driver);
727 module_init(adis16350_init);
729 static __exit void adis16350_exit(void)
731 spi_unregister_driver(&adis16350_driver);
733 module_exit(adis16350_exit);
735 MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
736 MODULE_DESCRIPTION("Analog Devices ADIS16350/54/55/60/62/64/65 IMU SPI driver");
737 MODULE_LICENSE("GPL v2");