diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2006-11-05 22:40:03 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2006-11-05 22:40:03 -0500 |
commit | 52c1f5704d7555a16641429b2e7af5d26d7b119a (patch) | |
tree | eb55cec7167646ba18f09d7d4b0009712fe45062 /drivers/input/touchscreen | |
parent | 2b03b60e6b8635fffdd15d5d24943950f2bbf96e (diff) |
Input: touchscreens - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r-- | drivers/input/touchscreen/corgi_ts.c | 30 | ||||
-rw-r--r-- | drivers/input/touchscreen/gunze.c | 14 | ||||
-rw-r--r-- | drivers/input/touchscreen/hp680_ts_input.c | 29 | ||||
-rw-r--r-- | drivers/input/touchscreen/mk712.c | 26 | ||||
-rw-r--r-- | drivers/input/touchscreen/mtouch.c | 13 |
5 files changed, 68 insertions, 44 deletions
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c index 66121f6a89ad..e2945582828e 100644 --- a/drivers/input/touchscreen/corgi_ts.c +++ b/drivers/input/touchscreen/corgi_ts.c | |||
@@ -175,17 +175,19 @@ static int read_xydata(struct corgi_ts *corgi_ts) | |||
175 | 175 | ||
176 | static void new_data(struct corgi_ts *corgi_ts) | 176 | static void new_data(struct corgi_ts *corgi_ts) |
177 | { | 177 | { |
178 | struct input_dev *dev = corgi_ts->input; | ||
179 | |||
178 | if (corgi_ts->power_mode != PWR_MODE_ACTIVE) | 180 | if (corgi_ts->power_mode != PWR_MODE_ACTIVE) |
179 | return; | 181 | return; |
180 | 182 | ||
181 | if (!corgi_ts->tc.pressure && corgi_ts->pendown == 0) | 183 | if (!corgi_ts->tc.pressure && corgi_ts->pendown == 0) |
182 | return; | 184 | return; |
183 | 185 | ||
184 | input_report_abs(corgi_ts->input, ABS_X, corgi_ts->tc.x); | 186 | input_report_abs(dev, ABS_X, corgi_ts->tc.x); |
185 | input_report_abs(corgi_ts->input, ABS_Y, corgi_ts->tc.y); | 187 | input_report_abs(dev, ABS_Y, corgi_ts->tc.y); |
186 | input_report_abs(corgi_ts->input, ABS_PRESSURE, corgi_ts->tc.pressure); | 188 | input_report_abs(dev, ABS_PRESSURE, corgi_ts->tc.pressure); |
187 | input_report_key(corgi_ts->input, BTN_TOUCH, (corgi_ts->pendown != 0)); | 189 | input_report_key(dev, BTN_TOUCH, corgi_ts->pendown); |
188 | input_sync(corgi_ts->input); | 190 | input_sync(dev); |
189 | } | 191 | } |
190 | 192 | ||
191 | static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer) | 193 | static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer) |
@@ -219,12 +221,14 @@ static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer) | |||
219 | static void corgi_ts_timer(unsigned long data) | 221 | static void corgi_ts_timer(unsigned long data) |
220 | { | 222 | { |
221 | struct corgi_ts *corgits_data = (struct corgi_ts *) data; | 223 | struct corgi_ts *corgits_data = (struct corgi_ts *) data; |
224 | |||
222 | ts_interrupt_main(corgits_data, 1); | 225 | ts_interrupt_main(corgits_data, 1); |
223 | } | 226 | } |
224 | 227 | ||
225 | static irqreturn_t ts_interrupt(int irq, void *dev_id) | 228 | static irqreturn_t ts_interrupt(int irq, void *dev_id) |
226 | { | 229 | { |
227 | struct corgi_ts *corgits_data = dev_id; | 230 | struct corgi_ts *corgits_data = dev_id; |
231 | |||
228 | ts_interrupt_main(corgits_data, 0); | 232 | ts_interrupt_main(corgits_data, 0); |
229 | return IRQ_HANDLED; | 233 | return IRQ_HANDLED; |
230 | } | 234 | } |
@@ -272,7 +276,7 @@ static int __init corgits_probe(struct platform_device *pdev) | |||
272 | corgi_ts = kzalloc(sizeof(struct corgi_ts), GFP_KERNEL); | 276 | corgi_ts = kzalloc(sizeof(struct corgi_ts), GFP_KERNEL); |
273 | input_dev = input_allocate_device(); | 277 | input_dev = input_allocate_device(); |
274 | if (!corgi_ts || !input_dev) | 278 | if (!corgi_ts || !input_dev) |
275 | goto fail; | 279 | goto fail1; |
276 | 280 | ||
277 | platform_set_drvdata(pdev, corgi_ts); | 281 | platform_set_drvdata(pdev, corgi_ts); |
278 | 282 | ||
@@ -281,7 +285,7 @@ static int __init corgits_probe(struct platform_device *pdev) | |||
281 | 285 | ||
282 | if (corgi_ts->irq_gpio < 0) { | 286 | if (corgi_ts->irq_gpio < 0) { |
283 | err = -ENODEV; | 287 | err = -ENODEV; |
284 | goto fail; | 288 | goto fail1; |
285 | } | 289 | } |
286 | 290 | ||
287 | corgi_ts->input = input_dev; | 291 | corgi_ts->input = input_dev; |
@@ -319,10 +323,12 @@ static int __init corgits_probe(struct platform_device *pdev) | |||
319 | 323 | ||
320 | if (request_irq(corgi_ts->irq_gpio, ts_interrupt, IRQF_DISABLED, "ts", corgi_ts)) { | 324 | if (request_irq(corgi_ts->irq_gpio, ts_interrupt, IRQF_DISABLED, "ts", corgi_ts)) { |
321 | err = -EBUSY; | 325 | err = -EBUSY; |
322 | goto fail; | 326 | goto fail1; |
323 | } | 327 | } |
324 | 328 | ||
325 | input_register_device(corgi_ts->input); | 329 | err = input_register_device(corgi_ts->input); |
330 | if (err) | ||
331 | goto fail2; | ||
326 | 332 | ||
327 | corgi_ts->power_mode = PWR_MODE_ACTIVE; | 333 | corgi_ts->power_mode = PWR_MODE_ACTIVE; |
328 | 334 | ||
@@ -331,17 +337,17 @@ static int __init corgits_probe(struct platform_device *pdev) | |||
331 | 337 | ||
332 | return 0; | 338 | return 0; |
333 | 339 | ||
334 | fail: input_free_device(input_dev); | 340 | fail2: free_irq(corgi_ts->irq_gpio, corgi_ts); |
341 | fail1: input_free_device(input_dev); | ||
335 | kfree(corgi_ts); | 342 | kfree(corgi_ts); |
336 | return err; | 343 | return err; |
337 | |||
338 | } | 344 | } |
339 | 345 | ||
340 | static int corgits_remove(struct platform_device *pdev) | 346 | static int corgits_remove(struct platform_device *pdev) |
341 | { | 347 | { |
342 | struct corgi_ts *corgi_ts = platform_get_drvdata(pdev); | 348 | struct corgi_ts *corgi_ts = platform_get_drvdata(pdev); |
343 | 349 | ||
344 | free_irq(corgi_ts->irq_gpio, NULL); | 350 | free_irq(corgi_ts->irq_gpio, corgi_ts); |
345 | del_timer_sync(&corgi_ts->timer); | 351 | del_timer_sync(&corgi_ts->timer); |
346 | corgi_ts->machinfo->put_hsync(); | 352 | corgi_ts->machinfo->put_hsync(); |
347 | input_unregister_device(corgi_ts->input); | 353 | input_unregister_device(corgi_ts->input); |
diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c index 817c2198933d..44f397fff715 100644 --- a/drivers/input/touchscreen/gunze.c +++ b/drivers/input/touchscreen/gunze.c | |||
@@ -123,7 +123,7 @@ static int gunze_connect(struct serio *serio, struct serio_driver *drv) | |||
123 | input_dev = input_allocate_device(); | 123 | input_dev = input_allocate_device(); |
124 | if (!gunze || !input_dev) { | 124 | if (!gunze || !input_dev) { |
125 | err = -ENOMEM; | 125 | err = -ENOMEM; |
126 | goto fail; | 126 | goto fail1; |
127 | } | 127 | } |
128 | 128 | ||
129 | gunze->serio = serio; | 129 | gunze->serio = serio; |
@@ -146,13 +146,17 @@ static int gunze_connect(struct serio *serio, struct serio_driver *drv) | |||
146 | 146 | ||
147 | err = serio_open(serio, drv); | 147 | err = serio_open(serio, drv); |
148 | if (err) | 148 | if (err) |
149 | goto fail; | 149 | goto fail2; |
150 | |||
151 | err = input_register_device(gunze->dev); | ||
152 | if (err) | ||
153 | goto fail3; | ||
150 | 154 | ||
151 | input_register_device(gunze->dev); | ||
152 | return 0; | 155 | return 0; |
153 | 156 | ||
154 | fail: serio_set_drvdata(serio, NULL); | 157 | fail3: serio_close(serio); |
155 | input_free_device(input_dev); | 158 | fail2: serio_set_drvdata(serio, NULL); |
159 | fail1: input_free_device(input_dev); | ||
156 | kfree(gunze); | 160 | kfree(gunze); |
157 | return err; | 161 | return err; |
158 | } | 162 | } |
diff --git a/drivers/input/touchscreen/hp680_ts_input.c b/drivers/input/touchscreen/hp680_ts_input.c index 58fca316786c..249087472740 100644 --- a/drivers/input/touchscreen/hp680_ts_input.c +++ b/drivers/input/touchscreen/hp680_ts_input.c | |||
@@ -76,38 +76,47 @@ static irqreturn_t hp680_ts_interrupt(int irq, void *dev) | |||
76 | 76 | ||
77 | static int __init hp680_ts_init(void) | 77 | static int __init hp680_ts_init(void) |
78 | { | 78 | { |
79 | int err; | ||
80 | |||
79 | hp680_ts_dev = input_allocate_device(); | 81 | hp680_ts_dev = input_allocate_device(); |
80 | if (!hp680_ts_dev) | 82 | if (!hp680_ts_dev) |
81 | return -ENOMEM; | 83 | return -ENOMEM; |
82 | 84 | ||
83 | hp680_ts_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); | 85 | hp680_ts_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); |
84 | hp680_ts_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | ||
85 | hp680_ts_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 86 | hp680_ts_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); |
86 | 87 | ||
87 | hp680_ts_dev->absmin[ABS_X] = HP680_TS_ABS_X_MIN; | 88 | input_set_abs_params(hp680_ts_dev, ABS_X, |
88 | hp680_ts_dev->absmin[ABS_Y] = HP680_TS_ABS_Y_MIN; | 89 | HP680_TS_ABS_X_MIN, HP680_TS_ABS_X_MAX, 0, 0); |
89 | hp680_ts_dev->absmax[ABS_X] = HP680_TS_ABS_X_MAX; | 90 | input_set_abs_params(hp680_ts_dev, ABS_Y, |
90 | hp680_ts_dev->absmax[ABS_Y] = HP680_TS_ABS_Y_MAX; | 91 | HP680_TS_ABS_Y_MIN, HP680_TS_ABS_Y_MAX, 0, 0); |
91 | 92 | ||
92 | hp680_ts_dev->name = "HP Jornada touchscreen"; | 93 | hp680_ts_dev->name = "HP Jornada touchscreen"; |
93 | hp680_ts_dev->phys = "hp680_ts/input0"; | 94 | hp680_ts_dev->phys = "hp680_ts/input0"; |
94 | 95 | ||
95 | input_register_device(hp680_ts_dev); | ||
96 | |||
97 | if (request_irq(HP680_TS_IRQ, hp680_ts_interrupt, | 96 | if (request_irq(HP680_TS_IRQ, hp680_ts_interrupt, |
98 | IRQF_DISABLED, MODNAME, 0) < 0) { | 97 | IRQF_DISABLED, MODNAME, 0) < 0) { |
99 | printk(KERN_ERR "hp680_touchscreen.c: Can't allocate irq %d\n", | 98 | printk(KERN_ERR "hp680_touchscreen.c: Can't allocate irq %d\n", |
100 | HP680_TS_IRQ); | 99 | HP680_TS_IRQ); |
101 | input_unregister_device(hp680_ts_dev); | 100 | err = -EBUSY; |
102 | return -EBUSY; | 101 | goto fail1; |
103 | } | 102 | } |
104 | 103 | ||
104 | err = input_register_device(hp680_ts_dev); | ||
105 | if (err) | ||
106 | goto fail2; | ||
107 | |||
105 | return 0; | 108 | return 0; |
109 | |||
110 | fail2: free_irq(HP680_TS_IRQ, NULL); | ||
111 | cancel_delayed_work(&work); | ||
112 | flush_scheduled_work(); | ||
113 | fail1: input_free_device(hp680_ts_dev); | ||
114 | return err; | ||
106 | } | 115 | } |
107 | 116 | ||
108 | static void __exit hp680_ts_exit(void) | 117 | static void __exit hp680_ts_exit(void) |
109 | { | 118 | { |
110 | free_irq(HP680_TS_IRQ, 0); | 119 | free_irq(HP680_TS_IRQ, NULL); |
111 | cancel_delayed_work(&work); | 120 | cancel_delayed_work(&work); |
112 | flush_scheduled_work(); | 121 | flush_scheduled_work(); |
113 | input_unregister_device(hp680_ts_dev); | 122 | input_unregister_device(hp680_ts_dev); |
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 | ||
116 | end: | 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 | } |
diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c index 3b4c61664b63..c66b399774f2 100644 --- a/drivers/input/touchscreen/mtouch.c +++ b/drivers/input/touchscreen/mtouch.c | |||
@@ -137,7 +137,7 @@ static int mtouch_connect(struct serio *serio, struct serio_driver *drv) | |||
137 | input_dev = input_allocate_device(); | 137 | input_dev = input_allocate_device(); |
138 | if (!mtouch || !input_dev) { | 138 | if (!mtouch || !input_dev) { |
139 | err = -ENOMEM; | 139 | err = -ENOMEM; |
140 | goto fail; | 140 | goto fail1; |
141 | } | 141 | } |
142 | 142 | ||
143 | mtouch->serio = serio; | 143 | mtouch->serio = serio; |
@@ -160,14 +160,17 @@ static int mtouch_connect(struct serio *serio, struct serio_driver *drv) | |||
160 | 160 | ||
161 | err = serio_open(serio, drv); | 161 | err = serio_open(serio, drv); |
162 | if (err) | 162 | if (err) |
163 | goto fail; | 163 | goto fail2; |
164 | 164 | ||
165 | input_register_device(mtouch->dev); | 165 | err = input_register_device(mtouch->dev); |
166 | if (err) | ||
167 | goto fail3; | ||
166 | 168 | ||
167 | return 0; | 169 | return 0; |
168 | 170 | ||
169 | fail: serio_set_drvdata(serio, NULL); | 171 | fail3: serio_close(serio); |
170 | input_free_device(input_dev); | 172 | fail2: serio_set_drvdata(serio, NULL); |
173 | fail1: input_free_device(input_dev); | ||
171 | kfree(mtouch); | 174 | kfree(mtouch); |
172 | return err; | 175 | return err; |
173 | } | 176 | } |