diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-08-08 02:17:47 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-08-09 16:27:09 -0400 |
commit | 1437dc3089911d42180be11c50a0b960250a1d87 (patch) | |
tree | 0c2fd0949829f4ead4ae76956be01d8fd1201f3a /drivers/input | |
parent | 6777f01728d5fc40e02cc0ae43639bf51cc247dd (diff) |
Input: hil_kbd - prepare for merging with hil_ptr
Rename functions and variables from [hil_]kbd to [hil_]dev in
preparation of merging hil_kbd and hil_ptr.
Tested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/keyboard/hil_kbd.c | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c index fe57044e9e54..235a669a0ac3 100644 --- a/drivers/input/keyboard/hil_kbd.c +++ b/drivers/input/keyboard/hil_kbd.c | |||
@@ -49,7 +49,7 @@ MODULE_DESCRIPTION(HIL_GENERIC_NAME " driver"); | |||
49 | MODULE_LICENSE("Dual BSD/GPL"); | 49 | MODULE_LICENSE("Dual BSD/GPL"); |
50 | MODULE_ALIAS("serio:ty03pr25id00ex*"); | 50 | MODULE_ALIAS("serio:ty03pr25id00ex*"); |
51 | 51 | ||
52 | #define HIL_KBD_MAX_LENGTH 16 | 52 | #define HIL_PACKET_MAX_LENGTH 16 |
53 | 53 | ||
54 | #define HIL_KBD_SET1_UPBIT 0x01 | 54 | #define HIL_KBD_SET1_UPBIT 0x01 |
55 | #define HIL_KBD_SET1_SHIFT 1 | 55 | #define HIL_KBD_SET1_SHIFT 1 |
@@ -67,24 +67,24 @@ static unsigned int hil_kbd_set3[HIL_KEYCODES_SET3_TBLSIZE] __read_mostly = | |||
67 | 67 | ||
68 | static const char hil_language[][16] = { HIL_LOCALE_MAP }; | 68 | static const char hil_language[][16] = { HIL_LOCALE_MAP }; |
69 | 69 | ||
70 | struct hil_kbd { | 70 | struct hil_dev { |
71 | struct input_dev *dev; | 71 | struct input_dev *dev; |
72 | struct serio *serio; | 72 | struct serio *serio; |
73 | 73 | ||
74 | /* Input buffer and index for packets from HIL bus. */ | 74 | /* Input buffer and index for packets from HIL bus. */ |
75 | hil_packet data[HIL_KBD_MAX_LENGTH]; | 75 | hil_packet data[HIL_PACKET_MAX_LENGTH]; |
76 | int idx4; /* four counts per packet */ | 76 | int idx4; /* four counts per packet */ |
77 | 77 | ||
78 | /* Raw device info records from HIL bus, see hil.h for fields. */ | 78 | /* Raw device info records from HIL bus, see hil.h for fields. */ |
79 | char idd[HIL_KBD_MAX_LENGTH]; /* DID byte and IDD record */ | 79 | char idd[HIL_PACKET_MAX_LENGTH]; /* DID byte and IDD record */ |
80 | char rsc[HIL_KBD_MAX_LENGTH]; /* RSC record */ | 80 | char rsc[HIL_PACKET_MAX_LENGTH]; /* RSC record */ |
81 | char exd[HIL_KBD_MAX_LENGTH]; /* EXD record */ | 81 | char exd[HIL_PACKET_MAX_LENGTH]; /* EXD record */ |
82 | char rnm[HIL_KBD_MAX_LENGTH + 1]; /* RNM record + NULL term. */ | 82 | char rnm[HIL_PACKET_MAX_LENGTH + 1]; /* RNM record + NULL term. */ |
83 | 83 | ||
84 | struct completion cmd_done; | 84 | struct completion cmd_done; |
85 | }; | 85 | }; |
86 | 86 | ||
87 | static bool hil_kbd_is_command_response(hil_packet p) | 87 | static bool hil_dev_is_command_response(hil_packet p) |
88 | { | 88 | { |
89 | if ((p & ~HIL_CMDCT_POL) == (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL)) | 89 | if ((p & ~HIL_CMDCT_POL) == (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL)) |
90 | return false; | 90 | return false; |
@@ -95,31 +95,31 @@ static bool hil_kbd_is_command_response(hil_packet p) | |||
95 | return true; | 95 | return true; |
96 | } | 96 | } |
97 | 97 | ||
98 | static void hil_kbd_handle_command_response(struct hil_kbd *kbd) | 98 | static void hil_dev_handle_command_response(struct hil_dev *dev) |
99 | { | 99 | { |
100 | hil_packet p; | 100 | hil_packet p; |
101 | char *buf; | 101 | char *buf; |
102 | int i, idx; | 102 | int i, idx; |
103 | 103 | ||
104 | idx = kbd->idx4 / 4; | 104 | idx = dev->idx4 / 4; |
105 | p = kbd->data[idx - 1]; | 105 | p = dev->data[idx - 1]; |
106 | 106 | ||
107 | switch (p & HIL_PKT_DATA_MASK) { | 107 | switch (p & HIL_PKT_DATA_MASK) { |
108 | case HIL_CMD_IDD: | 108 | case HIL_CMD_IDD: |
109 | buf = kbd->idd; | 109 | buf = dev->idd; |
110 | break; | 110 | break; |
111 | 111 | ||
112 | case HIL_CMD_RSC: | 112 | case HIL_CMD_RSC: |
113 | buf = kbd->rsc; | 113 | buf = dev->rsc; |
114 | break; | 114 | break; |
115 | 115 | ||
116 | case HIL_CMD_EXD: | 116 | case HIL_CMD_EXD: |
117 | buf = kbd->exd; | 117 | buf = dev->exd; |
118 | break; | 118 | break; |
119 | 119 | ||
120 | case HIL_CMD_RNM: | 120 | case HIL_CMD_RNM: |
121 | kbd->rnm[HIL_KBD_MAX_LENGTH] = 0; | 121 | dev->rnm[HIL_PACKET_MAX_LENGTH] = 0; |
122 | buf = kbd->rnm; | 122 | buf = dev->rnm; |
123 | break; | 123 | break; |
124 | 124 | ||
125 | default: | 125 | default: |
@@ -132,14 +132,14 @@ static void hil_kbd_handle_command_response(struct hil_kbd *kbd) | |||
132 | } | 132 | } |
133 | 133 | ||
134 | for (i = 0; i < idx; i++) | 134 | for (i = 0; i < idx; i++) |
135 | buf[i] = kbd->data[i] & HIL_PKT_DATA_MASK; | 135 | buf[i] = dev->data[i] & HIL_PKT_DATA_MASK; |
136 | for (; i < HIL_KBD_MAX_LENGTH; i++) | 136 | for (; i < HIL_PACKET_MAX_LENGTH; i++) |
137 | buf[i] = 0; | 137 | buf[i] = 0; |
138 | out: | 138 | out: |
139 | complete(&kbd->cmd_done); | 139 | complete(&dev->cmd_done); |
140 | } | 140 | } |
141 | 141 | ||
142 | static void hil_kbd_handle_key_events(struct hil_kbd *kbd) | 142 | static void hil_dev_handle_key_events(struct hil_dev *kbd) |
143 | { | 143 | { |
144 | struct input_dev *dev = kbd->dev; | 144 | struct input_dev *dev = kbd->dev; |
145 | int idx = kbd->idx4 / 4; | 145 | int idx = kbd->idx4 / 4; |
@@ -198,125 +198,125 @@ static void hil_kbd_handle_key_events(struct hil_kbd *kbd) | |||
198 | input_sync(dev); | 198 | input_sync(dev); |
199 | } | 199 | } |
200 | 200 | ||
201 | static void hil_kbd_process_err(struct hil_kbd *kbd) | 201 | static void hil_dev_process_err(struct hil_dev *dev) |
202 | { | 202 | { |
203 | printk(KERN_WARNING PREFIX "errored HIL packet\n"); | 203 | printk(KERN_WARNING PREFIX "errored HIL packet\n"); |
204 | kbd->idx4 = 0; | 204 | dev->idx4 = 0; |
205 | complete(&kbd->cmd_done); /* just in case somebody is waiting */ | 205 | complete(&dev->cmd_done); /* just in case somebody is waiting */ |
206 | } | 206 | } |
207 | 207 | ||
208 | static irqreturn_t hil_kbd_interrupt(struct serio *serio, | 208 | static irqreturn_t hil_dev_interrupt(struct serio *serio, |
209 | unsigned char data, unsigned int flags) | 209 | unsigned char data, unsigned int flags) |
210 | { | 210 | { |
211 | struct hil_kbd *kbd; | 211 | struct hil_dev *dev; |
212 | hil_packet packet; | 212 | hil_packet packet; |
213 | int idx; | 213 | int idx; |
214 | 214 | ||
215 | kbd = serio_get_drvdata(serio); | 215 | dev = serio_get_drvdata(serio); |
216 | BUG_ON(kbd == NULL); | 216 | BUG_ON(dev == NULL); |
217 | 217 | ||
218 | if (kbd->idx4 >= HIL_KBD_MAX_LENGTH * sizeof(hil_packet)) { | 218 | if (dev->idx4 >= HIL_PACKET_MAX_LENGTH * sizeof(hil_packet)) { |
219 | hil_kbd_process_err(kbd); | 219 | hil_dev_process_err(dev); |
220 | goto out; | 220 | goto out; |
221 | } | 221 | } |
222 | 222 | ||
223 | idx = kbd->idx4 / 4; | 223 | idx = dev->idx4 / 4; |
224 | if (!(kbd->idx4 % 4)) | 224 | if (!(dev->idx4 % 4)) |
225 | kbd->data[idx] = 0; | 225 | dev->data[idx] = 0; |
226 | packet = kbd->data[idx]; | 226 | packet = dev->data[idx]; |
227 | packet |= ((hil_packet)data) << ((3 - (kbd->idx4 % 4)) * 8); | 227 | packet |= ((hil_packet)data) << ((3 - (dev->idx4 % 4)) * 8); |
228 | kbd->data[idx] = packet; | 228 | dev->data[idx] = packet; |
229 | 229 | ||
230 | /* Records of N 4-byte hil_packets must terminate with a command. */ | 230 | /* Records of N 4-byte hil_packets must terminate with a command. */ |
231 | if ((++kbd->idx4 % 4) == 0) { | 231 | if ((++dev->idx4 % 4) == 0) { |
232 | if ((packet & 0xffff0000) != HIL_ERR_INT) { | 232 | if ((packet & 0xffff0000) != HIL_ERR_INT) { |
233 | hil_kbd_process_err(kbd); | 233 | hil_dev_process_err(dev); |
234 | } else if (packet & HIL_PKT_CMD) { | 234 | } else if (packet & HIL_PKT_CMD) { |
235 | if (hil_kbd_is_command_response(packet)) | 235 | if (hil_dev_is_command_response(packet)) |
236 | hil_kbd_handle_command_response(kbd); | 236 | hil_dev_handle_command_response(dev); |
237 | else | 237 | else |
238 | hil_kbd_handle_key_events(kbd); | 238 | hil_dev_handle_key_events(dev); |
239 | kbd->idx4 = 0; | 239 | dev->idx4 = 0; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | out: | 242 | out: |
243 | return IRQ_HANDLED; | 243 | return IRQ_HANDLED; |
244 | } | 244 | } |
245 | 245 | ||
246 | static void hil_kbd_disconnect(struct serio *serio) | 246 | static void hil_dev_disconnect(struct serio *serio) |
247 | { | 247 | { |
248 | struct hil_kbd *kbd = serio_get_drvdata(serio); | 248 | struct hil_dev *dev = serio_get_drvdata(serio); |
249 | 249 | ||
250 | BUG_ON(kbd == NULL); | 250 | BUG_ON(dev == NULL); |
251 | 251 | ||
252 | serio_close(serio); | 252 | serio_close(serio); |
253 | input_unregister_device(kbd->dev); | 253 | input_unregister_device(dev->dev); |
254 | kfree(kbd); | 254 | kfree(dev); |
255 | } | 255 | } |
256 | 256 | ||
257 | static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | 257 | static int hil_dev_connect(struct serio *serio, struct serio_driver *drv) |
258 | { | 258 | { |
259 | struct hil_kbd *kbd; | 259 | struct hil_dev *dev; |
260 | struct input_dev *input_dev; | 260 | struct input_dev *input_dev; |
261 | uint8_t did, *idd; | 261 | uint8_t did, *idd; |
262 | int i; | 262 | int i; |
263 | int error; | 263 | int error; |
264 | 264 | ||
265 | kbd = kzalloc(sizeof(*kbd), GFP_KERNEL); | 265 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
266 | input_dev = input_allocate_device(); | 266 | input_dev = input_allocate_device(); |
267 | if (!kbd || !input_dev) { | 267 | if (!dev || !input_dev) { |
268 | error = -ENOMEM; | 268 | error = -ENOMEM; |
269 | goto bail0; | 269 | goto bail0; |
270 | } | 270 | } |
271 | 271 | ||
272 | kbd->serio = serio; | 272 | dev->serio = serio; |
273 | kbd->dev = input_dev; | 273 | dev->dev = input_dev; |
274 | 274 | ||
275 | error = serio_open(serio, drv); | 275 | error = serio_open(serio, drv); |
276 | if (error) | 276 | if (error) |
277 | goto bail0; | 277 | goto bail0; |
278 | 278 | ||
279 | serio_set_drvdata(serio, kbd); | 279 | serio_set_drvdata(serio, dev); |
280 | 280 | ||
281 | /* Get device info. MLC driver supplies devid/status/etc. */ | 281 | /* Get device info. MLC driver supplies devid/status/etc. */ |
282 | init_completion(&kbd->cmd_done); | 282 | init_completion(&dev->cmd_done); |
283 | serio_write(serio, 0); | 283 | serio_write(serio, 0); |
284 | serio_write(serio, 0); | 284 | serio_write(serio, 0); |
285 | serio_write(serio, HIL_PKT_CMD >> 8); | 285 | serio_write(serio, HIL_PKT_CMD >> 8); |
286 | serio_write(serio, HIL_CMD_IDD); | 286 | serio_write(serio, HIL_CMD_IDD); |
287 | error = wait_for_completion_killable(&kbd->cmd_done); | 287 | error = wait_for_completion_killable(&dev->cmd_done); |
288 | if (error) | 288 | if (error) |
289 | goto bail1; | 289 | goto bail1; |
290 | 290 | ||
291 | init_completion(&kbd->cmd_done); | 291 | init_completion(&dev->cmd_done); |
292 | serio_write(serio, 0); | 292 | serio_write(serio, 0); |
293 | serio_write(serio, 0); | 293 | serio_write(serio, 0); |
294 | serio_write(serio, HIL_PKT_CMD >> 8); | 294 | serio_write(serio, HIL_PKT_CMD >> 8); |
295 | serio_write(serio, HIL_CMD_RSC); | 295 | serio_write(serio, HIL_CMD_RSC); |
296 | error = wait_for_completion_killable(&kbd->cmd_done); | 296 | error = wait_for_completion_killable(&dev->cmd_done); |
297 | if (error) | 297 | if (error) |
298 | goto bail1; | 298 | goto bail1; |
299 | 299 | ||
300 | init_completion(&kbd->cmd_done); | 300 | init_completion(&dev->cmd_done); |
301 | serio_write(serio, 0); | 301 | serio_write(serio, 0); |
302 | serio_write(serio, 0); | 302 | serio_write(serio, 0); |
303 | serio_write(serio, HIL_PKT_CMD >> 8); | 303 | serio_write(serio, HIL_PKT_CMD >> 8); |
304 | serio_write(serio, HIL_CMD_RNM); | 304 | serio_write(serio, HIL_CMD_RNM); |
305 | error = wait_for_completion_killable(&kbd->cmd_done); | 305 | error = wait_for_completion_killable(&dev->cmd_done); |
306 | if (error) | 306 | if (error) |
307 | goto bail1; | 307 | goto bail1; |
308 | 308 | ||
309 | init_completion(&kbd->cmd_done); | 309 | init_completion(&dev->cmd_done); |
310 | serio_write(serio, 0); | 310 | serio_write(serio, 0); |
311 | serio_write(serio, 0); | 311 | serio_write(serio, 0); |
312 | serio_write(serio, HIL_PKT_CMD >> 8); | 312 | serio_write(serio, HIL_PKT_CMD >> 8); |
313 | serio_write(serio, HIL_CMD_EXD); | 313 | serio_write(serio, HIL_CMD_EXD); |
314 | error = wait_for_completion_killable(&kbd->cmd_done); | 314 | error = wait_for_completion_killable(&dev->cmd_done); |
315 | if (error) | 315 | if (error) |
316 | goto bail1; | 316 | goto bail1; |
317 | 317 | ||
318 | did = kbd->idd[0]; | 318 | did = dev->idd[0]; |
319 | idd = kbd->idd + 1; | 319 | idd = dev->idd + 1; |
320 | switch (did & HIL_IDD_DID_TYPE_MASK) { | 320 | switch (did & HIL_IDD_DID_TYPE_MASK) { |
321 | case HIL_IDD_DID_TYPE_KB_INTEGRAL: | 321 | case HIL_IDD_DID_TYPE_KB_INTEGRAL: |
322 | case HIL_IDD_DID_TYPE_KB_ITF: | 322 | case HIL_IDD_DID_TYPE_KB_ITF: |
@@ -340,7 +340,7 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
340 | input_dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; | 340 | input_dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; |
341 | input_dev->keycodesize = sizeof(hil_kbd_set1[0]); | 341 | input_dev->keycodesize = sizeof(hil_kbd_set1[0]); |
342 | input_dev->keycode = hil_kbd_set1; | 342 | input_dev->keycode = hil_kbd_set1; |
343 | input_dev->name = strlen(kbd->rnm) ? kbd->rnm : HIL_GENERIC_NAME; | 343 | input_dev->name = strlen(dev->rnm) ? dev->rnm : HIL_GENERIC_NAME; |
344 | input_dev->phys = "hpkbd/input0"; /* XXX */ | 344 | input_dev->phys = "hpkbd/input0"; /* XXX */ |
345 | 345 | ||
346 | input_dev->id.bustype = BUS_HIL; | 346 | input_dev->id.bustype = BUS_HIL; |
@@ -361,7 +361,7 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
361 | serio_write(serio, HIL_CMD_EK1); /* Enable Keyswitch Autorepeat 1 */ | 361 | serio_write(serio, HIL_CMD_EK1); /* Enable Keyswitch Autorepeat 1 */ |
362 | /* No need to wait for completion */ | 362 | /* No need to wait for completion */ |
363 | 363 | ||
364 | error = input_register_device(kbd->dev); | 364 | error = input_register_device(input_dev); |
365 | if (error) | 365 | if (error) |
366 | goto bail1; | 366 | goto bail1; |
367 | 367 | ||
@@ -372,11 +372,11 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
372 | serio_set_drvdata(serio, NULL); | 372 | serio_set_drvdata(serio, NULL); |
373 | bail0: | 373 | bail0: |
374 | input_free_device(input_dev); | 374 | input_free_device(input_dev); |
375 | kfree(kbd); | 375 | kfree(dev); |
376 | return error; | 376 | return error; |
377 | } | 377 | } |
378 | 378 | ||
379 | static struct serio_device_id hil_kbd_ids[] = { | 379 | static struct serio_device_id hil_dev_ids[] = { |
380 | { | 380 | { |
381 | .type = SERIO_HIL_MLC, | 381 | .type = SERIO_HIL_MLC, |
382 | .proto = SERIO_HIL, | 382 | .proto = SERIO_HIL, |
@@ -386,26 +386,26 @@ static struct serio_device_id hil_kbd_ids[] = { | |||
386 | { 0 } | 386 | { 0 } |
387 | }; | 387 | }; |
388 | 388 | ||
389 | static struct serio_driver hil_kbd_serio_drv = { | 389 | static struct serio_driver hil_serio_drv = { |
390 | .driver = { | 390 | .driver = { |
391 | .name = "hil_kbd", | 391 | .name = "hil_kbd", |
392 | }, | 392 | }, |
393 | .description = "HP HIL keyboard driver", | 393 | .description = "HP HIL keyboard driver", |
394 | .id_table = hil_kbd_ids, | 394 | .id_table = hil_dev_ids, |
395 | .connect = hil_kbd_connect, | 395 | .connect = hil_dev_connect, |
396 | .disconnect = hil_kbd_disconnect, | 396 | .disconnect = hil_dev_disconnect, |
397 | .interrupt = hil_kbd_interrupt | 397 | .interrupt = hil_dev_interrupt |
398 | }; | 398 | }; |
399 | 399 | ||
400 | static int __init hil_kbd_init(void) | 400 | static int __init hil_dev_init(void) |
401 | { | 401 | { |
402 | return serio_register_driver(&hil_kbd_serio_drv); | 402 | return serio_register_driver(&hil_serio_drv); |
403 | } | 403 | } |
404 | 404 | ||
405 | static void __exit hil_kbd_exit(void) | 405 | static void __exit hil_dev_exit(void) |
406 | { | 406 | { |
407 | serio_unregister_driver(&hil_kbd_serio_drv); | 407 | serio_unregister_driver(&hil_serio_drv); |
408 | } | 408 | } |
409 | 409 | ||
410 | module_init(hil_kbd_init); | 410 | module_init(hil_dev_init); |
411 | module_exit(hil_kbd_exit); | 411 | module_exit(hil_dev_exit); |