diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2007-04-12 01:29:46 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2007-04-12 01:29:46 -0400 |
commit | 5b2a08262a8c952fef008154933953f083ca5766 (patch) | |
tree | 47fb54c30509a4c444613a1737a212ddda3bb05d /drivers/char/keyboard.c | |
parent | 6e782584e0713ea89da151333e7fe754c8f40324 (diff) |
Input: rework handle creation code
- consolidate code for binding handlers to a device
- return error codes from handlers connect() methods back to input
core and log failures
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/char/keyboard.c')
-rw-r--r-- | drivers/char/keyboard.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index 3d211e8553f..59712546f91 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <linux/input.h> | 41 | #include <linux/input.h> |
42 | #include <linux/reboot.h> | 42 | #include <linux/reboot.h> |
43 | 43 | ||
44 | static void kbd_disconnect(struct input_handle *handle); | ||
45 | extern void ctrl_alt_del(void); | 44 | extern void ctrl_alt_del(void); |
46 | 45 | ||
47 | /* | 46 | /* |
@@ -1260,11 +1259,11 @@ static void kbd_event(struct input_handle *handle, unsigned int event_type, | |||
1260 | * likes it, it can open it and get events from it. In this (kbd_connect) | 1259 | * likes it, it can open it and get events from it. In this (kbd_connect) |
1261 | * function, we should decide which VT to bind that keyboard to initially. | 1260 | * function, we should decide which VT to bind that keyboard to initially. |
1262 | */ | 1261 | */ |
1263 | static struct input_handle *kbd_connect(struct input_handler *handler, | 1262 | static int kbd_connect(struct input_handler *handler, struct input_dev *dev, |
1264 | struct input_dev *dev, | 1263 | const struct input_device_id *id) |
1265 | const struct input_device_id *id) | ||
1266 | { | 1264 | { |
1267 | struct input_handle *handle; | 1265 | struct input_handle *handle; |
1266 | int error; | ||
1268 | int i; | 1267 | int i; |
1269 | 1268 | ||
1270 | for (i = KEY_RESERVED; i < BTN_MISC; i++) | 1269 | for (i = KEY_RESERVED; i < BTN_MISC; i++) |
@@ -1272,24 +1271,37 @@ static struct input_handle *kbd_connect(struct input_handler *handler, | |||
1272 | break; | 1271 | break; |
1273 | 1272 | ||
1274 | if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit)) | 1273 | if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit)) |
1275 | return NULL; | 1274 | return -ENODEV; |
1276 | 1275 | ||
1277 | handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); | 1276 | handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); |
1278 | if (!handle) | 1277 | if (!handle) |
1279 | return NULL; | 1278 | return -ENOMEM; |
1280 | 1279 | ||
1281 | handle->dev = dev; | 1280 | handle->dev = dev; |
1282 | handle->handler = handler; | 1281 | handle->handler = handler; |
1283 | handle->name = "kbd"; | 1282 | handle->name = "kbd"; |
1284 | 1283 | ||
1285 | input_open_device(handle); | 1284 | error = input_register_handle(handle); |
1285 | if (error) | ||
1286 | goto err_free_handle; | ||
1287 | |||
1288 | error = input_open_device(handle); | ||
1289 | if (error) | ||
1290 | goto err_unregister_handle; | ||
1291 | |||
1292 | return 0; | ||
1286 | 1293 | ||
1287 | return handle; | 1294 | err_unregister_handle: |
1295 | input_unregister_handle(handle); | ||
1296 | err_free_handle: | ||
1297 | kfree(handle); | ||
1298 | return error; | ||
1288 | } | 1299 | } |
1289 | 1300 | ||
1290 | static void kbd_disconnect(struct input_handle *handle) | 1301 | static void kbd_disconnect(struct input_handle *handle) |
1291 | { | 1302 | { |
1292 | input_close_device(handle); | 1303 | input_close_device(handle); |
1304 | input_unregister_handle(handle); | ||
1293 | kfree(handle); | 1305 | kfree(handle); |
1294 | } | 1306 | } |
1295 | 1307 | ||