From 88d7eaeb81edc9fcd4cdf13c81cc36213f7d9109 Mon Sep 17 00:00:00 2001 From: Holger Nelson Date: Sun, 28 Oct 2007 12:46:50 +0000 Subject: [PATCH] Updated nbsmi hotkey handling to work with Kernel 2.6.22+ --- nbsmi.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/nbsmi.c b/nbsmi.c index 0f9a486..3be9cb9 100644 --- a/nbsmi.c +++ b/nbsmi.c @@ -336,6 +336,7 @@ static struct input_handle *hook_connect(struct input_handler *handler, #endif { struct input_handle *handle; + int error; /* the 0x0001 vendor magic number is found in atkbd.c */ if(!(dev->id.bustype == BUS_I8042 && dev->id.vendor == 0x0001)) @@ -363,14 +364,38 @@ static struct input_handle *hook_connect(struct input_handler *handler, handle->name = "omnibook_scancode_hook"; handle->private = handler->private; - input_open_device(handle); +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,21)) + error = input_register_handle(handle); + if (error) { + dprintk("register_handle failed\n"); + goto out_nobind_free; + } + error = input_open_device(handle); + if (error) { + dprintk("register_handle failed\n"); + input_unregister_handle(handle); + goto out_nobind_free; + } + +#else + status=input_open_device(handle); + if (error==0) dprintk("Input device opened\n"); + else { + dprintk("opening input device failed\n"); + goto out_nobind_free; + } +#endif #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,21)) return 0; +out_nobind_free: + kfree(handle); out_nobind: return -ENODEV; #else return handle; +out_nobind_free: + kfree(handle); out_nobind: return NULL; #endif @@ -380,6 +405,9 @@ static void hook_disconnect(struct input_handle *handle) { dprintk("hook_disconnect.\n"); input_close_device(handle); +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,21)) + input_unregister_handle(handle); +#endif kfree(handle); } -- 2.43.5