diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-09-15 03:01:46 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-10-28 12:52:53 -0400 |
commit | eca1ed196cd5b523c1057204cd3672555ad58dfe (patch) | |
tree | bf60f0c3ab6cbaf3235fe01387009e7df4b0926c /drivers/input/touchscreen/elo.c | |
parent | bd622663192e8ebebb27dc1d9397f352a82d2495 (diff) |
[PATCH] drivers/input/touchscreen: convert to dynamic input_dev allocation
Input: convert drivers/input/touchscreen to dynamic input_dev allocation
This is required for input_dev sysfs integration
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/input/touchscreen/elo.c')
-rw-r--r-- | drivers/input/touchscreen/elo.c | 89 |
1 files changed, 44 insertions, 45 deletions
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c index 3cdc9cab688d..c86a2eb310fd 100644 --- a/drivers/input/touchscreen/elo.c +++ b/drivers/input/touchscreen/elo.c | |||
@@ -36,14 +36,12 @@ MODULE_LICENSE("GPL"); | |||
36 | 36 | ||
37 | #define ELO_MAX_LENGTH 10 | 37 | #define ELO_MAX_LENGTH 10 |
38 | 38 | ||
39 | static char *elo_name = "Elo Serial TouchScreen"; | ||
40 | |||
41 | /* | 39 | /* |
42 | * Per-touchscreen data. | 40 | * Per-touchscreen data. |
43 | */ | 41 | */ |
44 | 42 | ||
45 | struct elo { | 43 | struct elo { |
46 | struct input_dev dev; | 44 | struct input_dev *dev; |
47 | struct serio *serio; | 45 | struct serio *serio; |
48 | int id; | 46 | int id; |
49 | int idx; | 47 | int idx; |
@@ -54,7 +52,7 @@ struct elo { | |||
54 | 52 | ||
55 | static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_regs *regs) | 53 | static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_regs *regs) |
56 | { | 54 | { |
57 | struct input_dev *dev = &elo->dev; | 55 | struct input_dev *dev = elo->dev; |
58 | 56 | ||
59 | elo->csum += elo->data[elo->idx] = data; | 57 | elo->csum += elo->data[elo->idx] = data; |
60 | 58 | ||
@@ -80,7 +78,7 @@ static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_r | |||
80 | input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); | 78 | input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); |
81 | input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); | 79 | input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); |
82 | input_report_abs(dev, ABS_PRESSURE, (elo->data[8] << 8) | elo->data[7]); | 80 | input_report_abs(dev, ABS_PRESSURE, (elo->data[8] << 8) | elo->data[7]); |
83 | input_report_key(dev, BTN_TOUCH, elo->data[2] & 3); | 81 | input_report_key(dev, BTN_TOUCH, elo->data[8] || elo->data[7]); |
84 | input_sync(dev); | 82 | input_sync(dev); |
85 | } | 83 | } |
86 | elo->idx = 0; | 84 | elo->idx = 0; |
@@ -91,7 +89,7 @@ static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_r | |||
91 | 89 | ||
92 | static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_regs *regs) | 90 | static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_regs *regs) |
93 | { | 91 | { |
94 | struct input_dev *dev = &elo->dev; | 92 | struct input_dev *dev = elo->dev; |
95 | 93 | ||
96 | elo->data[elo->idx] = data; | 94 | elo->data[elo->idx] = data; |
97 | 95 | ||
@@ -129,7 +127,7 @@ static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_re | |||
129 | case 5: | 127 | case 5: |
130 | if ((data & 0xf0) == 0) { | 128 | if ((data & 0xf0) == 0) { |
131 | input_report_abs(dev, ABS_PRESSURE, elo->data[5]); | 129 | input_report_abs(dev, ABS_PRESSURE, elo->data[5]); |
132 | input_report_key(dev, BTN_TOUCH, elo->data[5]); | 130 | input_report_key(dev, BTN_TOUCH, !!elo->data[5]); |
133 | } | 131 | } |
134 | input_sync(dev); | 132 | input_sync(dev); |
135 | elo->idx = 0; | 133 | elo->idx = 0; |
@@ -139,7 +137,7 @@ static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_re | |||
139 | 137 | ||
140 | static void elo_process_data_3(struct elo* elo, unsigned char data, struct pt_regs *regs) | 138 | static void elo_process_data_3(struct elo* elo, unsigned char data, struct pt_regs *regs) |
141 | { | 139 | { |
142 | struct input_dev *dev = &elo->dev; | 140 | struct input_dev *dev = elo->dev; |
143 | 141 | ||
144 | elo->data[elo->idx] = data; | 142 | elo->data[elo->idx] = data; |
145 | 143 | ||
@@ -191,7 +189,7 @@ static void elo_disconnect(struct serio *serio) | |||
191 | { | 189 | { |
192 | struct elo* elo = serio_get_drvdata(serio); | 190 | struct elo* elo = serio_get_drvdata(serio); |
193 | 191 | ||
194 | input_unregister_device(&elo->dev); | 192 | input_unregister_device(elo->dev); |
195 | serio_close(serio); | 193 | serio_close(serio); |
196 | serio_set_drvdata(serio, NULL); | 194 | serio_set_drvdata(serio, NULL); |
197 | kfree(elo); | 195 | kfree(elo); |
@@ -206,67 +204,68 @@ static void elo_disconnect(struct serio *serio) | |||
206 | static int elo_connect(struct serio *serio, struct serio_driver *drv) | 204 | static int elo_connect(struct serio *serio, struct serio_driver *drv) |
207 | { | 205 | { |
208 | struct elo *elo; | 206 | struct elo *elo; |
207 | struct input_dev *input_dev; | ||
209 | int err; | 208 | int err; |
210 | 209 | ||
211 | if (!(elo = kmalloc(sizeof(struct elo), GFP_KERNEL))) | 210 | elo = kzalloc(sizeof(struct elo), GFP_KERNEL); |
212 | return -ENOMEM; | 211 | input_dev = input_allocate_device(); |
212 | if (!elo || !input_dev) { | ||
213 | err = -ENOMEM; | ||
214 | goto fail; | ||
215 | } | ||
213 | 216 | ||
214 | memset(elo, 0, sizeof(struct elo)); | 217 | elo->serio = serio; |
218 | elo->id = serio->id.id; | ||
219 | elo->dev = input_dev; | ||
220 | snprintf(elo->phys, sizeof(elo->phys), "%s/input0", serio->phys); | ||
215 | 221 | ||
216 | init_input_dev(&elo->dev); | 222 | input_dev->private = elo; |
217 | elo->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 223 | input_dev->name = "Elo Serial TouchScreen"; |
218 | elo->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 224 | input_dev->phys = elo->phys; |
225 | input_dev->id.bustype = BUS_RS232; | ||
226 | input_dev->id.vendor = SERIO_ELO; | ||
227 | input_dev->id.product = elo->id; | ||
228 | input_dev->id.version = 0x0100; | ||
229 | input_dev->cdev.dev = &serio->dev; | ||
219 | 230 | ||
220 | elo->id = serio->id.id; | 231 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
232 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
221 | 233 | ||
222 | switch (elo->id) { | 234 | switch (elo->id) { |
223 | 235 | ||
224 | case 0: /* 10-byte protocol */ | 236 | case 0: /* 10-byte protocol */ |
225 | input_set_abs_params(&elo->dev, ABS_X, 96, 4000, 0, 0); | 237 | input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0); |
226 | input_set_abs_params(&elo->dev, ABS_Y, 96, 4000, 0, 0); | 238 | input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0); |
227 | input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 255, 0, 0); | 239 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 255, 0, 0); |
228 | break; | 240 | break; |
229 | 241 | ||
230 | case 1: /* 6-byte protocol */ | 242 | case 1: /* 6-byte protocol */ |
231 | input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 15, 0, 0); | 243 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0); |
232 | 244 | ||
233 | case 2: /* 4-byte protocol */ | 245 | case 2: /* 4-byte protocol */ |
234 | input_set_abs_params(&elo->dev, ABS_X, 96, 4000, 0, 0); | 246 | input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0); |
235 | input_set_abs_params(&elo->dev, ABS_Y, 96, 4000, 0, 0); | 247 | input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0); |
236 | break; | 248 | break; |
237 | 249 | ||
238 | case 3: /* 3-byte protocol */ | 250 | case 3: /* 3-byte protocol */ |
239 | input_set_abs_params(&elo->dev, ABS_X, 0, 255, 0, 0); | 251 | input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0); |
240 | input_set_abs_params(&elo->dev, ABS_Y, 0, 255, 0, 0); | 252 | input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0); |
241 | break; | 253 | break; |
242 | } | 254 | } |
243 | 255 | ||
244 | elo->serio = serio; | ||
245 | |||
246 | sprintf(elo->phys, "%s/input0", serio->phys); | ||
247 | |||
248 | elo->dev.private = elo; | ||
249 | elo->dev.name = elo_name; | ||
250 | elo->dev.phys = elo->phys; | ||
251 | elo->dev.id.bustype = BUS_RS232; | ||
252 | elo->dev.id.vendor = SERIO_ELO; | ||
253 | elo->dev.id.product = elo->id; | ||
254 | elo->dev.id.version = 0x0100; | ||
255 | |||
256 | serio_set_drvdata(serio, elo); | 256 | serio_set_drvdata(serio, elo); |
257 | 257 | ||
258 | err = serio_open(serio, drv); | 258 | err = serio_open(serio, drv); |
259 | if (err) { | 259 | if (err) |
260 | serio_set_drvdata(serio, NULL); | 260 | goto fail; |
261 | kfree(elo); | ||
262 | return err; | ||
263 | } | ||
264 | |||
265 | input_register_device(&elo->dev); | ||
266 | |||
267 | printk(KERN_INFO "input: %s on %s\n", elo_name, serio->phys); | ||
268 | 261 | ||
262 | input_register_device(elo->dev); | ||
269 | return 0; | 263 | return 0; |
264 | |||
265 | fail: serio_set_drvdata(serio, NULL); | ||
266 | input_free_device(input_dev); | ||
267 | kfree(elo); | ||
268 | return err; | ||
270 | } | 269 | } |
271 | 270 | ||
272 | /* | 271 | /* |