diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-09-04 00:57:48 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-09-11 01:11:32 -0400 |
commit | 7cac9cd935533e52e277c0c8799a8ba16c24f250 (patch) | |
tree | efde9e12a8cecdce1fcd8a5965cc0eb2f337f803 /drivers/input | |
parent | 1c7827ae70e7c8456e08f7bb9ef2238d27814cbe (diff) |
Input: sunkbd - fix formatting
Adjust the way 'switch' statements were indented; make sure we stay
under 80 ciolumns.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/keyboard/sunkbd.c | 128 |
1 files changed, 73 insertions, 55 deletions
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index e7aa935a294a..472b56639cdb 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c | |||
@@ -73,7 +73,7 @@ static unsigned char sunkbd_keycode[128] = { | |||
73 | */ | 73 | */ |
74 | 74 | ||
75 | struct sunkbd { | 75 | struct sunkbd { |
76 | unsigned char keycode[128]; | 76 | unsigned char keycode[ARRAY_SIZE(sunkbd_keycode)]; |
77 | struct input_dev *dev; | 77 | struct input_dev *dev; |
78 | struct serio *serio; | 78 | struct serio *serio; |
79 | struct work_struct tq; | 79 | struct work_struct tq; |
@@ -81,7 +81,7 @@ struct sunkbd { | |||
81 | char name[64]; | 81 | char name[64]; |
82 | char phys[32]; | 82 | char phys[32]; |
83 | char type; | 83 | char type; |
84 | unsigned char enabled; | 84 | bool enabled; |
85 | volatile s8 reset; | 85 | volatile s8 reset; |
86 | volatile s8 layout; | 86 | volatile s8 layout; |
87 | }; | 87 | }; |
@@ -94,10 +94,14 @@ struct sunkbd { | |||
94 | static irqreturn_t sunkbd_interrupt(struct serio *serio, | 94 | static irqreturn_t sunkbd_interrupt(struct serio *serio, |
95 | unsigned char data, unsigned int flags) | 95 | unsigned char data, unsigned int flags) |
96 | { | 96 | { |
97 | struct sunkbd* sunkbd = serio_get_drvdata(serio); | 97 | struct sunkbd *sunkbd = serio_get_drvdata(serio); |
98 | 98 | ||
99 | if (sunkbd->reset <= -1) { /* If cp[i] is 0xff, sunkbd->reset will stay -1. */ | 99 | if (sunkbd->reset <= -1) { |
100 | sunkbd->reset = data; /* The keyboard sends 0xff 0xff 0xID on powerup */ | 100 | /* |
101 | * If cp[i] is 0xff, sunkbd->reset will stay -1. | ||
102 | * The keyboard sends 0xff 0xff 0xID on powerup. | ||
103 | */ | ||
104 | sunkbd->reset = data; | ||
101 | wake_up_interruptible(&sunkbd->wait); | 105 | wake_up_interruptible(&sunkbd->wait); |
102 | goto out; | 106 | goto out; |
103 | } | 107 | } |
@@ -110,29 +114,33 @@ static irqreturn_t sunkbd_interrupt(struct serio *serio, | |||
110 | 114 | ||
111 | switch (data) { | 115 | switch (data) { |
112 | 116 | ||
113 | case SUNKBD_RET_RESET: | 117 | case SUNKBD_RET_RESET: |
114 | schedule_work(&sunkbd->tq); | 118 | schedule_work(&sunkbd->tq); |
115 | sunkbd->reset = -1; | 119 | sunkbd->reset = -1; |
116 | break; | 120 | break; |
117 | 121 | ||
118 | case SUNKBD_RET_LAYOUT: | 122 | case SUNKBD_RET_LAYOUT: |
119 | sunkbd->layout = -1; | 123 | sunkbd->layout = -1; |
120 | break; | 124 | break; |
121 | 125 | ||
122 | case SUNKBD_RET_ALLUP: /* All keys released */ | 126 | case SUNKBD_RET_ALLUP: /* All keys released */ |
127 | break; | ||
128 | |||
129 | default: | ||
130 | if (!sunkbd->enabled) | ||
123 | break; | 131 | break; |
124 | 132 | ||
125 | default: | 133 | if (sunkbd->keycode[data & SUNKBD_KEY]) { |
126 | if (!sunkbd->enabled) | 134 | input_report_key(sunkbd->dev, |
127 | break; | 135 | sunkbd->keycode[data & SUNKBD_KEY], |
128 | 136 | !(data & SUNKBD_RELEASE)); | |
129 | if (sunkbd->keycode[data & SUNKBD_KEY]) { | 137 | input_sync(sunkbd->dev); |
130 | input_report_key(sunkbd->dev, sunkbd->keycode[data & SUNKBD_KEY], !(data & SUNKBD_RELEASE)); | 138 | } else { |
131 | input_sync(sunkbd->dev); | 139 | printk(KERN_WARNING |
132 | } else { | 140 | "sunkbd.c: Unknown key (scancode %#x) %s.\n", |
133 | printk(KERN_WARNING "sunkbd.c: Unknown key (scancode %#x) %s.\n", | 141 | data & SUNKBD_KEY, |
134 | data & SUNKBD_KEY, data & SUNKBD_RELEASE ? "released" : "pressed"); | 142 | data & SUNKBD_RELEASE ? "released" : "pressed"); |
135 | } | 143 | } |
136 | } | 144 | } |
137 | out: | 145 | out: |
138 | return IRQ_HANDLED; | 146 | return IRQ_HANDLED; |
@@ -142,34 +150,37 @@ out: | |||
142 | * sunkbd_event() handles events from the input module. | 150 | * sunkbd_event() handles events from the input module. |
143 | */ | 151 | */ |
144 | 152 | ||
145 | static int sunkbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 153 | static int sunkbd_event(struct input_dev *dev, |
154 | unsigned int type, unsigned int code, int value) | ||
146 | { | 155 | { |
147 | struct sunkbd *sunkbd = input_get_drvdata(dev); | 156 | struct sunkbd *sunkbd = input_get_drvdata(dev); |
148 | 157 | ||
149 | switch (type) { | 158 | switch (type) { |
150 | 159 | ||
151 | case EV_LED: | 160 | case EV_LED: |
152 | 161 | ||
153 | serio_write(sunkbd->serio, SUNKBD_CMD_SETLED); | 162 | serio_write(sunkbd->serio, SUNKBD_CMD_SETLED); |
154 | serio_write(sunkbd->serio, | 163 | serio_write(sunkbd->serio, |
155 | (!!test_bit(LED_CAPSL, dev->led) << 3) | (!!test_bit(LED_SCROLLL, dev->led) << 2) | | 164 | (!!test_bit(LED_CAPSL, dev->led) << 3) | |
156 | (!!test_bit(LED_COMPOSE, dev->led) << 1) | !!test_bit(LED_NUML, dev->led)); | 165 | (!!test_bit(LED_SCROLLL, dev->led) << 2) | |
157 | return 0; | 166 | (!!test_bit(LED_COMPOSE, dev->led) << 1) | |
167 | !!test_bit(LED_NUML, dev->led)); | ||
168 | return 0; | ||
158 | 169 | ||
159 | case EV_SND: | 170 | case EV_SND: |
160 | 171 | ||
161 | switch (code) { | 172 | switch (code) { |
162 | 173 | ||
163 | case SND_CLICK: | 174 | case SND_CLICK: |
164 | serio_write(sunkbd->serio, SUNKBD_CMD_NOCLICK - value); | 175 | serio_write(sunkbd->serio, SUNKBD_CMD_NOCLICK - value); |
165 | return 0; | 176 | return 0; |
166 | 177 | ||
167 | case SND_BELL: | 178 | case SND_BELL: |
168 | serio_write(sunkbd->serio, SUNKBD_CMD_BELLOFF - value); | 179 | serio_write(sunkbd->serio, SUNKBD_CMD_BELLOFF - value); |
169 | return 0; | 180 | return 0; |
170 | } | 181 | } |
171 | 182 | ||
172 | break; | 183 | break; |
173 | } | 184 | } |
174 | 185 | ||
175 | return -1; | 186 | return -1; |
@@ -193,9 +204,12 @@ static int sunkbd_initialize(struct sunkbd *sunkbd) | |||
193 | if (sunkbd->type == 4) { /* Type 4 keyboard */ | 204 | if (sunkbd->type == 4) { /* Type 4 keyboard */ |
194 | sunkbd->layout = -2; | 205 | sunkbd->layout = -2; |
195 | serio_write(sunkbd->serio, SUNKBD_CMD_LAYOUT); | 206 | serio_write(sunkbd->serio, SUNKBD_CMD_LAYOUT); |
196 | wait_event_interruptible_timeout(sunkbd->wait, sunkbd->layout >= 0, HZ/4); | 207 | wait_event_interruptible_timeout(sunkbd->wait, |
197 | if (sunkbd->layout < 0) return -1; | 208 | sunkbd->layout >= 0, HZ / 4); |
198 | if (sunkbd->layout & SUNKBD_LAYOUT_5_MASK) sunkbd->type = 5; | 209 | if (sunkbd->layout < 0) |
210 | return -1; | ||
211 | if (sunkbd->layout & SUNKBD_LAYOUT_5_MASK) | ||
212 | sunkbd->type = 5; | ||
199 | } | 213 | } |
200 | 214 | ||
201 | return 0; | 215 | return 0; |
@@ -218,11 +232,13 @@ static void sunkbd_reinit(struct work_struct *work) | |||
218 | (!!test_bit(LED_SCROLLL, sunkbd->dev->led) << 2) | | 232 | (!!test_bit(LED_SCROLLL, sunkbd->dev->led) << 2) | |
219 | (!!test_bit(LED_COMPOSE, sunkbd->dev->led) << 1) | | 233 | (!!test_bit(LED_COMPOSE, sunkbd->dev->led) << 1) | |
220 | !!test_bit(LED_NUML, sunkbd->dev->led)); | 234 | !!test_bit(LED_NUML, sunkbd->dev->led)); |
221 | serio_write(sunkbd->serio, SUNKBD_CMD_NOCLICK - !!test_bit(SND_CLICK, sunkbd->dev->snd)); | 235 | serio_write(sunkbd->serio, |
222 | serio_write(sunkbd->serio, SUNKBD_CMD_BELLOFF - !!test_bit(SND_BELL, sunkbd->dev->snd)); | 236 | SUNKBD_CMD_NOCLICK - !!test_bit(SND_CLICK, sunkbd->dev->snd)); |
237 | serio_write(sunkbd->serio, | ||
238 | SUNKBD_CMD_BELLOFF - !!test_bit(SND_BELL, sunkbd->dev->snd)); | ||
223 | } | 239 | } |
224 | 240 | ||
225 | static void sunkbd_enable(struct sunkbd *sunkbd, int enable) | 241 | static void sunkbd_enable(struct sunkbd *sunkbd, bool enable) |
226 | { | 242 | { |
227 | serio_pause_rx(sunkbd->serio); | 243 | serio_pause_rx(sunkbd->serio); |
228 | sunkbd->enabled = enable; | 244 | sunkbd->enabled = enable; |
@@ -230,7 +246,8 @@ static void sunkbd_enable(struct sunkbd *sunkbd, int enable) | |||
230 | } | 246 | } |
231 | 247 | ||
232 | /* | 248 | /* |
233 | * sunkbd_connect() probes for a Sun keyboard and fills the necessary structures. | 249 | * sunkbd_connect() probes for a Sun keyboard and fills the necessary |
250 | * structures. | ||
234 | */ | 251 | */ |
235 | 252 | ||
236 | static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | 253 | static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) |
@@ -262,7 +279,8 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
262 | goto fail3; | 279 | goto fail3; |
263 | } | 280 | } |
264 | 281 | ||
265 | snprintf(sunkbd->name, sizeof(sunkbd->name), "Sun Type %d keyboard", sunkbd->type); | 282 | snprintf(sunkbd->name, sizeof(sunkbd->name), |
283 | "Sun Type %d keyboard", sunkbd->type); | ||
266 | memcpy(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode)); | 284 | memcpy(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode)); |
267 | 285 | ||
268 | input_dev->name = sunkbd->name; | 286 | input_dev->name = sunkbd->name; |
@@ -286,11 +304,11 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
286 | input_dev->keycode = sunkbd->keycode; | 304 | input_dev->keycode = sunkbd->keycode; |
287 | input_dev->keycodesize = sizeof(unsigned char); | 305 | input_dev->keycodesize = sizeof(unsigned char); |
288 | input_dev->keycodemax = ARRAY_SIZE(sunkbd_keycode); | 306 | input_dev->keycodemax = ARRAY_SIZE(sunkbd_keycode); |
289 | for (i = 0; i < 128; i++) | 307 | for (i = 0; i < ARRAY_SIZE(sunkbd_keycode); i++) |
290 | set_bit(sunkbd->keycode[i], input_dev->keybit); | 308 | __set_bit(sunkbd->keycode[i], input_dev->keybit); |
291 | clear_bit(0, input_dev->keybit); | 309 | __clear_bit(KEY_RESERVED, input_dev->keybit); |
292 | 310 | ||
293 | sunkbd_enable(sunkbd, 1); | 311 | sunkbd_enable(sunkbd, true); |
294 | 312 | ||
295 | err = input_register_device(sunkbd->dev); | 313 | err = input_register_device(sunkbd->dev); |
296 | if (err) | 314 | if (err) |
@@ -298,7 +316,7 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
298 | 316 | ||
299 | return 0; | 317 | return 0; |
300 | 318 | ||
301 | fail4: sunkbd_enable(sunkbd, 0); | 319 | fail4: sunkbd_enable(sunkbd, false); |
302 | fail3: serio_close(serio); | 320 | fail3: serio_close(serio); |
303 | fail2: serio_set_drvdata(serio, NULL); | 321 | fail2: serio_set_drvdata(serio, NULL); |
304 | fail1: input_free_device(input_dev); | 322 | fail1: input_free_device(input_dev); |
@@ -314,7 +332,7 @@ static void sunkbd_disconnect(struct serio *serio) | |||
314 | { | 332 | { |
315 | struct sunkbd *sunkbd = serio_get_drvdata(serio); | 333 | struct sunkbd *sunkbd = serio_get_drvdata(serio); |
316 | 334 | ||
317 | sunkbd_enable(sunkbd, 0); | 335 | sunkbd_enable(sunkbd, false); |
318 | input_unregister_device(sunkbd->dev); | 336 | input_unregister_device(sunkbd->dev); |
319 | serio_close(serio); | 337 | serio_close(serio); |
320 | serio_set_drvdata(serio, NULL); | 338 | serio_set_drvdata(serio, NULL); |