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/hp680_ts_input.c | |
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/hp680_ts_input.c')
-rw-r--r-- | drivers/input/touchscreen/hp680_ts_input.c | 29 |
1 files changed, 19 insertions, 10 deletions
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); |