diff options
| author | Cyrill V. Gorcunov <gorcunov@gmail.com> | 2007-02-10 01:29:19 -0500 |
|---|---|---|
| committer | Dmitry Torokhov <dtor@insightbb.com> | 2007-02-10 01:29:19 -0500 |
| commit | b350620cc5e8e62782a4d47bf45952442a18a0b0 (patch) | |
| tree | 03850d27686950a0aba6cbd702e70334dc39c24c | |
| parent | ff141a03e1909db719c6afd3230c2f16a4141860 (diff) | |
Input: HIL - handle erros from input_register_device()
Also some whitespace cleanup.
Signed-off-by: Cyrill V. Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
| -rw-r--r-- | drivers/input/keyboard/hilkbd.c | 114 |
1 files changed, 66 insertions, 48 deletions
diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c index 35461eab2faf..255a6ec75a48 100644 --- a/drivers/input/keyboard/hilkbd.c +++ b/drivers/input/keyboard/hilkbd.c | |||
| @@ -6,10 +6,10 @@ | |||
| 6 | * Copyright (C) 1999-2006 Helge Deller <deller@gmx.de> | 6 | * Copyright (C) 1999-2006 Helge Deller <deller@gmx.de> |
| 7 | * | 7 | * |
| 8 | * Very basic HP Human Interface Loop (HIL) driver. | 8 | * Very basic HP Human Interface Loop (HIL) driver. |
| 9 | * This driver handles the keyboard on HP300 (m68k) and on some | 9 | * This driver handles the keyboard on HP300 (m68k) and on some |
| 10 | * HP700 (parisc) series machines. | 10 | * HP700 (parisc) series machines. |
| 11 | * | 11 | * |
| 12 | * | 12 | * |
| 13 | * This file is subject to the terms and conditions of the GNU General Public | 13 | * This file is subject to the terms and conditions of the GNU General Public |
| 14 | * License version 2. See the file COPYING in the main directory of this | 14 | * License version 2. See the file COPYING in the main directory of this |
| 15 | * archive for more details. | 15 | * archive for more details. |
| @@ -64,9 +64,9 @@ MODULE_LICENSE("GPL v2"); | |||
| 64 | #endif | 64 | #endif |
| 65 | 65 | ||
| 66 | 66 | ||
| 67 | 67 | ||
| 68 | /* HIL helper functions */ | 68 | /* HIL helper functions */ |
| 69 | 69 | ||
| 70 | #define hil_busy() (hil_readb(HILBASE + HIL_CMD) & HIL_BUSY) | 70 | #define hil_busy() (hil_readb(HILBASE + HIL_CMD) & HIL_BUSY) |
| 71 | #define hil_data_available() (hil_readb(HILBASE + HIL_CMD) & HIL_DATA_RDY) | 71 | #define hil_data_available() (hil_readb(HILBASE + HIL_CMD) & HIL_DATA_RDY) |
| 72 | #define hil_status() (hil_readb(HILBASE + HIL_CMD)) | 72 | #define hil_status() (hil_readb(HILBASE + HIL_CMD)) |
| @@ -75,7 +75,7 @@ MODULE_LICENSE("GPL v2"); | |||
| 75 | #define hil_write_data(x) do { hil_writeb((x), HILBASE + HIL_DATA); } while (0) | 75 | #define hil_write_data(x) do { hil_writeb((x), HILBASE + HIL_DATA); } while (0) |
| 76 | 76 | ||
| 77 | /* HIL constants */ | 77 | /* HIL constants */ |
| 78 | 78 | ||
| 79 | #define HIL_BUSY 0x02 | 79 | #define HIL_BUSY 0x02 |
| 80 | #define HIL_DATA_RDY 0x01 | 80 | #define HIL_DATA_RDY 0x01 |
| 81 | 81 | ||
| @@ -86,10 +86,10 @@ MODULE_LICENSE("GPL v2"); | |||
| 86 | #define HIL_INTON 0x5C /* Turn on interrupts. */ | 86 | #define HIL_INTON 0x5C /* Turn on interrupts. */ |
| 87 | #define HIL_INTOFF 0x5D /* Turn off interrupts. */ | 87 | #define HIL_INTOFF 0x5D /* Turn off interrupts. */ |
| 88 | 88 | ||
| 89 | #define HIL_READKBDSADR 0xF9 | 89 | #define HIL_READKBDSADR 0xF9 |
| 90 | #define HIL_WRITEKBDSADR 0xE9 | 90 | #define HIL_WRITEKBDSADR 0xE9 |
| 91 | 91 | ||
| 92 | static unsigned int hphilkeyb_keycode[HIL_KEYCODES_SET1_TBLSIZE] = | 92 | static unsigned int hphilkeyb_keycode[HIL_KEYCODES_SET1_TBLSIZE] = |
| 93 | { HIL_KEYCODES_SET1 }; | 93 | { HIL_KEYCODES_SET1 }; |
| 94 | 94 | ||
| 95 | /* HIL structure */ | 95 | /* HIL structure */ |
| @@ -97,11 +97,11 @@ static struct { | |||
| 97 | struct input_dev *dev; | 97 | struct input_dev *dev; |
| 98 | 98 | ||
| 99 | unsigned int curdev; | 99 | unsigned int curdev; |
| 100 | 100 | ||
| 101 | unsigned char s; | 101 | unsigned char s; |
| 102 | unsigned char c; | 102 | unsigned char c; |
| 103 | int valid; | 103 | int valid; |
| 104 | 104 | ||
| 105 | unsigned char data[16]; | 105 | unsigned char data[16]; |
| 106 | unsigned int ptr; | 106 | unsigned int ptr; |
| 107 | spinlock_t lock; | 107 | spinlock_t lock; |
| @@ -115,7 +115,7 @@ static void poll_finished(void) | |||
| 115 | int down; | 115 | int down; |
| 116 | int key; | 116 | int key; |
| 117 | unsigned char scode; | 117 | unsigned char scode; |
| 118 | 118 | ||
| 119 | switch (hil_dev.data[0]) { | 119 | switch (hil_dev.data[0]) { |
| 120 | case 0x40: | 120 | case 0x40: |
| 121 | down = (hil_dev.data[1] & 1) == 0; | 121 | down = (hil_dev.data[1] & 1) == 0; |
| @@ -127,6 +127,7 @@ static void poll_finished(void) | |||
| 127 | hil_dev.curdev = 0; | 127 | hil_dev.curdev = 0; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | |||
| 130 | static inline void handle_status(unsigned char s, unsigned char c) | 131 | static inline void handle_status(unsigned char s, unsigned char c) |
| 131 | { | 132 | { |
| 132 | if (c & 0x8) { | 133 | if (c & 0x8) { |
| @@ -143,6 +144,7 @@ static inline void handle_status(unsigned char s, unsigned char c) | |||
| 143 | } | 144 | } |
| 144 | } | 145 | } |
| 145 | 146 | ||
| 147 | |||
| 146 | static inline void handle_data(unsigned char s, unsigned char c) | 148 | static inline void handle_data(unsigned char s, unsigned char c) |
| 147 | { | 149 | { |
| 148 | if (hil_dev.curdev) { | 150 | if (hil_dev.curdev) { |
| @@ -152,13 +154,11 @@ static inline void handle_data(unsigned char s, unsigned char c) | |||
| 152 | } | 154 | } |
| 153 | 155 | ||
| 154 | 156 | ||
| 155 | /* | 157 | /* handle HIL interrupts */ |
| 156 | * Handle HIL interrupts. | ||
| 157 | */ | ||
| 158 | static irqreturn_t hil_interrupt(int irq, void *handle) | 158 | static irqreturn_t hil_interrupt(int irq, void *handle) |
| 159 | { | 159 | { |
| 160 | unsigned char s, c; | 160 | unsigned char s, c; |
| 161 | 161 | ||
| 162 | s = hil_status(); | 162 | s = hil_status(); |
| 163 | c = hil_read_data(); | 163 | c = hil_read_data(); |
| 164 | 164 | ||
| @@ -179,10 +179,8 @@ static irqreturn_t hil_interrupt(int irq, void *handle) | |||
| 179 | return IRQ_HANDLED; | 179 | return IRQ_HANDLED; |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | /* | ||
| 183 | * Send a command to the HIL | ||
| 184 | */ | ||
| 185 | 182 | ||
| 183 | /* send a command to the HIL */ | ||
| 186 | static void hil_do(unsigned char cmd, unsigned char *data, unsigned int len) | 184 | static void hil_do(unsigned char cmd, unsigned char *data, unsigned int len) |
| 187 | { | 185 | { |
| 188 | unsigned long flags; | 186 | unsigned long flags; |
| @@ -200,16 +198,14 @@ static void hil_do(unsigned char cmd, unsigned char *data, unsigned int len) | |||
| 200 | } | 198 | } |
| 201 | 199 | ||
| 202 | 200 | ||
| 203 | /* | 201 | /* initialise HIL */ |
| 204 | * Initialise HIL. | ||
| 205 | */ | ||
| 206 | |||
| 207 | static int __init | 202 | static int __init |
| 208 | hil_keyb_init(void) | 203 | hil_keyb_init(void) |
| 209 | { | 204 | { |
| 210 | unsigned char c; | 205 | unsigned char c; |
| 211 | unsigned int i, kbid; | 206 | unsigned int i, kbid; |
| 212 | wait_queue_head_t hil_wait; | 207 | wait_queue_head_t hil_wait; |
| 208 | int err; | ||
| 213 | 209 | ||
| 214 | if (hil_dev.dev) { | 210 | if (hil_dev.dev) { |
| 215 | return -ENODEV; /* already initialized */ | 211 | return -ENODEV; /* already initialized */ |
| @@ -219,15 +215,25 @@ hil_keyb_init(void) | |||
| 219 | if (!hil_dev.dev) | 215 | if (!hil_dev.dev) |
| 220 | return -ENOMEM; | 216 | return -ENOMEM; |
| 221 | hil_dev.dev->private = &hil_dev; | 217 | hil_dev.dev->private = &hil_dev; |
| 222 | 218 | ||
| 223 | #if defined(CONFIG_HP300) | 219 | #if defined(CONFIG_HP300) |
| 224 | if (!hwreg_present((void *)(HILBASE + HIL_DATA))) | 220 | if (!hwreg_present((void *)(HILBASE + HIL_DATA))) { |
| 225 | return -ENODEV; | 221 | printk(KERN_ERR "HIL: hardware register was not found\n"); |
| 226 | 222 | err = -ENODEV; | |
| 227 | request_region(HILBASE+HIL_DATA, 2, "hil"); | 223 | goto err1; |
| 224 | } | ||
| 225 | if (!request_region(HILBASE + HIL_DATA, 2, "hil")) { | ||
| 226 | printk(KERN_ERR "HIL: IOPORT region already used\n"); | ||
| 227 | err = -EIO; | ||
| 228 | goto err1; | ||
| 229 | } | ||
| 228 | #endif | 230 | #endif |
| 229 | 231 | ||
| 230 | request_irq(HIL_IRQ, hil_interrupt, 0, "hil", hil_dev.dev_id); | 232 | err = request_irq(HIL_IRQ, hil_interrupt, 0, "hil", hil_dev.dev_id); |
| 233 | if (err) { | ||
| 234 | printk(KERN_ERR "HIL: Can't get IRQ\n"); | ||
| 235 | goto err2; | ||
