aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/mk712.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2006-11-05 22:40:03 -0500
committerDmitry Torokhov <dtor@insightbb.com>2006-11-05 22:40:03 -0500
commit52c1f5704d7555a16641429b2e7af5d26d7b119a (patch)
treeeb55cec7167646ba18f09d7d4b0009712fe45062 /drivers/input/touchscreen/mk712.c
parent2b03b60e6b8635fffdd15d5d24943950f2bbf96e (diff)
Input: touchscreens - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/touchscreen/mk712.c')
-rw-r--r--drivers/input/touchscreen/mk712.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/input/touchscreen/mk712.c b/drivers/input/touchscreen/mk712.c
index 4cbcaa6a71e5..44140feeffc5 100644
--- a/drivers/input/touchscreen/mk712.c
+++ b/drivers/input/touchscreen/mk712.c
@@ -96,15 +96,13 @@ static irqreturn_t mk712_interrupt(int irq, void *dev_id)
96 goto end; 96 goto end;
97 } 97 }
98 98
99 if (~status & MK712_STATUS_TOUCH) 99 if (~status & MK712_STATUS_TOUCH) {
100 {
101 debounce = 1; 100 debounce = 1;
102 input_report_key(mk712_dev, BTN_TOUCH, 0); 101 input_report_key(mk712_dev, BTN_TOUCH, 0);
103 goto end; 102 goto end;
104 } 103 }
105 104
106 if (debounce) 105 if (debounce) {
107 {
108 debounce = 0; 106 debounce = 0;
109 goto end; 107 goto end;
110 } 108 }
@@ -113,8 +111,7 @@ static irqreturn_t mk712_interrupt(int irq, void *dev_id)
113 input_report_abs(mk712_dev, ABS_X, last_x); 111 input_report_abs(mk712_dev, ABS_X, last_x);
114 input_report_abs(mk712_dev, ABS_Y, last_y); 112 input_report_abs(mk712_dev, ABS_Y, last_y);
115 113
116end: 114 end:
117
118 last_x = inw(mk712_io + MK712_X) & 0x0fff; 115 last_x = inw(mk712_io + MK712_X) & 0x0fff;
119 last_y = inw(mk712_io + MK712_Y) & 0x0fff; 116 last_y = inw(mk712_io + MK712_Y) & 0x0fff;
120 input_sync(mk712_dev); 117 input_sync(mk712_dev);
@@ -169,13 +166,14 @@ static int __init mk712_init(void)
169 (inw(mk712_io + MK712_STATUS) & 0xf333)) { 166 (inw(mk712_io + MK712_STATUS) & 0xf333)) {
170 printk(KERN_WARNING "mk712: device not present\n"); 167 printk(KERN_WARNING "mk712: device not present\n");
171 err = -ENODEV; 168 err = -ENODEV;
172 goto fail; 169 goto fail1;
173 } 170 }
174 171
175 if (!(mk712_dev = input_allocate_device())) { 172 mk712_dev = input_allocate_device();
173 if (!mk712_dev) {
176 printk(KERN_ERR "mk712: not enough memory\n"); 174 printk(KERN_ERR "mk712: not enough memory\n");
177 err = -ENOMEM; 175 err = -ENOMEM;
178 goto fail; 176 goto fail1;
179 } 177 }
180 178
181 mk712_dev->name = "ICS MicroClock MK712 TouchScreen"; 179 mk712_dev->name = "ICS MicroClock MK712 TouchScreen";
@@ -196,13 +194,17 @@ static int __init mk712_init(void)
196 if (request_irq(mk712_irq, mk712_interrupt, 0, "mk712", mk712_dev)) { 194 if (request_irq(mk712_irq, mk712_interrupt, 0, "mk712", mk712_dev)) {
197 printk(KERN_WARNING "mk712: unable to get IRQ\n"); 195 printk(KERN_WARNING "mk712: unable to get IRQ\n");
198 err = -EBUSY; 196 err = -EBUSY;
199 goto fail; 197 goto fail1;
200 } 198 }
201 199
202 input_register_device(mk712_dev); 200 err = input_register_device(mk712_dev);
201 if (err)
202 goto fail2;
203
203 return 0; 204 return 0;
204 205
205 fail: input_free_device(mk712_dev); 206 fail2: free_irq(mk712_irq, mk712_dev);
207 fail1: input_free_device(mk712_dev);
206 release_region(mk712_io, 8); 208 release_region(mk712_io, 8);
207 return err; 209 return err;
208} 210}