diff options
author | Helge Deller <deller@gmx.de> | 2007-02-28 23:51:29 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2007-02-28 23:51:29 -0500 |
commit | ffd51f46cdf856c0b453d2828a74d552cc15f881 (patch) | |
tree | 2322b5c7dbbbf876e549e40ff340240b6a59af20 /drivers/input/keyboard/hil_kbd.c | |
parent | 3acaf540a33199141695f2e2fcfa8829053159bf (diff) |
Input: HIL - cleanup coding style
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/keyboard/hil_kbd.c')
-rw-r--r-- | drivers/input/keyboard/hil_kbd.c | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c index 7143f37927cd..18f4d417576f 100644 --- a/drivers/input/keyboard/hil_kbd.c +++ b/drivers/input/keyboard/hil_kbd.c | |||
@@ -94,10 +94,12 @@ static void hil_kbd_process_record(struct hil_kbd *kbd) | |||
94 | idx = kbd->idx4/4; | 94 | idx = kbd->idx4/4; |
95 | p = data[idx - 1]; | 95 | p = data[idx - 1]; |
96 | 96 | ||
97 | if ((p & ~HIL_CMDCT_POL) == | 97 | if ((p & ~HIL_CMDCT_POL) == |
98 | (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL)) goto report; | 98 | (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL)) |
99 | if ((p & ~HIL_CMDCT_RPL) == | 99 | goto report; |
100 | (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_RPL)) goto report; | 100 | if ((p & ~HIL_CMDCT_RPL) == |
101 | (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_RPL)) | ||
102 | goto report; | ||
101 | 103 | ||
102 | /* Not a poll response. See if we are loading config records. */ | 104 | /* Not a poll response. See if we are loading config records. */ |
103 | switch (p & HIL_PKT_DATA_MASK) { | 105 | switch (p & HIL_PKT_DATA_MASK) { |
@@ -107,27 +109,32 @@ static void hil_kbd_process_record(struct hil_kbd *kbd) | |||
107 | for (; i < HIL_KBD_MAX_LENGTH; i++) | 109 | for (; i < HIL_KBD_MAX_LENGTH; i++) |
108 | kbd->idd[i] = 0; | 110 | kbd->idd[i] = 0; |
109 | break; | 111 | break; |
112 | |||
110 | case HIL_CMD_RSC: | 113 | case HIL_CMD_RSC: |
111 | for (i = 0; i < idx; i++) | 114 | for (i = 0; i < idx; i++) |
112 | kbd->rsc[i] = kbd->data[i] & HIL_PKT_DATA_MASK; | 115 | kbd->rsc[i] = kbd->data[i] & HIL_PKT_DATA_MASK; |
113 | for (; i < HIL_KBD_MAX_LENGTH; i++) | 116 | for (; i < HIL_KBD_MAX_LENGTH; i++) |
114 | kbd->rsc[i] = 0; | 117 | kbd->rsc[i] = 0; |
115 | break; | 118 | break; |
119 | |||
116 | case HIL_CMD_EXD: | 120 | case HIL_CMD_EXD: |
117 | for (i = 0; i < idx; i++) | 121 | for (i = 0; i < idx; i++) |
118 | kbd->exd[i] = kbd->data[i] & HIL_PKT_DATA_MASK; | 122 | kbd->exd[i] = kbd->data[i] & HIL_PKT_DATA_MASK; |
119 | for (; i < HIL_KBD_MAX_LENGTH; i++) | 123 | for (; i < HIL_KBD_MAX_LENGTH; i++) |
120 | kbd->exd[i] = 0; | 124 | kbd->exd[i] = 0; |
121 | break; | 125 | break; |
126 | |||
122 | case HIL_CMD_RNM: | 127 | case HIL_CMD_RNM: |
123 | for (i = 0; i < idx; i++) | 128 | for (i = 0; i < idx; i++) |
124 | kbd->rnm[i] = kbd->data[i] & HIL_PKT_DATA_MASK; | 129 | kbd->rnm[i] = kbd->data[i] & HIL_PKT_DATA_MASK; |
125 | for (; i < HIL_KBD_MAX_LENGTH + 1; i++) | 130 | for (; i < HIL_KBD_MAX_LENGTH + 1; i++) |
126 | kbd->rnm[i] = '\0'; | 131 | kbd->rnm[i] = '\0'; |
127 | break; | 132 | break; |
133 | |||
128 | default: | 134 | default: |
129 | /* These occur when device isn't present */ | 135 | /* These occur when device isn't present */ |
130 | if (p == (HIL_ERR_INT | HIL_PKT_CMD)) break; | 136 | if (p == (HIL_ERR_INT | HIL_PKT_CMD)) |
137 | break; | ||
131 | /* Anything else we'd like to know about. */ | 138 | /* Anything else we'd like to know about. */ |
132 | printk(KERN_WARNING PREFIX "Device sent unknown record %x\n", p); | 139 | printk(KERN_WARNING PREFIX "Device sent unknown record %x\n", p); |
133 | break; | 140 | break; |
@@ -139,16 +146,19 @@ static void hil_kbd_process_record(struct hil_kbd *kbd) | |||
139 | switch (kbd->data[0] & HIL_POL_CHARTYPE_MASK) { | 146 | switch (kbd->data[0] & HIL_POL_CHARTYPE_MASK) { |
140 | case HIL_POL_CHARTYPE_NONE: | 147 | case HIL_POL_CHARTYPE_NONE: |
141 | break; | 148 | break; |
149 | |||
142 | case HIL_POL_CHARTYPE_ASCII: | 150 | case HIL_POL_CHARTYPE_ASCII: |
143 | while (cnt < idx - 1) | 151 | while (cnt < idx - 1) |
144 | input_report_key(dev, kbd->data[cnt++] & 0x7f, 1); | 152 | input_report_key(dev, kbd->data[cnt++] & 0x7f, 1); |
145 | break; | 153 | break; |
154 | |||
146 | case HIL_POL_CHARTYPE_RSVD1: | 155 | case HIL_POL_CHARTYPE_RSVD1: |
147 | case HIL_POL_CHARTYPE_RSVD2: | 156 | case HIL_POL_CHARTYPE_RSVD2: |
148 | case HIL_POL_CHARTYPE_BINARY: | 157 | case HIL_POL_CHARTYPE_BINARY: |
149 | while (cnt < idx - 1) | 158 | while (cnt < idx - 1) |
150 | input_report_key(dev, kbd->data[cnt++], 1); | 159 | input_report_key(dev, kbd->data[cnt++], 1); |
151 | break; | 160 | break; |
161 | |||
152 | case HIL_POL_CHARTYPE_SET1: | 162 | case HIL_POL_CHARTYPE_SET1: |
153 | while (cnt < idx - 1) { | 163 | while (cnt < idx - 1) { |
154 | unsigned int key; | 164 | unsigned int key; |
@@ -161,6 +171,7 @@ static void hil_kbd_process_record(struct hil_kbd *kbd) | |||
161 | input_report_key(dev, key, !up); | 171 | input_report_key(dev, key, !up); |
162 | } | 172 | } |
163 | break; | 173 | break; |
174 | |||
164 | case HIL_POL_CHARTYPE_SET2: | 175 | case HIL_POL_CHARTYPE_SET2: |
165 | while (cnt < idx - 1) { | 176 | while (cnt < idx - 1) { |
166 | unsigned int key; | 177 | unsigned int key; |
@@ -173,6 +184,7 @@ static void hil_kbd_process_record(struct hil_kbd *kbd) | |||
173 | input_report_key(dev, key, !up); | 184 | input_report_key(dev, key, !up); |
174 | } | 185 | } |
175 | break; | 186 | break; |
187 | |||
176 | case HIL_POL_CHARTYPE_SET3: | 188 | case HIL_POL_CHARTYPE_SET3: |
177 | while (cnt < idx - 1) { | 189 | while (cnt < idx - 1) { |
178 | unsigned int key; | 190 | unsigned int key; |
@@ -191,42 +203,43 @@ static void hil_kbd_process_record(struct hil_kbd *kbd) | |||
191 | up(&kbd->sem); | 203 | up(&kbd->sem); |
192 | } | 204 | } |
193 | 205 | ||
194 | static void hil_kbd_process_err(struct hil_kbd *kbd) { | 206 | static void hil_kbd_process_err(struct hil_kbd *kbd) |
207 | { | ||
195 | printk(KERN_WARNING PREFIX "errored HIL packet\n"); | 208 | printk(KERN_WARNING PREFIX "errored HIL packet\n"); |
196 | kbd->idx4 = 0; | 209 | kbd->idx4 = 0; |
197 | up(&kbd->sem); | 210 | up(&kbd->sem); |
198 | } | 211 | } |
199 | 212 | ||
200 | static irqreturn_t hil_kbd_interrupt(struct serio *serio, | 213 | static irqreturn_t hil_kbd_interrupt(struct serio *serio, |
201 | unsigned char data, unsigned int flags) | 214 | unsigned char data, unsigned int flags) |
202 | { | 215 | { |
203 | struct hil_kbd *kbd; | 216 | struct hil_kbd *kbd; |
204 | hil_packet packet; | 217 | hil_packet packet; |
205 | int idx; | 218 | int idx; |
206 | 219 | ||
207 | kbd = serio_get_drvdata(serio); | 220 | kbd = serio_get_drvdata(serio); |
208 | if (kbd == NULL) { | 221 | BUG_ON(kbd == NULL); |
209 | BUG(); | ||
210 | return IRQ_HANDLED; | ||
211 | } | ||
212 | 222 | ||
213 | if (kbd->idx4 >= (HIL_KBD_MAX_LENGTH * sizeof(hil_packet))) { | 223 | if (kbd->idx4 >= (HIL_KBD_MAX_LENGTH * sizeof(hil_packet))) { |
214 | hil_kbd_process_err(kbd); | 224 | hil_kbd_process_err(kbd); |
215 | return IRQ_HANDLED; | 225 | return IRQ_HANDLED; |
216 | } | 226 | } |
217 | idx = kbd->idx4/4; | 227 | idx = kbd->idx4/4; |
218 | if (!(kbd->idx4 % 4)) kbd->data[idx] = 0; | 228 | if (!(kbd->idx4 % 4)) |
229 | kbd->data[idx] = 0; | ||
219 | packet = kbd->data[idx]; | 230 | packet = kbd->data[idx]; |
220 | packet |= ((hil_packet)data) << ((3 - (kbd->idx4 % 4)) * 8); | 231 | packet |= ((hil_packet)data) << ((3 - (kbd->idx4 % 4)) * 8); |
221 | kbd->data[idx] = packet; | 232 | kbd->data[idx] = packet; |
222 | 233 | ||
223 | /* Records of N 4-byte hil_packets must terminate with a command. */ | 234 | /* Records of N 4-byte hil_packets must terminate with a command. */ |
224 | if ((++(kbd->idx4)) % 4) return IRQ_HANDLED; | 235 | if ((++(kbd->idx4)) % 4) |
236 | return IRQ_HANDLED; | ||
225 | if ((packet & 0xffff0000) != HIL_ERR_INT) { | 237 | if ((packet & 0xffff0000) != HIL_ERR_INT) { |
226 | hil_kbd_process_err(kbd); | 238 | hil_kbd_process_err(kbd); |
227 | return IRQ_HANDLED; | 239 | return IRQ_HANDLED; |
228 | } | 240 | } |
229 | if (packet & HIL_PKT_CMD) hil_kbd_process_record(kbd); | 241 | if (packet & HIL_PKT_CMD) |
242 | hil_kbd_process_record(kbd); | ||
230 | return IRQ_HANDLED; | 243 | return IRQ_HANDLED; |
231 | } | 244 | } |
232 | 245 | ||
@@ -235,10 +248,7 @@ static void hil_kbd_disconnect(struct serio *serio) | |||
235 | struct hil_kbd *kbd; | 248 | struct hil_kbd *kbd; |
236 | 249 | ||
237 | kbd = serio_get_drvdata(serio); | 250 | kbd = serio_get_drvdata(serio); |
238 | if (kbd == NULL) { | 251 | BUG_ON(kbd == NULL); |
239 | BUG(); | ||
240 | return; | ||
241 | } | ||
242 | 252 | ||
243 | serio_close(serio); | 253 | serio_close(serio); |
244 | input_unregister_device(kbd->dev); | 254 | input_unregister_device(kbd->dev); |
@@ -267,34 +277,34 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
267 | serio_set_drvdata(serio, kbd); | 277 | serio_set_drvdata(serio, kbd); |
268 | kbd->serio = serio; | 278 | kbd->serio = serio; |
269 | 279 | ||
270 | init_MUTEX_LOCKED(&(kbd->sem)); | 280 | init_MUTEX_LOCKED(&kbd->sem); |
271 | 281 | ||
272 | /* Get device info. MLC driver supplies devid/status/etc. */ | 282 | /* Get device info. MLC driver supplies devid/status/etc. */ |
273 | serio->write(serio, 0); | 283 | serio->write(serio, 0); |
274 | serio->write(serio, 0); | 284 | serio->write(serio, 0); |
275 | serio->write(serio, HIL_PKT_CMD >> 8); | 285 | serio->write(serio, HIL_PKT_CMD >> 8); |
276 | serio->write(serio, HIL_CMD_IDD); | 286 | serio->write(serio, HIL_CMD_IDD); |
277 | down(&(kbd->sem)); | 287 | down(&kbd->sem); |
278 | 288 | ||
279 | serio->write(serio, 0); | 289 | serio->write(serio, 0); |
280 | serio->write(serio, 0); | 290 | serio->write(serio, 0); |
281 | serio->write(serio, HIL_PKT_CMD >> 8); | 291 | serio->write(serio, HIL_PKT_CMD >> 8); |
282 | serio->write(serio, HIL_CMD_RSC); | 292 | serio->write(serio, HIL_CMD_RSC); |
283 | down(&(kbd->sem)); | 293 | down(&kbd->sem); |
284 | 294 | ||
285 | serio->write(serio, 0); | 295 | serio->write(serio, 0); |
286 | serio->write(serio, 0); | 296 | serio->write(serio, 0); |
287 | serio->write(serio, HIL_PKT_CMD >> 8); | 297 | serio->write(serio, HIL_PKT_CMD >> 8); |
288 | serio->write(serio, HIL_CMD_RNM); | 298 | serio->write(serio, HIL_CMD_RNM); |
289 | down(&(kbd->sem)); | 299 | down(&kbd->sem); |
290 | 300 | ||
291 | serio->write(serio, 0); | 301 | serio->write(serio, 0); |
292 | serio->write(serio, 0); | 302 | serio->write(serio, 0); |
293 | serio->write(serio, HIL_PKT_CMD >> 8); | 303 | serio->write(serio, HIL_PKT_CMD >> 8); |
294 | serio->write(serio, HIL_CMD_EXD); | 304 | serio->write(serio, HIL_CMD_EXD); |
295 | down(&(kbd->sem)); | 305 | down(&kbd->sem); |
296 | 306 | ||
297 | up(&(kbd->sem)); | 307 | up(&kbd->sem); |
298 | 308 | ||
299 | did = kbd->idd[0]; | 309 | did = kbd->idd[0]; |
300 | idd = kbd->idd + 1; | 310 | idd = kbd->idd + 1; |
@@ -310,12 +320,11 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
310 | goto bail2; | 320 | goto bail2; |
311 | } | 321 | } |
312 | 322 | ||
313 | if(HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) { | 323 | if (HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) { |
314 | printk(KERN_INFO PREFIX "keyboards only, no combo devices supported.\n"); | 324 | printk(KERN_INFO PREFIX "keyboards only, no combo devices supported.\n"); |
315 | goto bail2; | 325 | goto bail2; |
316 | } | 326 | } |
317 | 327 | ||
318 | |||
319 | kbd->dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 328 | kbd->dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); |
320 | kbd->dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); | 329 | kbd->dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); |
321 | kbd->dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; | 330 | kbd->dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; |
@@ -344,8 +353,8 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
344 | serio->write(serio, 0); | 353 | serio->write(serio, 0); |
345 | serio->write(serio, HIL_PKT_CMD >> 8); | 354 | serio->write(serio, HIL_PKT_CMD >> 8); |
346 | serio->write(serio, HIL_CMD_EK1); /* Enable Keyswitch Autorepeat 1 */ | 355 | serio->write(serio, HIL_CMD_EK1); /* Enable Keyswitch Autorepeat 1 */ |
347 | down(&(kbd->sem)); | 356 | down(&kbd->sem); |
348 | up(&(kbd->sem)); | 357 | up(&kbd->sem); |
349 | 358 | ||
350 | return 0; | 359 | return 0; |
351 | bail2: | 360 | bail2: |
@@ -374,20 +383,20 @@ static struct serio_driver hil_kbd_serio_drv = { | |||
374 | }, | 383 | }, |
375 | .description = "HP HIL keyboard driver", | 384 | .description = "HP HIL keyboard driver", |
376 | .id_table = hil_kbd_ids, | 385 | .id_table = hil_kbd_ids, |
377 | .connect = hil_kbd_connect, | 386 | .connect = hil_kbd_connect, |
378 | .disconnect = hil_kbd_disconnect, | 387 | .disconnect = hil_kbd_disconnect, |
379 | .interrupt = hil_kbd_interrupt | 388 | .interrupt = hil_kbd_interrupt |
380 | }; | 389 | }; |
381 | 390 | ||
382 | static int __init hil_kbd_init(void) | 391 | static int __init hil_kbd_init(void) |
383 | { | 392 | { |
384 | return serio_register_driver(&hil_kbd_serio_drv); | 393 | return serio_register_driver(&hil_kbd_serio_drv); |
385 | } | 394 | } |
386 | 395 | ||
387 | static void __exit hil_kbd_exit(void) | 396 | static void __exit hil_kbd_exit(void) |
388 | { | 397 | { |
389 | serio_unregister_driver(&hil_kbd_serio_drv); | 398 | serio_unregister_driver(&hil_kbd_serio_drv); |
390 | } | 399 | } |
391 | 400 | ||
392 | module_init(hil_kbd_init); | 401 | module_init(hil_kbd_init); |
393 | module_exit(hil_kbd_exit); | 402 | module_exit(hil_kbd_exit); |