diff options
| author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
|---|---|---|
| committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
| commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
| tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/input/touchscreen/ad7877.c | |
| parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
| parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) | |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/input/touchscreen/ad7877.c')
| -rw-r--r-- | drivers/input/touchscreen/ad7877.c | 163 |
1 files changed, 90 insertions, 73 deletions
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c index 5f0221cffef9..714d4e0f9f95 100644 --- a/drivers/input/touchscreen/ad7877.c +++ b/drivers/input/touchscreen/ad7877.c | |||
| @@ -41,6 +41,7 @@ | |||
| 41 | #include <linux/delay.h> | 41 | #include <linux/delay.h> |
| 42 | #include <linux/input.h> | 42 | #include <linux/input.h> |
| 43 | #include <linux/interrupt.h> | 43 | #include <linux/interrupt.h> |
| 44 | #include <linux/pm.h> | ||
| 44 | #include <linux/slab.h> | 45 | #include <linux/slab.h> |
| 45 | #include <linux/spi/spi.h> | 46 | #include <linux/spi/spi.h> |
| 46 | #include <linux/spi/ad7877.h> | 47 | #include <linux/spi/ad7877.h> |
| @@ -191,13 +192,12 @@ struct ad7877 { | |||
| 191 | struct spi_message msg; | 192 | struct spi_message msg; |
| 192 | 193 | ||
| 193 | struct mutex mutex; | 194 | struct mutex mutex; |
| 194 | unsigned disabled:1; /* P: mutex */ | 195 | bool disabled; /* P: mutex */ |
| 195 | unsigned gpio3:1; /* P: mutex */ | 196 | bool gpio3; /* P: mutex */ |
| 196 | unsigned gpio4:1; /* P: mutex */ | 197 | bool gpio4; /* P: mutex */ |
| 197 | 198 | ||
| 198 | spinlock_t lock; | 199 | spinlock_t lock; |
| 199 | struct timer_list timer; /* P: lock */ | 200 | struct timer_list timer; /* P: lock */ |
| 200 | unsigned pending:1; /* P: lock */ | ||
| 201 | 201 | ||
| 202 | /* | 202 | /* |
| 203 | * DMA (thus cache coherency maintenance) requires the | 203 | * DMA (thus cache coherency maintenance) requires the |
| @@ -206,8 +206,8 @@ struct ad7877 { | |||
| 206 | u16 conversion_data[AD7877_NR_SENSE] ____cacheline_aligned; | 206 | u16 conversion_data[AD7877_NR_SENSE] ____cacheline_aligned; |
| 207 | }; | 207 | }; |
| 208 | 208 | ||
| 209 | static int gpio3; | 209 | static bool gpio3; |
| 210 | module_param(gpio3, int, 0); | 210 | module_param(gpio3, bool, 0); |
| 211 | MODULE_PARM_DESC(gpio3, "If gpio3 is set to 1 AUX3 acts as GPIO3"); | 211 | MODULE_PARM_DESC(gpio3, "If gpio3 is set to 1 AUX3 acts as GPIO3"); |
| 212 | 212 | ||
| 213 | /* | 213 | /* |
| @@ -230,6 +230,7 @@ static int ad7877_read(struct spi_device *spi, u16 reg) | |||
| 230 | AD7877_READADD(reg)); | 230 | AD7877_READADD(reg)); |
| 231 | req->xfer[0].tx_buf = &req->command; | 231 | req->xfer[0].tx_buf = &req->command; |
| 232 | req->xfer[0].len = 2; | 232 | req->xfer[0].len = 2; |
| 233 | req->xfer[0].cs_change = 1; | ||
| 233 | 234 | ||
| 234 | req->xfer[1].rx_buf = &req->sample; | 235 | req->xfer[1].rx_buf = &req->sample; |
| 235 | req->xfer[1].len = 2; | 236 | req->xfer[1].len = 2; |
| @@ -295,20 +296,25 @@ static int ad7877_read_adc(struct spi_device *spi, unsigned command) | |||
| 295 | 296 | ||
| 296 | req->xfer[0].tx_buf = &req->reset; | 297 | req->xfer[0].tx_buf = &req->reset; |
| 297 | req->xfer[0].len = 2; | 298 | req->xfer[0].len = 2; |
| 299 | req->xfer[0].cs_change = 1; | ||
| 298 | 300 | ||
| 299 | req->xfer[1].tx_buf = &req->ref_on; | 301 | req->xfer[1].tx_buf = &req->ref_on; |
| 300 | req->xfer[1].len = 2; | 302 | req->xfer[1].len = 2; |
| 301 | req->xfer[1].delay_usecs = ts->vref_delay_usecs; | 303 | req->xfer[1].delay_usecs = ts->vref_delay_usecs; |
| 304 | req->xfer[1].cs_change = 1; | ||
| 302 | 305 | ||
| 303 | req->xfer[2].tx_buf = &req->command; | 306 | req->xfer[2].tx_buf = &req->command; |
| 304 | req->xfer[2].len = 2; | 307 | req->xfer[2].len = 2; |
| 305 | req->xfer[2].delay_usecs = ts->vref_delay_usecs; | 308 | req->xfer[2].delay_usecs = ts->vref_delay_usecs; |
| 309 | req->xfer[2].cs_change = 1; | ||
| 306 | 310 | ||
| 307 | req->xfer[3].rx_buf = &req->sample; | 311 | req->xfer[3].rx_buf = &req->sample; |
| 308 | req->xfer[3].len = 2; | 312 | req->xfer[3].len = 2; |
| 313 | req->xfer[3].cs_change = 1; | ||
| 309 | 314 | ||
| 310 | req->xfer[4].tx_buf = &ts->cmd_crtl2; /*REF OFF*/ | 315 | req->xfer[4].tx_buf = &ts->cmd_crtl2; /*REF OFF*/ |
| 311 | req->xfer[4].len = 2; | 316 | req->xfer[4].len = 2; |
| 317 | req->xfer[4].cs_change = 1; | ||
| 312 | 318 | ||
| 313 | req->xfer[5].tx_buf = &ts->cmd_crtl1; /*DEFAULT*/ | 319 | req->xfer[5].tx_buf = &ts->cmd_crtl1; /*DEFAULT*/ |
| 314 | req->xfer[5].len = 2; | 320 | req->xfer[5].len = 2; |
| @@ -327,7 +333,7 @@ static int ad7877_read_adc(struct spi_device *spi, unsigned command) | |||
| 327 | return status ? : sample; | 333 | return status ? : sample; |
| 328 | } | 334 | } |
| 329 | 335 | ||
| 330 | static void ad7877_rx(struct ad7877 *ts) | 336 | static int ad7877_process_data(struct ad7877 *ts) |
| 331 | { | 337 | { |
| 332 | struct input_dev *input_dev = ts->input; | 338 | struct input_dev *input_dev = ts->input; |
| 333 | unsigned Rt; | 339 | unsigned Rt; |
| @@ -354,11 +360,25 @@ static void ad7877_rx(struct ad7877 *ts) | |||
| 354 | Rt /= z1; | 360 | Rt /= z1; |
| 355 | Rt = (Rt + 2047) >> 12; | 361 | Rt = (Rt + 2047) >> 12; |
| 356 | 362 | ||
| 363 | /* | ||
| 364 | * Sample found inconsistent, pressure is beyond | ||
| 365 | * the maximum. Don't report it to user space. | ||
| 366 | */ | ||
| 367 | if (Rt > ts->pressure_max) | ||
| 368 | return -EINVAL; | ||
| 369 | |||
| 370 | if (!timer_pending(&ts->timer)) | ||
| 371 | input_report_key(input_dev, BTN_TOUCH, 1); | ||
| 372 | |||
| 357 | input_report_abs(input_dev, ABS_X, x); | 373 | input_report_abs(input_dev, ABS_X, x); |
| 358 | input_report_abs(input_dev, ABS_Y, y); | 374 | input_report_abs(input_dev, ABS_Y, y); |
| 359 | input_report_abs(input_dev, ABS_PRESSURE, Rt); | 375 | input_report_abs(input_dev, ABS_PRESSURE, Rt); |
| 360 | input_sync(input_dev); | 376 | input_sync(input_dev); |
| 377 | |||
| 378 | return 0; | ||
| 361 | } | 379 | } |
| 380 | |||
| 381 | return -EINVAL; | ||
| 362 | } | 382 | } |
| 363 | 383 | ||
| 364 | static inline void ad7877_ts_event_release(struct ad7877 *ts) | 384 | static inline void ad7877_ts_event_release(struct ad7877 *ts) |
| @@ -366,72 +386,56 @@ static inline void ad7877_ts_event_release(struct ad7877 *ts) | |||
| 366 | struct input_dev *input_dev = ts->input; | 386 | struct input_dev *input_dev = ts->input; |
| 367 | 387 | ||
| 368 | input_report_abs(input_dev, ABS_PRESSURE, 0); | 388 | input_report_abs(input_dev, ABS_PRESSURE, 0); |
| 389 | input_report_key(input_dev, BTN_TOUCH, 0); | ||
| 369 | input_sync(input_dev); | 390 | input_sync(input_dev); |
| 370 | } | 391 | } |
| 371 | 392 | ||
| 372 | static void ad7877_timer(unsigned long handle) | 393 | static void ad7877_timer(unsigned long handle) |
| 373 | { | 394 | { |
| 374 | struct ad7877 *ts = (void *)handle; | 395 | struct ad7877 *ts = (void *)handle; |
| 396 | unsigned long flags; | ||
| 375 | 397 | ||
| 398 | spin_lock_irqsave(&ts->lock, flags); | ||
| 376 | ad7877_ts_event_release(ts); | 399 | ad7877_ts_event_release(ts); |
| 400 | spin_unlock_irqrestore(&ts->lock, flags); | ||
| 377 | } | 401 | } |
| 378 | 402 | ||
| 379 | static irqreturn_t ad7877_irq(int irq, void *handle) | 403 | static irqreturn_t ad7877_irq(int irq, void *handle) |
| 380 | { | 404 | { |
| 381 | struct ad7877 *ts = handle; | 405 | struct ad7877 *ts = handle; |
| 382 | unsigned long flags; | 406 | unsigned long flags; |
| 383 | int status; | 407 | int error; |
| 384 | 408 | ||
| 385 | /* | 409 | error = spi_sync(ts->spi, &ts->msg); |
| 386 | * The repeated conversion sequencer controlled by TMR kicked off | 410 | if (error) { |
| 387 | * too fast. We ignore the last and process the sample sequence | 411 | dev_err(&ts->spi->dev, "spi_sync --> %d\n", error); |
| 388 | * currently in the queue. It can't be older than 9.4ms, and we | 412 | goto out; |
| 389 | * need to avoid that ts->msg doesn't get issued twice while in work. | 413 | } |
| 390 | */ | ||
| 391 | 414 | ||
| 392 | spin_lock_irqsave(&ts->lock, flags); | 415 | spin_lock_irqsave(&ts->lock, flags); |
| 393 | if (!ts->pending) { | 416 | error = ad7877_process_data(ts); |
| 394 | ts->pending = 1; | 417 | if (!error) |
| 395 | 418 | mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); | |
| 396 | status = spi_async(ts->spi, &ts->msg); | ||
| 397 | if (status) | ||
| 398 | dev_err(&ts->spi->dev, "spi_sync --> %d\n", status); | ||
| 399 | } | ||
| 400 | spin_unlock_irqrestore(&ts->lock, flags); | 419 | spin_unlock_irqrestore(&ts->lock, flags); |
| 401 | 420 | ||
| 421 | out: | ||
| 402 | return IRQ_HANDLED; | 422 | return IRQ_HANDLED; |
| 403 | } | 423 | } |
| 404 | 424 | ||
| 405 | static void ad7877_callback(void *_ts) | ||
| 406 | { | ||
| 407 | struct ad7877 *ts = _ts; | ||
| 408 | |||
| 409 | spin_lock_irq(&ts->lock); | ||
| 410 | |||
| 411 | ad7877_rx(ts); | ||
| 412 | ts->pending = 0; | ||
| 413 | mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); | ||
| 414 | |||
| 415 | spin_unlock_irq(&ts->lock); | ||
| 416 | } | ||
| 417 | |||
| 418 | static void ad7877_disable(struct ad7877 *ts) | 425 | static void ad7877_disable(struct ad7877 *ts) |
| 419 | { | 426 | { |
| 420 | mutex_lock(&ts->mutex); | 427 | mutex_lock(&ts->mutex); |
| 421 | 428 | ||
| 422 | if (!ts->disabled) { | 429 | if (!ts->disabled) { |
| 423 | ts->disabled = 1; | 430 | ts->disabled = true; |
| 424 | disable_irq(ts->spi->irq); | 431 | disable_irq(ts->spi->irq); |
| 425 | 432 | ||
| 426 | /* Wait for spi_async callback */ | ||
| 427 | while (ts->pending) | ||
| 428 | msleep(1); | ||
| 429 | |||
| 430 | if (del_timer_sync(&ts->timer)) | 433 | if (del_timer_sync(&ts->timer)) |
| 431 | ad7877_ts_event_release(ts); | 434 | ad7877_ts_event_release(ts); |
| 432 | } | 435 | } |
| 433 | 436 | ||
| 434 | /* we know the chip's in lowpower mode since we always | 437 | /* |
| 438 | * We know the chip's in lowpower mode since we always | ||
| 435 | * leave it that way after every request | 439 | * leave it that way after every request |
| 436 | */ | 440 | */ |
| 437 | 441 | ||
| @@ -443,7 +447,7 @@ static void ad7877_enable(struct ad7877 *ts) | |||
| 443 | mutex_lock(&ts->mutex); | 447 | mutex_lock(&ts->mutex); |
| 444 | 448 | ||
| 445 | if (ts->disabled) { | 449 | if (ts->disabled) { |
| 446 | ts->disabled = 0; | 450 | ts->disabled = false; |
| 447 | enable_irq(ts->spi->irq); | 451 | enable_irq(ts->spi->irq); |
| 448 | } | 452 | } |
| 449 | 453 | ||
| @@ -453,7 +457,7 @@ static void ad7877_enable(struct ad7877 *ts) | |||
| 453 | #define SHOW(name) static ssize_t \ | 457 | #define SHOW(name) static ssize_t \ |
| 454 | name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \ | 458 | name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \ |
| 455 | { \ | 459 | { \ |
| 456 | struct ad7877 *ts = dev_get_drvdata(dev); \ | 460 | struct ad7877 *ts = dev_get_drvdata(dev); \ |
| 457 | ssize_t v = ad7877_read_adc(ts->spi, \ | 461 | ssize_t v = ad7877_read_adc(ts->spi, \ |
| 458 | AD7877_READ_CHAN(name)); \ | 462 | AD7877_READ_CHAN(name)); \ |
| 459 | if (v < 0) \ | 463 | if (v < 0) \ |
| @@ -473,7 +477,7 @@ SHOW(temp2) | |||
| 473 | static ssize_t ad7877_disable_show(struct device *dev, | 477 | static ssize_t ad7877_disable_show(struct device *dev, |
| 474 | struct device_attribute *attr, char *buf) | 478 | struct device_attribute *attr, char *buf) |
| 475 | { | 479 | { |
| 476 | struct ad7877 *ts = dev_get_drvdata(dev); | 480 | struct ad7877 *ts = dev_get_drvdata(dev); |
| 477 | 481 | ||
| 478 | return sprintf(buf, "%u\n", ts->disabled); | 482 | return sprintf(buf, "%u\n", ts->disabled); |
| 479 | } | 483 | } |
| @@ -503,7 +507,7 @@ static DEVICE_ATTR(disable, 0664, ad7877_disable_show, ad7877_disable_store); | |||
| 503 | static ssize_t ad7877_dac_show(struct device *dev, | 507 | static ssize_t ad7877_dac_show(struct device *dev, |
| 504 | struct device_attribute *attr, char *buf) | 508 | struct device_attribute *attr, char *buf) |
| 505 | { | 509 | { |
| 506 | struct ad7877 *ts = dev_get_drvdata(dev); | 510 | struct ad7877 *ts = dev_get_drvdata(dev); |
| 507 | 511 | ||
| 508 | return sprintf(buf, "%u\n", ts->dac); | 512 | return sprintf(buf, "%u\n", ts->dac); |
| 509 | } | 513 | } |
| @@ -533,7 +537,7 @@ static DEVICE_ATTR(dac, 0664, ad7877_dac_show, ad7877_dac_store); | |||
| 533 | static ssize_t ad7877_gpio3_show(struct device *dev, | 537 | static ssize_t ad7877_gpio3_show(struct device *dev, |
| 534 | struct device_attribute *attr, char *buf) | 538 | struct device_attribute *attr, char *buf) |
| 535 | { | 539 | { |
| 536 | struct ad7877 *ts = dev_get_drvdata(dev); | 540 | struct ad7877 *ts = dev_get_drvdata(dev); |
| 537 | 541 | ||
| 538 | return sprintf(buf, "%u\n", ts->gpio3); | 542 | return sprintf(buf, "%u\n", ts->gpio3); |
| 539 | } | 543 | } |
| @@ -564,7 +568,7 @@ static DEVICE_ATTR(gpio3, 0664, ad7877_gpio3_show, ad7877_gpio3_store); | |||
| 564 | static ssize_t ad7877_gpio4_show(struct device *dev, | 568 | static ssize_t ad7877_gpio4_show(struct device *dev, |
| 565 | struct device_attribute *attr, char *buf) | 569 | struct device_attribute *attr, char *buf) |
| 566 | { | 570 | { |
| 567 | struct ad7877 *ts = dev_get_drvdata(dev); | 571 | struct ad7877 *ts = dev_get_drvdata(dev); |
| 568 | 572 | ||
| 569 | return sprintf(buf, "%u\n", ts->gpio4); | 573 | return sprintf(buf, "%u\n", ts->gpio4); |
| 570 | } | 574 | } |
| @@ -597,16 +601,35 @@ static struct attribute *ad7877_attributes[] = { | |||
| 597 | &dev_attr_temp2.attr, | 601 | &dev_attr_temp2.attr, |
| 598 | &dev_attr_aux1.attr, | 602 | &dev_attr_aux1.attr, |
| 599 | &dev_attr_aux2.attr, | 603 | &dev_attr_aux2.attr, |
| 604 | &dev_attr_aux3.attr, | ||
| 600 | &dev_attr_bat1.attr, | 605 | &dev_attr_bat1.attr, |
| 601 | &dev_attr_bat2.attr, | 606 | &dev_attr_bat2.attr, |
| 602 | &dev_attr_disable.attr, | 607 | &dev_attr_disable.attr, |
| 603 | &dev_attr_dac.attr, | 608 | &dev_attr_dac.attr, |
| 609 | &dev_attr_gpio3.attr, | ||
| 604 | &dev_attr_gpio4.attr, | 610 | &dev_attr_gpio4.attr, |
| 605 | NULL | 611 | NULL |
| 606 | }; | 612 | }; |
| 607 | 613 | ||
| 614 | static mode_t ad7877_attr_is_visible(struct kobject *kobj, | ||
| 615 | struct attribute *attr, int n) | ||
| 616 | { | ||
| 617 | mode_t mode = attr->mode; | ||
| 618 | |||
| 619 | if (attr == &dev_attr_aux3.attr) { | ||
| 620 | if (gpio3) | ||
| 621 | mode = 0; | ||
| 622 | } else if (attr == &dev_attr_gpio3.attr) { | ||
| 623 | if (!gpio3) | ||
| 624 | mode = 0; | ||
| 625 | } | ||
| 626 | |||
| 627 | return mode; | ||
| 628 | } | ||
| 629 | |||
| 608 | static const struct attribute_group ad7877_attr_group = { | 630 | static const struct attribute_group ad7877_attr_group = { |
| 609 | .attrs = ad7877_attributes, | 631 | .is_visible = ad7877_attr_is_visible, |
| 632 | .attrs = ad7877_attributes, | ||
| 610 | }; | 633 | }; |
| 611 | 634 | ||
| 612 | static void ad7877_setup_ts_def_msg(struct spi_device *spi, struct ad7877 *ts) | 635 | static void ad7877_setup_ts_def_msg(struct spi_device *spi, struct ad7877 *ts) |
| @@ -635,22 +658,25 @@ static void ad7877_setup_ts_def_msg(struct spi_device *spi, struct ad7877 *ts) | |||
| 635 | 658 | ||
| 636 | spi_message_init(m); | 659 | spi_message_init(m); |
| 637 | 660 | ||
| 638 | m->complete = ad7877_callback; | ||
| 639 | m->context = ts; | 661 | m->context = ts; |
| 640 | 662 | ||
| 641 | ts->xfer[0].tx_buf = &ts->cmd_crtl1; | 663 | ts->xfer[0].tx_buf = &ts->cmd_crtl1; |
| 642 | ts->xfer[0].len = 2; | 664 | ts->xfer[0].len = 2; |
| 665 | ts->xfer[0].cs_change = 1; | ||
| 643 | 666 | ||
| 644 | spi_message_add_tail(&ts->xfer[0], m); | 667 | spi_message_add_tail(&ts->xfer[0], m); |
| 645 | 668 | ||
| 646 | ts->xfer[1].tx_buf = &ts->cmd_dummy; /* Send ZERO */ | 669 | ts->xfer[1].tx_buf = &ts->cmd_dummy; /* Send ZERO */ |
| 647 | ts->xfer[1].len = 2; | 670 | ts->xfer[1].len = 2; |
| 671 | ts->xfer[1].cs_change = 1; | ||
| 648 | 672 | ||
| 649 | spi_message_add_tail(&ts->xfer[1], m); | 673 | spi_message_add_tail(&ts->xfer[1], m); |
| 650 | 674 | ||
| 651 | for (i = 0; i < 11; i++) { | 675 | for (i = 0; i < AD7877_NR_SENSE; i++) { |
| 652 | ts->xfer[i + 2].rx_buf = &ts->conversion_data[AD7877_SEQ_YPOS + i]; | 676 | ts->xfer[i + 2].rx_buf = &ts->conversion_data[AD7877_SEQ_YPOS + i]; |
| 653 | ts->xfer[i + 2].len = 2; | 677 | ts->xfer[i + 2].len = 2; |
| 678 | if (i < (AD7877_NR_SENSE - 1)) | ||
| 679 | ts->xfer[i + 2].cs_change = 1; | ||
| 654 | spi_message_add_tail(&ts->xfer[i + 2], m); | 680 | spi_message_add_tail(&ts->xfer[i + 2], m); |
| 655 | } | 681 | } |
| 656 | } | 682 | } |
| @@ -718,6 +744,8 @@ static int __devinit ad7877_probe(struct spi_device *spi) | |||
| 718 | input_dev->phys = ts->phys; | 744 | input_dev->phys = ts->phys; |
| 719 | input_dev->dev.parent = &spi->dev; | 745 | input_dev->dev.parent = &spi->dev; |
| 720 | 746 | ||
| 747 | __set_bit(EV_KEY, input_dev->evbit); | ||
| 748 | __set_bit(BTN_TOUCH, input_dev->keybit); | ||
| 721 | __set_bit(EV_ABS, input_dev->evbit); | 749 | __set_bit(EV_ABS, input_dev->evbit); |
| 722 | __set_bit(ABS_X, input_dev->absbit); | 750 | __set_bit(ABS_X, input_dev->absbit); |
| 723 | __set_bit(ABS_Y, input_dev->absbit); | 751 | __set_bit(ABS_Y, input_dev->absbit); |
| @@ -752,8 +780,9 @@ static int __devinit ad7877_probe(struct spi_device *spi) | |||
| 752 | 780 | ||
| 753 | /* Request AD7877 /DAV GPIO interrupt */ | 781 | /* Request AD7877 /DAV GPIO interrupt */ |
| 754 | 782 | ||
| 755 | err = request_irq(spi->irq, ad7877_irq, IRQF_TRIGGER_FALLING, | 783 | err = request_threaded_irq(spi->irq, NULL, ad7877_irq, |
| 756 | spi->dev.driver->name, ts); | 784 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, |
| 785 | spi->dev.driver->name, ts); | ||
| 757 | if (err) { | 786 | if (err) { |
| 758 | dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); | 787 | dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); |
| 759 | goto err_free_mem; | 788 | goto err_free_mem; |
| @@ -763,20 +792,12 @@ static int __devinit ad7877_probe(struct spi_device *spi) | |||
| 763 | if (err) | 792 | if (err) |
| 764 | goto err_free_irq; | 793 | goto err_free_irq; |
| 765 | 794 | ||
| 766 | err = device_create_file(&spi->dev, | ||
| 767 | gpio3 ? &dev_attr_gpio3 : &dev_attr_aux3); | ||
| 768 | if (err) | ||
| 769 | goto err_remove_attr_group; | ||
| 770 | |||
| 771 | err = input_register_device(input_dev); | 795 | err = input_register_device(input_dev); |
| 772 | if (err) | 796 | if (err) |
| 773 | goto err_remove_attr; | 797 | goto err_remove_attr_group; |
| 774 | 798 | ||
| 775 | return 0; | 799 | return 0; |
| 776 | 800 | ||
| 777 | err_remove_attr: | ||
| 778 | device_remove_file(&spi->dev, | ||
| 779 | gpio3 ? &dev_attr_gpio3 : &dev_attr_aux3); | ||
| 780 | err_remove_attr_group: | 801 | err_remove_attr_group: |
| 781 | sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group); | 802 | sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group); |
| 782 | err_free_irq: | 803 | err_free_irq: |
| @@ -790,11 +811,9 @@ err_free_mem: | |||
| 790 | 811 | ||
| 791 | static int __devexit ad7877_remove(struct spi_device *spi) | 812 | static int __devexit ad7877_remove(struct spi_device *spi) |
| 792 | { | 813 | { |
| 793 | struct ad7877 *ts = dev_get_drvdata(&spi->dev); | 814 | struct ad7877 *ts = dev_get_drvdata(&spi->dev); |
| 794 | 815 | ||
| 795 | sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group); | 816 | sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group); |
| 796 | device_remove_file(&spi->dev, | ||
| 797 | gpio3 ? &dev_attr_gpio3 : &dev_attr_aux3); | ||
| 798 | 817 | ||
| 799 | ad7877_disable(ts); | 818 | ad7877_disable(ts); |
| 800 | free_irq(ts->spi->irq, ts); | 819 | free_irq(ts->spi->irq, ts); |
| @@ -808,39 +827,37 @@ static int __devexit ad7877_remove(struct spi_device *spi) | |||
| 808 | return 0; | 827 | return 0; |
| 809 | } | 828 | } |
| 810 | 829 | ||
| 811 | #ifdef CONFIG_PM | 830 | #ifdef CONFIG_PM_SLEEP |
| 812 | static int ad7877_suspend(struct spi_device *spi, pm_message_t message) | 831 | static int ad7877_suspend(struct device *dev) |
| 813 | { | 832 | { |
| 814 | struct ad7877 *ts = dev_get_drvdata(&spi->dev); | 833 | struct ad7877 *ts = dev_get_drvdata(dev); |
| 815 | 834 | ||
| 816 | ad7877_disable(ts); | 835 | ad7877_disable(ts); |
| 817 | 836 | ||
| 818 | return 0; | 837 | return 0; |
| 819 | } | 838 | } |
| 820 | 839 | ||
| 821 | static int ad7877_resume(struct spi_device *spi) | 840 | static int ad7877_resume(struct device *dev) |
| 822 | { | 841 | { |
| 823 | struct ad7877 *ts = dev_get_drvdata(&spi->dev); | 842 | struct ad7877 *ts = dev_get_drvdata(dev); |
| 824 | 843 | ||
| 825 | ad7877_enable(ts); | 844 | ad7877_enable(ts); |
| 826 | 845 | ||
| 827 | return 0; | 846 | return 0; |
| 828 | } | 847 | } |
| 829 | #else | ||
| 830 | #define ad7877_suspend NULL | ||
| 831 | #define ad7877_resume NULL | ||
| 832 | #endif | 848 | #endif |
| 833 | 849 | ||
| 850 | static SIMPLE_DEV_PM_OPS(ad7877_pm, ad7877_suspend, ad7877_resume); | ||
| 851 | |||
| 834 | static struct spi_driver ad7877_driver = { | 852 | static struct spi_driver ad7877_driver = { |
| 835 | .driver = { | 853 | .driver = { |
| 836 | .name = "ad7877", | 854 | .name = "ad7877", |
| 837 | .bus = &spi_bus_type, | 855 | .bus = &spi_bus_type, |
| 838 | .owner = THIS_MODULE, | 856 | .owner = THIS_MODULE, |
| 857 | .pm = &ad7877_pm, | ||
| 839 | }, | 858 | }, |
| 840 | .probe = ad7877_probe, | 859 | .probe = ad7877_probe, |
| 841 | .remove = __devexit_p(ad7877_remove), | 860 | .remove = __devexit_p(ad7877_remove), |
| 842 | .suspend = ad7877_suspend, | ||
| 843 | .resume = ad7877_resume, | ||
| 844 | }; | 861 | }; |
| 845 | 862 | ||
| 846 | static int __init ad7877_init(void) | 863 | static int __init ad7877_init(void) |
