aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Brugger <mensch0815@googlemail.com>2010-05-07 15:39:56 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-11 17:46:03 -0400
commite390b07bc50fc96caa15c594374782e472c27419 (patch)
tree8f109dec519e84f812eb84dbea1983cfcc85e411
parent2c834b4d2d30c8f8ae5365a66c50da95aed7b7ea (diff)
staging: adis16255 - TODO issues resolved and typos removed
This patch adds the adis16255 driver to the build system under the staging directory. It solves also most issues mentioned in TODO list: - sample rate exported to sysfs - spi_adis16255_bringup and spi_adis16255_shutdown encapsulated - chip selftest in spi_adis16255_bringup - kernel messages reduced to a reasonable number I removed the TODO file, because ther was only the reset of the gyroscope left. This is IMOH not necessary for the actual driver. There are also some typos in adis.c file. This patch should get rid of them as well. Signed-off-by: Matthias Brugger <mensch0815@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/Kconfig2
-rw-r--r--drivers/staging/Makefile1
-rw-r--r--drivers/staging/adis16255/Kconfig10
-rw-r--r--drivers/staging/adis16255/Makefile2
-rw-r--r--drivers/staging/adis16255/TODO8
-rw-r--r--drivers/staging/adis16255/adis16255.c354
6 files changed, 222 insertions, 155 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index e062b092073..06d3b10d2a1 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -137,5 +137,7 @@ source "drivers/staging/cxt1e1/Kconfig"
137 137
138source "drivers/staging/ti-st/Kconfig" 138source "drivers/staging/ti-st/Kconfig"
139 139
140source "drivers/staging/adis16255/Kconfig"
141
140endif # !STAGING_EXCLUDE_BUILD 142endif # !STAGING_EXCLUDE_BUILD
141endif # STAGING 143endif # STAGING
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 097c158d91f..5526870777c 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -49,3 +49,4 @@ obj-$(CONFIG_VIDEO_DT3155) += dt3155v4l/
49obj-$(CONFIG_CRYSTALHD) += crystalhd/ 49obj-$(CONFIG_CRYSTALHD) += crystalhd/
50obj-$(CONFIG_CXT1E1) += cxt1e1/ 50obj-$(CONFIG_CXT1E1) += cxt1e1/
51obj-$(CONFIG_TI_ST) += ti-st/ 51obj-$(CONFIG_TI_ST) += ti-st/
52obj-$(CONFIG_ADIS16255)) += adis16255/
diff --git a/drivers/staging/adis16255/Kconfig b/drivers/staging/adis16255/Kconfig
index 3952cf95b78..a642be66ade 100644
--- a/drivers/staging/adis16255/Kconfig
+++ b/drivers/staging/adis16255/Kconfig
@@ -2,8 +2,10 @@ config ADIS16255
2 tristate "Ananlog Devices ADIS16250/16255" 2 tristate "Ananlog Devices ADIS16250/16255"
3 depends on SPI && SYSFS 3 depends on SPI && SYSFS
4 ---help--- 4 ---help---
5 If you say yes here you get support for the Analog Devices 5 If you say yes here you get support for the Analog Devices
6 ADIS16250/16255 Low Power Gyroscope. 6 ADIS16250/16255 Low Power Gyroscope. The driver exposes
7 orientation and gyroscope value, as well as sample rate
8 to the sysfs.
7 9
8 This driver can also be built as a module. If so, the module 10 This driver can also be built as a module. If so, the module
9 will be called adis16255. 11 will be called adis16255.
diff --git a/drivers/staging/adis16255/Makefile b/drivers/staging/adis16255/Makefile
index 8057372d378..8c3908106bf 100644
--- a/drivers/staging/adis16255/Makefile
+++ b/drivers/staging/adis16255/Makefile
@@ -1 +1 @@
obj-$(CONFIG_ADIS16255) += adis1625.o obj-$(CONFIG_ADIS16255) += adis16255.o
diff --git a/drivers/staging/adis16255/TODO b/drivers/staging/adis16255/TODO
deleted file mode 100644
index 31e4ac3bdb6..00000000000
--- a/drivers/staging/adis16255/TODO
+++ /dev/null
@@ -1,8 +0,0 @@
1* sample rate changeable or at least readable from sysfs
2* reset gyroscope
3* encapsulate adis_init and adis_turn_off
4* AD_CHK deletion
5* chip selftest in adis_init
6* reduce kernel messages to reasonable amount
7
8Contact: Matthias Brugger <mensch0815@gmail.com>
diff --git a/drivers/staging/adis16255/adis16255.c b/drivers/staging/adis16255/adis16255.c
index 8d110692a03..1ba11f00b2e 100644
--- a/drivers/staging/adis16255/adis16255.c
+++ b/drivers/staging/adis16255/adis16255.c
@@ -21,6 +21,14 @@
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */ 22 */
23 23
24/*
25 * The driver just has a bare interface to the sysfs (sample rate in Hz,
26 * orientation (x, y, z) and gyroscope data in °/sec.
27 *
28 * It should be added to iio subsystem when this has left staging.
29 *
30 */
31
24#include <linux/init.h> 32#include <linux/init.h>
25#include <linux/module.h> 33#include <linux/module.h>
26#include <linux/device.h> 34#include <linux/device.h>
@@ -62,14 +70,13 @@
62 * @data: Last read data from device. 70 * @data: Last read data from device.
63 * @irq_adis: GPIO Number of IRQ signal 71 * @irq_adis: GPIO Number of IRQ signal
64 * @irq: irq line manage by kernel 72 * @irq: irq line manage by kernel
65 * @negative: indicates if sensor is upside down (negative ÿ1) 73 * @negative: indicates if sensor is upside down (negative == 1)
66 * @direction: indicates axis (x, y, z) the sensor is meassuring 74 * @direction: indicates axis (x, y, z) the sensor is meassuring
67 */ 75 */
68struct spi_adis16255_data { 76struct spi_adis16255_data {
69 struct device dev; 77 struct device dev;
70 struct spi_device *spi; 78 struct spi_device *spi;
71 s16 data; 79 s16 data;
72 int irq_adis;
73 int irq; 80 int irq;
74 u8 negative; 81 u8 negative;
75 char direction; 82 char direction;
@@ -81,47 +88,44 @@ static int spi_adis16255_read_data(struct spi_adis16255_data *spiadis,
81 u8 adr, 88 u8 adr,
82 u8 *rbuf) 89 u8 *rbuf)
83{ 90{
84 struct spi_device *spi ÿpiadis->spi; 91 struct spi_device *spi = spiadis->spi;
85 struct spi_message msg; 92 struct spi_message msg;
86 struct spi_transfer xfer1, xfer2; 93 struct spi_transfer xfer1, xfer2;
87 u8 *buf, *rx; 94 u8 *buf, *rx;
88 int ret; 95 int ret;
89 96
90 buf ÿmalloc(4, GFP_KERNEL); 97 buf = kzalloc(4, GFP_KERNEL);
91 if (buf ÿNULL) 98 if (buf == NULL)
92 return -ENOMEM; 99 return -ENOMEM;
93 100
94 rx ÿzalloc(4, GFP_KERNEL); 101 rx = kzalloc(4, GFP_KERNEL);
95 if (rx ÿNULL) { 102 if (rx == NULL) {
96 ret ÿENOMEM; 103 ret = -ENOMEM;
97 goto err_buf; 104 goto err_buf;
98 } 105 }
99 106
100 buf[0] údr; 107 buf[0] = adr;
101 buf[1] ðx00;
102 buf[2] ðx00;
103 buf[3] ðx00;
104 108
105 spi_message_init(&msg); 109 spi_message_init(&msg);
106 memset(&xfer1, 0, sizeof(xfer1)); 110 memset(&xfer1, 0, sizeof(xfer1));
107 memset(&xfer2, 0, sizeof(xfer2)); 111 memset(&xfer2, 0, sizeof(xfer2));
108 112
109 xfer1.tx_buf ûuf; 113 xfer1.tx_buf = buf;
110 xfer1.rx_buf ûuf + 2; 114 xfer1.rx_buf = buf + 2;
111 xfer1.len ò; 115 xfer1.len = 2;
112 xfer1.delay_usecs ù; 116 xfer1.delay_usecs = 9;
113 117
114 xfer2.tx_buf ÿx + 2; 118 xfer2.tx_buf = rx + 2;
115 xfer2.rx_buf ÿx; 119 xfer2.rx_buf = rx;
116 xfer2.len ò; 120 xfer2.len = 2;
117 121
118 spi_message_add_tail(&xfer1, &msg); 122 spi_message_add_tail(&xfer1, &msg);
119 spi_message_add_tail(&xfer2, &msg); 123 spi_message_add_tail(&xfer2, &msg);
120 124
121 ret ÿpi_sync(spi, &msg); 125 ret = spi_sync(spi, &msg);
122 if (ret ÿ0) { 126 if (ret == 0) {
123 rbuf[0] ÿx[0]; 127 rbuf[0] = rx[0];
124 rbuf[1] ÿx[1]; 128 rbuf[1] = rx[1];
125 } 129 }
126 130
127 kfree(rx); 131 kfree(rx);
@@ -136,19 +140,19 @@ static int spi_adis16255_write_data(struct spi_adis16255_data *spiadis,
136 u8 adr2, 140 u8 adr2,
137 u8 *wbuf) 141 u8 *wbuf)
138{ 142{
139 struct spi_device *spi ÿpiadis->spi; 143 struct spi_device *spi = spiadis->spi;
140 struct spi_message msg; 144 struct spi_message msg;
141 struct spi_transfer xfer1, xfer2; 145 struct spi_transfer xfer1, xfer2;
142 u8 *buf, *rx; 146 u8 *buf, *rx;
143 int ret; 147 int ret;
144 148
145 buf ÿmalloc(4, GFP_KERNEL); 149 buf = kmalloc(4, GFP_KERNEL);
146 if (buf ÿNULL) 150 if (buf == NULL)
147 return -ENOMEM; 151 return -ENOMEM;
148 152
149 rx ÿzalloc(4, GFP_KERNEL); 153 rx = kzalloc(4, GFP_KERNEL);
150 if (rx ÿNULL) { 154 if (rx == NULL) {
151 ret ÿENOMEM; 155 ret = -ENOMEM;
152 goto err_buf; 156 goto err_buf;
153 } 157 }
154 158
@@ -156,27 +160,27 @@ static int spi_adis16255_write_data(struct spi_adis16255_data *spiadis,
156 memset(&xfer1, 0, sizeof(xfer1)); 160 memset(&xfer1, 0, sizeof(xfer1));
157 memset(&xfer2, 0, sizeof(xfer2)); 161 memset(&xfer2, 0, sizeof(xfer2));
158 162
159 buf[0] údr1 | 0x80; 163 buf[0] = adr1 | 0x80;
160 buf[1] ÿwbuf; 164 buf[1] = *wbuf;
161 165
162 buf[2] údr2 | 0x80; 166 buf[2] = adr2 | 0x80;
163 buf[3] ÿ(wbuf + 1); 167 buf[3] = *(wbuf + 1);
164 168
165 xfer1.tx_buf ûuf; 169 xfer1.tx_buf = buf;
166 xfer1.rx_buf ÿx; 170 xfer1.rx_buf = rx;
167 xfer1.len ò; 171 xfer1.len = 2;
168 xfer1.delay_usecs ù; 172 xfer1.delay_usecs = 9;
169 173
170 xfer2.tx_buf ûuf+2; 174 xfer2.tx_buf = buf+2;
171 xfer2.rx_buf ÿx+2; 175 xfer2.rx_buf = rx+2;
172 xfer2.len ò; 176 xfer2.len = 2;
173 177
174 spi_message_add_tail(&xfer1, &msg); 178 spi_message_add_tail(&xfer1, &msg);
175 spi_message_add_tail(&xfer2, &msg); 179 spi_message_add_tail(&xfer2, &msg);
176 180
177 ret ÿpi_sync(spi, &msg); 181 ret = spi_sync(spi, &msg);
178 if (ret !ð) 182 if (ret != 0)
179 dev_warn(&spi->dev, "wirte data to %#x %#x failed\n", 183 dev_warn(&spi->dev, "write data to %#x %#x failed\n",
180 buf[0], buf[2]); 184 buf[0], buf[2]);
181 185
182 kfree(rx); 186 kfree(rx);
@@ -189,29 +193,31 @@ err_buf:
189 193
190static irqreturn_t adis_irq_thread(int irq, void *dev_id) 194static irqreturn_t adis_irq_thread(int irq, void *dev_id)
191{ 195{
192 struct spi_adis16255_data *spiadis ýev_id; 196 struct spi_adis16255_data *spiadis = dev_id;
193 int status; 197 int status;
194 u16 value; 198 u16 value = 0;
195 199
196 status ÿspi_adis16255_read_data(spiadis, ADIS_GYRO_OUT, (u8 *)&value); 200 status = spi_adis16255_read_data(spiadis, ADIS_GYRO_OUT, (u8 *)&value);
197 if (status ÿ0) { 201 if (status != 0) {
198 /* perform on new data only... */
199 if (value & 0x8000) {
200 /* delete error and new data bit */
201 value ÿalue & 0x3fff;
202 /* set negative value */
203 if (value & 0x2000)
204 value ÿalue | 0xe000;
205
206 if (likely(spiadis->negative))
207 value ÿvalue;
208
209 spiadis->data ÿs16) value;
210 }
211 } else {
212 dev_warn(&spiadis->spi->dev, "SPI FAILED\n"); 202 dev_warn(&spiadis->spi->dev, "SPI FAILED\n");
203 goto exit;
213 } 204 }
214 205
206 /* perform on new data only... */
207 if (value & 0x8000) {
208 /* delete error and new data bit */
209 value = value & 0x3fff;
210 /* set negative value */
211 if (value & 0x2000)
212 value = value | 0xe000;
213
214 if (likely(spiadis->negative))
215 value = -value;
216
217 spiadis->data = (s16) value;
218 }
219
220exit:
215 return IRQ_HANDLED; 221 return IRQ_HANDLED;
216} 222}
217 223
@@ -221,7 +227,7 @@ ssize_t adis16255_show_data(struct device *device,
221 struct device_attribute *da, 227 struct device_attribute *da,
222 char *buf) 228 char *buf)
223{ 229{
224 struct spi_adis16255_data *spiadis ýev_get_drvdata(device); 230 struct spi_adis16255_data *spiadis = dev_get_drvdata(device);
225 return snprintf(buf, PAGE_SIZE, "%d\n", spiadis->data); 231 return snprintf(buf, PAGE_SIZE, "%d\n", spiadis->data);
226} 232}
227DEVICE_ATTR(data, S_IRUGO , adis16255_show_data, NULL); 233DEVICE_ATTR(data, S_IRUGO , adis16255_show_data, NULL);
@@ -230,112 +236,186 @@ ssize_t adis16255_show_direction(struct device *device,
230 struct device_attribute *da, 236 struct device_attribute *da,
231 char *buf) 237 char *buf)
232{ 238{
233 struct spi_adis16255_data *spiadis ýev_get_drvdata(device); 239 struct spi_adis16255_data *spiadis = dev_get_drvdata(device);
234 return snprintf(buf, PAGE_SIZE, "%c\n", spiadis->direction); 240 return snprintf(buf, PAGE_SIZE, "%c\n", spiadis->direction);
235} 241}
236DEVICE_ATTR(direction, S_IRUGO , adis16255_show_direction, NULL); 242DEVICE_ATTR(direction, S_IRUGO , adis16255_show_direction, NULL);
237 243
238static struct attribute *adis16255_attributes[] ÿ 244ssize_t adis16255_show_sample_rate(struct device *device,
245 struct device_attribute *da,
246 char *buf)
247{
248 struct spi_adis16255_data *spiadis = dev_get_drvdata(device);
249 int status = 0;
250 u16 value = 0;
251 int ts = 0;
252
253 status = spi_adis16255_read_data(spiadis, ADIS_SMPL_PRD_MSB,
254 (u8 *)&value);
255 if (status != 0)
256 return -EINVAL;
257
258 if (value & 0x80) {
259 /* timebase = 60.54 ms */
260 ts = 60540 * ((0x7f & value) + 1);
261 } else {
262 /* timebase = 1.953 ms */
263 ts = 1953 * ((0x7f & value) + 1);
264 }
265
266 return snprintf(buf, PAGE_SIZE, "%d\n", (1000*1000)/ts);
267}
268DEVICE_ATTR(sample_rate, S_IRUGO , adis16255_show_sample_rate, NULL);
269
270static struct attribute *adis16255_attributes[] = {
239 &dev_attr_data.attr, 271 &dev_attr_data.attr,
240 &dev_attr_direction.attr, 272 &dev_attr_direction.attr,
273 &dev_attr_sample_rate.attr,
241 NULL 274 NULL
242}; 275};
243 276
244static const struct attribute_group adis16255_attr_group ÿ 277static const struct attribute_group adis16255_attr_group = {
245 .attrs údis16255_attributes, 278 .attrs = adis16255_attributes,
246}; 279};
247 280
248/*-------------------------------------------------------------------------*/ 281/*-------------------------------------------------------------------------*/
249 282
250static int spi_adis16255_probe(struct spi_device *spi) 283static int spi_adis16255_shutdown(struct spi_adis16255_data *spiadis)
284{
285 u16 value = 0;
286 /* turn sensor off */
287 spi_adis16255_write_data(spiadis,
288 ADIS_SMPL_PRD_MSB, ADIS_SMPL_PRD_LSB,
289 (u8 *)&value);
290 spi_adis16255_write_data(spiadis,
291 ADIS_MSC_CTRL_MSB, ADIS_MSC_CTRL_LSB,
292 (u8 *)&value);
293 return 0;
294}
295
296static int spi_adis16255_bringup(struct spi_adis16255_data *spiadis)
251{ 297{
298 int status = 0;
299 u16 value = 0;
300
301 status = spi_adis16255_read_data(spiadis, ADIS_GYRO_SCALE,
302 (u8 *)&value);
303 if (status != 0)
304 goto err;
305 if (value != 0x0800) {
306 dev_warn(&spiadis->spi->dev, "Scale factor is none default"
307 "value (%.4x)\n", value);
308 }
309
310 /* timebase = 1.953 ms, Ns = 0 -> 512 Hz sample rate */
311 value = 0x0001;
312 status = spi_adis16255_write_data(spiadis,
313 ADIS_SMPL_PRD_MSB, ADIS_SMPL_PRD_LSB,
314 (u8 *)&value);
315 if (status != 0)
316 goto err;
317
318 /* start internal self-test */
319 value = 0x0400;
320 status = spi_adis16255_write_data(spiadis,
321 ADIS_MSC_CTRL_MSB, ADIS_MSC_CTRL_LSB,
322 (u8 *)&value);
323 if (status != 0)
324 goto err;
325
326 /* wait 35 ms to finish self-test */
327 msleep(35);
328
329 value = 0x0000;
330 status = spi_adis16255_read_data(spiadis, ADIS_STATUS,
331 (u8 *)&value);
332 if (status != 0)
333 goto err;
334
335 if (value & 0x23) {
336 if (value & 0x20) {
337 dev_warn(&spiadis->spi->dev, "self-test error\n");
338 status = -ENODEV;
339 goto err;
340 } else if (value & 0x3) {
341 dev_warn(&spiadis->spi->dev, "Sensor voltage"
342 "out of range.\n");
343 status = -ENODEV;
344 goto err;
345 }
346 }
252 347
253#define AD_CHK(_ss)\ 348 /* set interrupt to active high on DIO0 when data ready */
254 do {\ 349 value = 0x0006;
255 status ÿss;\ 350 status = spi_adis16255_write_data(spiadis,
256 if (status !ð)\ 351 ADIS_MSC_CTRL_MSB, ADIS_MSC_CTRL_LSB,
257 goto irq_err;\ 352 (u8 *)&value);
258 } while (0); 353 if (status != 0)
354 goto err;
355 return status;
356
357err:
358 spi_adis16255_shutdown(spiadis);
359 return status;
360}
361
362/*-------------------------------------------------------------------------*/
259 363
260 struct adis16255_init_data *init_data ÿpi->dev.platform_data; 364static int spi_adis16255_probe(struct spi_device *spi)
365{
366
367 struct adis16255_init_data *init_data = spi->dev.platform_data;
261 struct spi_adis16255_data *spiadis; 368 struct spi_adis16255_data *spiadis;
262 int status ð; 369 int status = 0;
263 u16 value;
264 370
265 spiadis ÿzalloc(sizeof(*spiadis), GFP_KERNEL); 371 spiadis = kzalloc(sizeof(*spiadis), GFP_KERNEL);
266 if (!spiadis) 372 if (!spiadis)
267 return -ENOMEM; 373 return -ENOMEM;
268 374
269 spiadis->spi ÿpi; 375 spiadis->spi = spi;
270 spiadis->irq_adis ÿnit_data->irq; 376 spiadis->direction = init_data->direction;
271 spiadis->direction ÿnit_data->direction;
272 377
273 if (init_data->negative) 378 if (init_data->negative)
274 spiadis->negative ñ; 379 spiadis->negative = 1;
275 380
276 status ÿpio_request(spiadis->irq_adis, "adis16255"); 381 status = gpio_request(init_data->irq, "adis16255");
277 if (status !ð) 382 if (status != 0)
278 goto err; 383 goto err;
279 384
280 status ÿpio_direction_input(spiadis->irq_adis); 385 status = gpio_direction_input(init_data->irq);
281 if (status !ð) 386 if (status != 0)
282 goto gpio_err; 387 goto gpio_err;
283 388
284 spiadis->irq ÿpio_to_irq(spiadis->irq_adis); 389 spiadis->irq = gpio_to_irq(init_data->irq);
285 390
286 status ÿequest_threaded_irq(spiadis->irq, 391 status = request_threaded_irq(spiadis->irq,
287 NULL, adis_irq_thread, 392 NULL, adis_irq_thread,
288 IRQF_DISABLED, "adis-driver", spiadis); 393 IRQF_DISABLED, "adis-driver", spiadis);
289 394
290 if (status !ð) { 395 if (status != 0) {
291 dev_err(&spi->dev, "IRQ request failed\n"); 396 dev_err(&spi->dev, "IRQ request failed\n");
292 goto gpio_err; 397 goto gpio_err;
293 } 398 }
294 399
295 dev_dbg(&spi->dev, "GPIO %d IRQ %d\n", spiadis->irq_adis, spiadis->irq); 400 dev_dbg(&spi->dev, "GPIO %d IRQ %d\n", init_data->irq, spiadis->irq);
296 401
297 dev_set_drvdata(&spi->dev, spiadis); 402 dev_set_drvdata(&spi->dev, spiadis);
298 AD_CHK(sysfs_create_group(&spi->dev.kobj, &adis16255_attr_group)); 403 status = sysfs_create_group(&spi->dev.kobj, &adis16255_attr_group);
299 404 if (status != 0)
300 dev_info(&spi->dev, "spi_adis16255 driver added!\n"); 405 goto irq_err;
301 406
302 AD_CHK(spi_adis16255_read_data(spiadis, ADIS_SUPPLY_OUT, (u8 *)&value)); 407 status = spi_adis16255_bringup(spiadis);
303 dev_info(&spi->dev, "sensor works with %d mV (%.4x)!\n", 408 if (status != 0)
304 ((value & 0x0fff)*18315)/10000, 409 goto irq_err;
305 (value & 0x0fff));
306 410
307 AD_CHK(spi_adis16255_read_data(spiadis, ADIS_GYRO_SCALE, (u8 *)&value)); 411 dev_info(&spi->dev, "spi_adis16255 driver added!\n");
308 dev_info(&spi->dev, "adis GYRO_SCALE is %.4x\n", value);
309
310 AD_CHK(spi_adis16255_read_data(spiadis, ADIS_STATUS, (u8 *)&value));
311 dev_info(&spi->dev, "adis STATUS is %.4x\n", value);
312
313 /* timebase ñ.953 ms, Ns ð -> 512 Hz sample rate */
314 value ÿ0x0001;
315 AD_CHK(spi_adis16255_write_data(spiadis,
316 ADIS_SMPL_PRD_MSB, ADIS_SMPL_PRD_LSB,
317 (u8 *)&value));
318 value ðx0000;
319 AD_CHK(spi_adis16255_read_data(spiadis, ADIS_SMPL_PRD_MSB,
320 (u8 *)&value));
321 dev_info(&spi->dev, "adis SMP_PRD is %.4x\n", value);
322
323 /* set interrupt on new data... */
324 value ðx0006;
325 AD_CHK(spi_adis16255_write_data(spiadis,
326 ADIS_MSC_CTRL_MSB, ADIS_MSC_CTRL_LSB,
327 (u8 *)&value));
328 value ðx0000;
329 AD_CHK(spi_adis16255_read_data(spiadis, ADIS_MSC_CTRL_MSB,
330 (u8 *)&value));
331 dev_info(&spi->dev, "adis MSC_CONTROL is %.4x\n", value);
332 412
333 return status; 413 return status;
334 414
335irq_err: 415irq_err:
336 free_irq(spiadis->irq, spiadis); 416 free_irq(spiadis->irq, spiadis);
337gpio_err: 417gpio_err:
338 gpio_free(spiadis->irq_adis); 418 gpio_free(init_data->irq);
339err: 419err:
340 kfree(spiadis); 420 kfree(spiadis);
341 return status; 421 return status;
@@ -343,22 +423,12 @@ err:
343 423
344static int spi_adis16255_remove(struct spi_device *spi) 424static int spi_adis16255_remove(struct spi_device *spi)
345{ 425{
346 u16 value ð; 426 struct spi_adis16255_data *spiadis = dev_get_drvdata(&spi->dev);
347 struct spi_adis16255_data *spiadis ýev_get_drvdata(&spi->dev);
348
349 /* turn sensor off */
350 spi_adis16255_write_data(spiadis,
351 ADIS_SMPL_PRD_MSB, ADIS_SMPL_PRD_LSB,
352 (u8 *)&value);
353 spi_adis16255_write_data(spiadis,
354 ADIS_MSC_CTRL_MSB, ADIS_MSC_CTRL_LSB,
355 (u8 *)&value);
356 427
357 dev_info(&spi->dev, "unregister: GPIO %d IRQ %d\n", 428 spi_adis16255_shutdown(spiadis);
358 spiadis->irq_adis, spiadis->irq);
359 429
360 free_irq(spiadis->irq, spiadis); 430 free_irq(spiadis->irq, spiadis);
361 gpio_free(spiadis->irq_adis); 431 gpio_free(irq_to_gpio(spiadis->irq));
362 432
363 sysfs_remove_group(&spiadis->spi->dev.kobj, &adis16255_attr_group); 433 sysfs_remove_group(&spiadis->spi->dev.kobj, &adis16255_attr_group);
364 434
@@ -368,13 +438,13 @@ static int spi_adis16255_remove(struct spi_device *spi)
368 return 0; 438 return 0;
369} 439}
370 440
371static struct spi_driver spi_adis16255_drv ÿ 441static struct spi_driver spi_adis16255_drv = {
372 .driver ÿ 442 .driver = {
373 .name ÿ"spi_adis16255", 443 .name = "spi_adis16255",
374 .owner ÿHIS_MODULE, 444 .owner = THIS_MODULE,
375 }, 445 },
376 .probe ÿpi_adis16255_probe, 446 .probe = spi_adis16255_probe,
377 .remove ÿ __devexit_p(spi_adis16255_remove), 447 .remove = __devexit_p(spi_adis16255_remove),
378}; 448};
379 449
380/*-------------------------------------------------------------------------*/ 450/*-------------------------------------------------------------------------*/