diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2008-10-15 23:29:12 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2008-10-15 23:29:12 -0400 |
commit | 4c0e799a9a6dc64426ddb6c03aea1a154357658f (patch) | |
tree | 2d9aa9493d80fceb178a63bf15bb3d9edfc5fbae /drivers/input/touchscreen/ads7846.c | |
parent | 3fa8749e584b55f1180411ab1b51117190bac1e5 (diff) | |
parent | b8d055a878ee0f997ded40649701089d2486f850 (diff) |
Merge branch 'next' into for-linus
Diffstat (limited to 'drivers/input/touchscreen/ads7846.c')
-rw-r--r-- | drivers/input/touchscreen/ads7846.c | 162 |
1 files changed, 109 insertions, 53 deletions
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index ce6f48c695f5..b9b7fc6ff1eb 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/input.h> | 24 | #include <linux/input.h> |
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/gpio.h> | ||
27 | #include <linux/spi/spi.h> | 28 | #include <linux/spi/spi.h> |
28 | #include <linux/spi/ads7846.h> | 29 | #include <linux/spi/ads7846.h> |
29 | #include <asm/irq.h> | 30 | #include <asm/irq.h> |
@@ -68,6 +69,17 @@ struct ts_event { | |||
68 | int ignore; | 69 | int ignore; |
69 | }; | 70 | }; |
70 | 71 | ||
72 | /* | ||
73 | * We allocate this separately to avoid cache line sharing issues when | ||
74 | * driver is used with DMA-based SPI controllers (like atmel_spi) on | ||
75 | * systems where main memory is not DMA-coherent (most non-x86 boards). | ||
76 | */ | ||
77 | struct ads7846_packet { | ||
78 | u8 read_x, read_y, read_z1, read_z2, pwrdown; | ||
79 | u16 dummy; /* for the pwrdown read */ | ||
80 | struct ts_event tc; | ||
81 | }; | ||
82 | |||
71 | struct ads7846 { | 83 | struct ads7846 { |
72 | struct input_dev *input; | 84 | struct input_dev *input; |
73 | char phys[32]; | 85 | char phys[32]; |
@@ -85,9 +97,7 @@ struct ads7846 { | |||
85 | u16 x_plate_ohms; | 97 | u16 x_plate_ohms; |
86 | u16 pressure_max; | 98 | u16 pressure_max; |
87 | 99 | ||
88 | u8 read_x, read_y, read_z1, read_z2, pwrdown; | 100 | struct ads7846_packet *packet; |
89 | u16 dummy; /* for the pwrdown read */ | ||
90 | struct ts_event tc; | ||
91 | 101 | ||
92 | struct spi_transfer xfer[18]; | 102 | struct spi_transfer xfer[18]; |
93 | struct spi_message msg[5]; | 103 | struct spi_message msg[5]; |
@@ -116,6 +126,7 @@ struct ads7846 { | |||
116 | void *filter_data; | 126 | void *filter_data; |
117 | void (*filter_cleanup)(void *data); | 127 | void (*filter_cleanup)(void *data); |
118 | int (*get_pendown_state)(void); | 128 | int (*get_pendown_state)(void); |
129 | int gpio_pendown; | ||
119 | }; | 130 | }; |
120 | 131 | ||
121 | /* leave chip selected when we're done, for quicker re-select? */ | 132 | /* leave chip selected when we're done, for quicker re-select? */ |
@@ -461,10 +472,11 @@ static ssize_t ads7846_disable_store(struct device *dev, | |||
461 | const char *buf, size_t count) | 472 | const char *buf, size_t count) |
462 | { | 473 | { |
463 | struct ads7846 *ts = dev_get_drvdata(dev); | 474 | struct ads7846 *ts = dev_get_drvdata(dev); |
464 | char *endp; | 475 | long i; |
465 | int i; | 476 | |
477 | if (strict_strtoul(buf, 10, &i)) | ||
478 | return -EINVAL; | ||
466 | 479 | ||
467 | i = simple_strtoul(buf, &endp, 10); | ||
468 | spin_lock_irq(&ts->lock); | 480 | spin_lock_irq(&ts->lock); |
469 | 481 | ||
470 | if (i) | 482 | if (i) |
@@ -491,6 +503,14 @@ static struct attribute_group ads784x_attr_group = { | |||
491 | 503 | ||
492 | /*--------------------------------------------------------------------------*/ | 504 | /*--------------------------------------------------------------------------*/ |
493 | 505 | ||
506 | static int get_pendown_state(struct ads7846 *ts) | ||
507 | { | ||
508 | if (ts->get_pendown_state) | ||
509 | return ts->get_pendown_state(); | ||
510 | |||
511 | return !gpio_get_value(ts->gpio_pendown); | ||
512 | } | ||
513 | |||
494 | /* | 514 | /* |
495 | * PENIRQ only kicks the timer. The timer only reissues the SPI transfer, | 515 | * PENIRQ only kicks the timer. The timer only reissues the SPI transfer, |
496 | * to retrieve touchscreen status. | 516 | * to retrieve touchscreen status. |
@@ -502,16 +522,17 @@ static struct attribute_group ads784x_attr_group = { | |||
502 | static void ads7846_rx(void *ads) | 522 | static void ads7846_rx(void *ads) |
503 | { | 523 | { |
504 | struct ads7846 *ts = ads; | 524 | struct ads7846 *ts = ads; |
525 | struct ads7846_packet *packet = ts->packet; | ||
505 | unsigned Rt; | 526 | unsigned Rt; |
506 | u16 x, y, z1, z2; | 527 | u16 x, y, z1, z2; |
507 | 528 | ||
508 | /* ads7846_rx_val() did in-place conversion (including byteswap) from | 529 | /* ads7846_rx_val() did in-place conversion (including byteswap) from |
509 | * on-the-wire format as part of debouncing to get stable readings. | 530 | * on-the-wire format as part of debouncing to get stable readings. |
510 | */ | 531 | */ |
511 | x = ts->tc.x; | 532 | x = packet->tc.x; |
512 | y = ts->tc.y; | 533 | y = packet->tc.y; |
513 | z1 = ts->tc.z1; | 534 | z1 = packet->tc.z1; |
514 | z2 = ts->tc.z2; | 535 | z2 = packet->tc.z2; |
515 | 536 | ||
516 | /* range filtering */ | 537 | /* range filtering */ |
517 | if (x == MAX_12BIT) | 538 | if (x == MAX_12BIT) |
@@ -535,10 +556,10 @@ static void ads7846_rx(void *ads) | |||
535 | * the maximum. Don't report it to user space, repeat at least | 556 | * the maximum. Don't report it to user space, repeat at least |
536 | * once more the measurement | 557 | * once more the measurement |
537 | */ | 558 | */ |
538 | if (ts->tc.ignore || Rt > ts->pressure_max) { | 559 | if (packet->tc.ignore || Rt > ts->pressure_max) { |
539 | #ifdef VERBOSE | 560 | #ifdef VERBOSE |
540 | pr_debug("%s: ignored %d pressure %d\n", | 561 | pr_debug("%s: ignored %d pressure %d\n", |
541 | ts->spi->dev.bus_id, ts->tc.ignore, Rt); | 562 | ts->spi->dev.bus_id, packet->tc.ignore, Rt); |
542 | #endif | 563 | #endif |
543 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), | 564 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), |
544 | HRTIMER_MODE_REL); | 565 | HRTIMER_MODE_REL); |
@@ -550,7 +571,7 @@ static void ads7846_rx(void *ads) | |||
550 | */ | 571 | */ |
551 | if (ts->penirq_recheck_delay_usecs) { | 572 | if (ts->penirq_recheck_delay_usecs) { |
552 | udelay(ts->penirq_recheck_delay_usecs); | 573 | udelay(ts->penirq_recheck_delay_usecs); |
553 | if (!ts->get_pendown_state()) | 574 | if (!get_pendown_state(ts)) |
554 | Rt = 0; | 575 | Rt = 0; |
555 | } | 576 | } |
556 | 577 | ||
@@ -631,6 +652,7 @@ static int ads7846_no_filter(void *ads, int data_idx, int *val) | |||
631 | static void ads7846_rx_val(void *ads) | 652 | static void ads7846_rx_val(void *ads) |
632 | { | 653 | { |
633 | struct ads7846 *ts = ads; | 654 | struct ads7846 *ts = ads; |
655 | struct ads7846_packet *packet = ts->packet; | ||
634 | struct spi_message *m; | 656 | struct spi_message *m; |
635 | struct spi_transfer *t; | 657 | struct spi_transfer *t; |
636 | int val; | 658 | int val; |
@@ -650,7 +672,7 @@ static void ads7846_rx_val(void *ads) | |||
650 | case ADS7846_FILTER_REPEAT: | 672 | case ADS7846_FILTER_REPEAT: |
651 | break; | 673 | break; |
652 | case ADS7846_FILTER_IGNORE: | 674 | case ADS7846_FILTER_IGNORE: |
653 | ts->tc.ignore = 1; | 675 | packet->tc.ignore = 1; |
654 | /* Last message will contain ads7846_rx() as the | 676 | /* Last message will contain ads7846_rx() as the |
655 | * completion function. | 677 | * completion function. |
656 | */ | 678 | */ |
@@ -658,7 +680,7 @@ static void ads7846_rx_val(void *ads) | |||
658 | break; | 680 | break; |
659 | case ADS7846_FILTER_OK: | 681 | case ADS7846_FILTER_OK: |
660 | *(u16 *)t->rx_buf = val; | 682 | *(u16 *)t->rx_buf = val; |
661 | ts->tc.ignore = 0; | 683 | packet->tc.ignore = 0; |
662 | m = &ts->msg[++ts->msg_idx]; | 684 | m = &ts->msg[++ts->msg_idx]; |
663 | break; | 685 | break; |
664 | default: | 686 | default: |
@@ -677,7 +699,7 @@ static enum hrtimer_restart ads7846_timer(struct hrtimer *handle) | |||
677 | 699 | ||
678 | spin_lock_irq(&ts->lock); | 700 | spin_lock_irq(&ts->lock); |
679 | 701 | ||
680 | if (unlikely(!ts->get_pendown_state() || | 702 | if (unlikely(!get_pendown_state(ts) || |
681 | device_suspended(&ts->spi->dev))) { | 703 | device_suspended(&ts->spi->dev))) { |
682 | if (ts->pendown) { | 704 | if (ts->pendown) { |
683 | struct input_dev *input = ts->input; | 705 | struct input_dev *input = ts->input; |
@@ -716,7 +738,7 @@ static irqreturn_t ads7846_irq(int irq, void *handle) | |||
716 | unsigned long flags; | 738 | unsigned long flags; |
717 | 739 | ||
718 | spin_lock_irqsave(&ts->lock, flags); | 740 | spin_lock_irqsave(&ts->lock, flags); |
719 | if (likely(ts->get_pendown_state())) { | 741 | if (likely(get_pendown_state(ts))) { |
720 | if (!ts->irq_disabled) { | 742 | if (!ts->irq_disabled) { |
721 | /* The ARM do_simple_IRQ() dispatcher doesn't act | 743 | /* The ARM do_simple_IRQ() dispatcher doesn't act |
722 | * like the other dispatchers: it will report IRQs | 744 | * like the other dispatchers: it will report IRQs |
@@ -763,7 +785,6 @@ static void ads7846_disable(struct ads7846 *ts) | |||
763 | /* we know the chip's in lowpower mode since we always | 785 | /* we know the chip's in lowpower mode since we always |
764 | * leave it that way after every request | 786 | * leave it that way after every request |
765 | */ | 787 | */ |
766 | |||
767 | } | 788 | } |
768 | 789 | ||
769 | /* Must be called with ts->lock held */ | 790 | /* Must be called with ts->lock held */ |
@@ -806,9 +827,40 @@ static int ads7846_resume(struct spi_device *spi) | |||
806 | return 0; | 827 | return 0; |
807 | } | 828 | } |
808 | 829 | ||
830 | static int __devinit setup_pendown(struct spi_device *spi, struct ads7846 *ts) | ||
831 | { | ||
832 | struct ads7846_platform_data *pdata = spi->dev.platform_data; | ||
833 | int err; | ||
834 | |||
835 | /* REVISIT when the irq can be triggered active-low, or if for some | ||
836 | * reason the touchscreen isn't hooked up, we don't need to access | ||
837 | * the pendown state. | ||
838 | */ | ||
839 | if (!pdata->get_pendown_state && !gpio_is_valid(pdata->gpio_pendown)) { | ||
840 | dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); | ||
841 | return -EINVAL; | ||
842 | } | ||
843 | |||
844 | if (pdata->get_pendown_state) { | ||
845 | ts->get_pendown_state = pdata->get_pendown_state; | ||
846 | return 0; | ||
847 | } | ||
848 | |||
849 | err = gpio_request(pdata->gpio_pendown, "ads7846_pendown"); | ||
850 | if (err) { | ||
851 | dev_err(&spi->dev, "failed to request pendown GPIO%d\n", | ||
852 | pdata->gpio_pendown); | ||
853 | return err; | ||
854 | } | ||
855 | |||
856 | ts->gpio_pendown = pdata->gpio_pendown; | ||
857 | return 0; | ||
858 | } | ||
859 | |||
809 | static int __devinit ads7846_probe(struct spi_device *spi) | 860 | static int __devinit ads7846_probe(struct spi_device *spi) |
810 | { | 861 | { |
811 | struct ads7846 *ts; | 862 | struct ads7846 *ts; |
863 | struct ads7846_packet *packet; | ||
812 | struct input_dev *input_dev; | 864 | struct input_dev *input_dev; |
813 | struct ads7846_platform_data *pdata = spi->dev.platform_data; | 865 | struct ads7846_platform_data *pdata = spi->dev.platform_data; |
814 | struct spi_message *m; | 866 | struct spi_message *m; |
@@ -833,15 +885,6 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
833 | return -EINVAL; | 885 | return -EINVAL; |
834 | } | 886 | } |
835 | 887 | ||
836 | /* REVISIT when the irq can be triggered active-low, or if for some | ||
837 | * reason the touchscreen isn't hooked up, we don't need to access | ||
838 | * the pendown state. | ||
839 | */ | ||
840 | if (pdata->get_pendown_state == NULL) { | ||
841 | dev_dbg(&spi->dev, "no get_pendown_state function?\n"); | ||
842 | return -EINVAL; | ||
843 | } | ||
844 | |||
845 | /* We'd set TX wordsize 8 bits and RX wordsize to 13 bits ... except | 888 | /* We'd set TX wordsize 8 bits and RX wordsize to 13 bits ... except |
846 | * that even if the hardware can do that, the SPI controller driver | 889 | * that even if the hardware can do that, the SPI controller driver |
847 | * may not. So we stick to very-portable 8 bit words, both RX and TX. | 890 | * may not. So we stick to very-portable 8 bit words, both RX and TX. |
@@ -853,14 +896,16 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
853 | return err; | 896 | return err; |
854 | 897 | ||
855 | ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL); | 898 | ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL); |
899 | packet = kzalloc(sizeof(struct ads7846_packet), GFP_KERNEL); | ||
856 | input_dev = input_allocate_device(); | 900 | input_dev = input_allocate_device(); |
857 | if (!ts || !input_dev) { | 901 | if (!ts || !packet || !input_dev) { |
858 | err = -ENOMEM; | 902 | err = -ENOMEM; |
859 | goto err_free_mem; | 903 | goto err_free_mem; |
860 | } | 904 | } |
861 | 905 | ||
862 | dev_set_drvdata(&spi->dev, ts); | 906 | dev_set_drvdata(&spi->dev, ts); |
863 | 907 | ||
908 | ts->packet = packet; | ||
864 | ts->spi = spi; | 909 | ts->spi = spi; |
865 | ts->input = input_dev; | 910 | ts->input = input_dev; |
866 | ts->vref_mv = pdata->vref_mv; | 911 | ts->vref_mv = pdata->vref_mv; |
@@ -893,7 +938,10 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
893 | ts->filter_data = ts; | 938 | ts->filter_data = ts; |
894 | } else | 939 | } else |
895 | ts->filter = ads7846_no_filter; | 940 | ts->filter = ads7846_no_filter; |
896 | ts->get_pendown_state = pdata->get_pendown_state; | 941 | |
942 | err = setup_pendown(spi, ts); | ||
943 | if (err) | ||
944 | goto err_cleanup_filter; | ||
897 | 945 | ||
898 | if (pdata->penirq_recheck_delay_usecs) | 946 | if (pdata->penirq_recheck_delay_usecs) |
899 | ts->penirq_recheck_delay_usecs = | 947 | ts->penirq_recheck_delay_usecs = |
@@ -929,13 +977,13 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
929 | spi_message_init(m); | 977 | spi_message_init(m); |
930 | 978 | ||
931 | /* y- still on; turn on only y+ (and ADC) */ | 979 | /* y- still on; turn on only y+ (and ADC) */ |
932 | ts->read_y = READ_Y(vref); | 980 | packet->read_y = READ_Y(vref); |
933 | x->tx_buf = &ts->read_y; | 981 | x->tx_buf = &packet->read_y; |
934 | x->len = 1; | 982 | x->len = 1; |
935 | spi_message_add_tail(x, m); | 983 | spi_message_add_tail(x, m); |
936 | 984 | ||
937 | x++; | 985 | x++; |
938 | x->rx_buf = &ts->tc.y; | 986 | x->rx_buf = &packet->tc.y; |
939 | x->len = 2; | 987 | x->len = 2; |
940 | spi_message_add_tail(x, m); | 988 | spi_message_add_tail(x, m); |
941 | 989 | ||
@@ -947,12 +995,12 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
947 | x->delay_usecs = pdata->settle_delay_usecs; | 995 | x->delay_usecs = pdata->settle_delay_usecs; |
948 | 996 | ||
949 | x++; | 997 | x++; |
950 | x->tx_buf = &ts->read_y; | 998 | x->tx_buf = &packet->read_y; |
951 | x->len = 1; | 999 | x->len = 1; |
952 | spi_message_add_tail(x, m); | 1000 | spi_message_add_tail(x, m); |
953 | 1001 | ||
954 | x++; | 1002 | x++; |
955 | x->rx_buf = &ts->tc.y; | 1003 | x->rx_buf = &packet->tc.y; |
956 | x->len = 2; | 1004 | x->len = 2; |
957 | spi_message_add_tail(x, m); | 1005 | spi_message_add_tail(x, m); |
958 | } | 1006 | } |
@@ -965,13 +1013,13 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
965 | 1013 | ||
966 | /* turn y- off, x+ on, then leave in lowpower */ | 1014 | /* turn y- off, x+ on, then leave in lowpower */ |
967 | x++; | 1015 | x++; |
968 | ts->read_x = READ_X(vref); | 1016 | packet->read_x = READ_X(vref); |
969 | x->tx_buf = &ts->read_x; | 1017 | x->tx_buf = &packet->read_x; |
970 | x->len = 1; | 1018 | x->len = 1; |
971 | spi_message_add_tail(x, m); | 1019 | spi_message_add_tail(x, m); |
972 | 1020 | ||
973 | x++; | 1021 | x++; |
974 | x->rx_buf = &ts->tc.x; | 1022 | x->rx_buf = &packet->tc.x; |
975 | x->len = 2; | 1023 | x->len = 2; |
976 | spi_message_add_tail(x, m); | 1024 | spi_message_add_tail(x, m); |
977 | 1025 | ||
@@ -980,12 +1028,12 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
980 | x->delay_usecs = pdata->settle_delay_usecs; | 1028 | x->delay_usecs = pdata->settle_delay_usecs; |
981 | 1029 | ||
982 | x++; | 1030 | x++; |
983 | x->tx_buf = &ts->read_x; | 1031 | x->tx_buf = &packet->read_x; |
984 | x->len = 1; | 1032 | x->len = 1; |
985 | spi_message_add_tail(x, m); | 1033 | spi_message_add_tail(x, m); |
986 | 1034 | ||
987 | x++; | 1035 | x++; |
988 | x->rx_buf = &ts->tc.x; | 1036 | x->rx_buf = &packet->tc.x; |
989 | x->len = 2; | 1037 | x->len = 2; |
990 | spi_message_add_tail(x, m); | 1038 | spi_message_add_tail(x, m); |
991 | } | 1039 | } |
@@ -999,13 +1047,13 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
999 | spi_message_init(m); | 1047 | spi_message_init(m); |
1000 | 1048 | ||
1001 | x++; | 1049 | x++; |
1002 | ts->read_z1 = READ_Z1(vref); | 1050 | packet->read_z1 = READ_Z1(vref); |
1003 | x->tx_buf = &ts->read_z1; | 1051 | x->tx_buf = &packet->read_z1; |
1004 | x->len = 1; | 1052 | x->len = 1; |
1005 | spi_message_add_tail(x, m); | 1053 | spi_message_add_tail(x, m); |
1006 | 1054 | ||
1007 | x++; | 1055 | x++; |
1008 | x->rx_buf = &ts->tc.z1; | 1056 | x->rx_buf = &packet->tc.z1; |
1009 | x->len = 2; | 1057 | x->len = 2; |
1010 | spi_message_add_tail(x, m); | 1058 | spi_message_add_tail(x, m); |
1011 | 1059 | ||
@@ -1014,12 +1062,12 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1014 | x->delay_usecs = pdata->settle_delay_usecs; | 1062 | x->delay_usecs = pdata->settle_delay_usecs; |
1015 | 1063 | ||
1016 | x++; | 1064 | x++; |
1017 | x->tx_buf = &ts->read_z1; | 1065 | x->tx_buf = &packet->read_z1; |
1018 | x->len = 1; | 1066 | x->len = 1; |
1019 | spi_message_add_tail(x, m); | 1067 | spi_message_add_tail(x, m); |
1020 | 1068 | ||
1021 | x++; | 1069 | x++; |
1022 | x->rx_buf = &ts->tc.z1; | 1070 | x->rx_buf = &packet->tc.z1; |
1023 | x->len = 2; | 1071 | x->len = 2; |
1024 | spi_message_add_tail(x, m); | 1072 | spi_message_add_tail(x, m); |
1025 | } | 1073 | } |
@@ -1031,13 +1079,13 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1031 | spi_message_init(m); | 1079 | spi_message_init(m); |
1032 | 1080 | ||
1033 | x++; | 1081 | x++; |
1034 | ts->read_z2 = READ_Z2(vref); | 1082 | packet->read_z2 = READ_Z2(vref); |
1035 | x->tx_buf = &ts->read_z2; | 1083 | x->tx_buf = &packet->read_z2; |
1036 | x->len = 1; | 1084 | x->len = 1; |
1037 | spi_message_add_tail(x, m); | 1085 | spi_message_add_tail(x, m); |
1038 | 1086 | ||
1039 | x++; | 1087 | x++; |
1040 | x->rx_buf = &ts->tc.z2; | 1088 | x->rx_buf = &packet->tc.z2; |
1041 | x->len = 2; | 1089 | x->len = 2; |
1042 | spi_message_add_tail(x, m); | 1090 | spi_message_add_tail(x, m); |
1043 | 1091 | ||
@@ -1046,12 +1094,12 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1046 | x->delay_usecs = pdata->settle_delay_usecs; | 1094 | x->delay_usecs = pdata->settle_delay_usecs; |
1047 | 1095 | ||
1048 | x++; | 1096 | x++; |
1049 | x->tx_buf = &ts->read_z2; | 1097 | x->tx_buf = &packet->read_z2; |
1050 | x->len = 1; | 1098 | x->len = 1; |
1051 | spi_message_add_tail(x, m); | 1099 | spi_message_add_tail(x, m); |
1052 | 1100 | ||
1053 | x++; | 1101 | x++; |
1054 | x->rx_buf = &ts->tc.z2; | 1102 | x->rx_buf = &packet->tc.z2; |
1055 | x->len = 2; | 1103 | x->len = 2; |
1056 | spi_message_add_tail(x, m); | 1104 | spi_message_add_tail(x, m); |
1057 | } | 1105 | } |
@@ -1065,13 +1113,13 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1065 | spi_message_init(m); | 1113 | spi_message_init(m); |
1066 | 1114 | ||
1067 | x++; | 1115 | x++; |
1068 | ts->pwrdown = PWRDOWN; | 1116 | packet->pwrdown = PWRDOWN; |
1069 | x->tx_buf = &ts->pwrdown; | 1117 | x->tx_buf = &packet->pwrdown; |
1070 | x->len = 1; | 1118 | x->len = 1; |
1071 | spi_message_add_tail(x, m); | 1119 | spi_message_add_tail(x, m); |
1072 | 1120 | ||
1073 | x++; | 1121 | x++; |
1074 | x->rx_buf = &ts->dummy; | 1122 | x->rx_buf = &packet->dummy; |
1075 | x->len = 2; | 1123 | x->len = 2; |
1076 | CS_CHANGE(*x); | 1124 | CS_CHANGE(*x); |
1077 | spi_message_add_tail(x, m); | 1125 | spi_message_add_tail(x, m); |
@@ -1085,7 +1133,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1085 | spi->dev.driver->name, ts)) { | 1133 | spi->dev.driver->name, ts)) { |
1086 | dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); | 1134 | dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); |
1087 | err = -EBUSY; | 1135 | err = -EBUSY; |
1088 | goto err_cleanup_filter; | 1136 | goto err_free_gpio; |
1089 | } | 1137 | } |
1090 | 1138 | ||
1091 | err = ads784x_hwmon_register(spi, ts); | 1139 | err = ads784x_hwmon_register(spi, ts); |
@@ -1116,11 +1164,15 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1116 | ads784x_hwmon_unregister(spi, ts); | 1164 | ads784x_hwmon_unregister(spi, ts); |
1117 | err_free_irq: | 1165 | err_free_irq: |
1118 | free_irq(spi->irq, ts); | 1166 | free_irq(spi->irq, ts); |
1167 | err_free_gpio: | ||
1168 | if (ts->gpio_pendown != -1) | ||
1169 | gpio_free(ts->gpio_pendown); | ||
1119 | err_cleanup_filter: | 1170 | err_cleanup_filter: |
1120 | if (ts->filter_cleanup) | 1171 | if (ts->filter_cleanup) |
1121 | ts->filter_cleanup(ts->filter_data); | 1172 | ts->filter_cleanup(ts->filter_data); |
1122 | err_free_mem: | 1173 | err_free_mem: |
1123 | input_free_device(input_dev); | 1174 | input_free_device(input_dev); |
1175 | kfree(packet); | ||
1124 | kfree(ts); | 1176 | kfree(ts); |
1125 | return err; | 1177 | return err; |
1126 | } | 1178 | } |
@@ -1140,9 +1192,13 @@ static int __devexit ads7846_remove(struct spi_device *spi) | |||
1140 | /* suspend left the IRQ disabled */ | 1192 | /* suspend left the IRQ disabled */ |
1141 | enable_irq(ts->spi->irq); | 1193 | enable_irq(ts->spi->irq); |
1142 | 1194 | ||
1195 | if (ts->gpio_pendown != -1) | ||
1196 | gpio_free(ts->gpio_pendown); | ||
1197 | |||
1143 | if (ts->filter_cleanup) | 1198 | if (ts->filter_cleanup) |
1144 | ts->filter_cleanup(ts->filter_data); | 1199 | ts->filter_cleanup(ts->filter_data); |
1145 | 1200 | ||
1201 | kfree(ts->packet); | ||
1146 | kfree(ts); | 1202 | kfree(ts); |
1147 | 1203 | ||
1148 | dev_dbg(&spi->dev, "unregistered touchscreen\n"); | 1204 | dev_dbg(&spi->dev, "unregistered touchscreen\n"); |