fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / input / power.c
index 552dcd8..ee82464 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * $Id: power.c,v 1.10 2001/09/25 09:17:15 vojtech Exp $
  *
- *  Copyright (c) 2001 "Crazy" James Simmons  
+ *  Copyright (c) 2001 "Crazy" James Simmons
  *
  *  Input driver Power Management.
  *
@@ -28,7 +28,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/config.h>
 #include <linux/input.h>
 #include <linux/slab.h>
 #include <linux/init.h>
@@ -51,15 +50,13 @@ static void suspend_button_task_handler(void *data)
 
 static DECLARE_WORK(suspend_button_task, suspend_button_task_handler, NULL);
 
-static void power_event(struct input_handle *handle, unsigned int type, 
+static void power_event(struct input_handle *handle, unsigned int type,
                        unsigned int code, int down)
 {
        struct input_dev *dev = handle->dev;
 
        printk("Entering power_event\n");
 
-       if (type != EV_KEY || type != EV_PWR) return;
-
        if (type == EV_PWR) {
                switch (code) {
                        case KEY_SUSPEND:
@@ -73,19 +70,21 @@ static void power_event(struct input_handle *handle, unsigned int type,
                        case KEY_POWER:
                                /* Hum power down the machine. */
                                break;
-                       default:        
+                       default:
                                return;
                }
-       } else {
+       }
+
+       if (type == EV_KEY) {
                switch (code) {
                        case KEY_SUSPEND:
                                printk("Powering down input device\n");
                                /* This is risky. See pm.h for details. */
                                if (dev->state != PM_RESUME)
                                        dev->state = PM_RESUME;
-                               else 
-                                       dev->state = PM_SUSPEND;        
-                               pm_send(dev->pm_dev, dev->state, dev);  
+                               else
+                                       dev->state = PM_SUSPEND;
+                               pm_send(dev->pm_dev, dev->state, dev);
                                break;
                        case KEY_POWER:
                                /* Turn the input device off completely ? */
@@ -97,21 +96,14 @@ static void power_event(struct input_handle *handle, unsigned int type,
        return;
 }
 
-static struct input_handle *power_connect(struct input_handler *handler, 
-                                         struct input_dev *dev, 
-                                         struct input_device_id *id)
+static struct input_handle *power_connect(struct input_handler *handler,
+                                         struct input_dev *dev,
+                                         const struct input_device_id *id)
 {
        struct input_handle *handle;
 
-       if (!test_bit(EV_KEY, dev->evbit) || !test_bit(EV_PWR, dev->evbit))
-               return NULL;    
-
-       if (!test_bit(KEY_SUSPEND, dev->keybit) || (!test_bit(KEY_POWER, dev->keybit)))
-               return NULL;
-
-       if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
+       if (!(handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL)))
                return NULL;
-       memset(handle, 0, sizeof(struct input_handle));
 
        handle->dev = dev;
        handle->handler = handler;
@@ -128,26 +120,26 @@ static void power_disconnect(struct input_handle *handle)
        kfree(handle);
 }
 
-static struct input_device_id power_ids[] = {
+static const struct input_device_id power_ids[] = {
        {
                .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT,
                .evbit = { BIT(EV_KEY) },
                .keybit = { [LONG(KEY_SUSPEND)] = BIT(KEY_SUSPEND) }
-       },      
+       },
        {
                .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT,
                .evbit = { BIT(EV_KEY) },
                .keybit = { [LONG(KEY_POWER)] = BIT(KEY_POWER) }
-       },      
+       },
        {
                .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
                .evbit = { BIT(EV_PWR) },
-       },      
+       },
        { },    /* Terminating entry */
 };
 
 MODULE_DEVICE_TABLE(input, power_ids);
-       
+
 static struct input_handler power_handler = {
        .event =        power_event,
        .connect =      power_connect,
@@ -158,8 +150,7 @@ static struct input_handler power_handler = {
 
 static int __init power_init(void)
 {
-       input_register_handler(&power_handler);
-       return 0;
+       return input_register_handler(&power_handler);
 }
 
 static void __exit power_exit(void)
@@ -172,3 +163,4 @@ module_exit(power_exit);
 
 MODULE_AUTHOR("James Simmons <jsimmons@transvirtual.com>");
 MODULE_DESCRIPTION("Input Power Management driver");
+MODULE_LICENSE("GPL");