aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/power.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/power.c')
-rw-r--r--drivers/input/power.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/drivers/input/power.c b/drivers/input/power.c
index ee82464a2fa7..e28d264b9e06 100644
--- a/drivers/input/power.c
+++ b/drivers/input/power.c
@@ -41,14 +41,14 @@ static struct input_handler power_handler;
41 * Power management can't be done in a interrupt context. So we have to 41 * Power management can't be done in a interrupt context. So we have to
42 * use keventd. 42 * use keventd.
43 */ 43 */
44static int suspend_button_pushed = 0; 44static int suspend_button_pushed;
45static void suspend_button_task_handler(void *data) 45static void suspend_button_task_handler(struct work_struct *work)
46{ 46{
47 udelay(200); /* debounce */ 47 udelay(200); /* debounce */
48 suspend_button_pushed = 0; 48 suspend_button_pushed = 0;
49} 49}
50 50
51static DECLARE_WORK(suspend_button_task, suspend_button_task_handler, NULL); 51static DECLARE_WORK(suspend_button_task, suspend_button_task_handler);
52 52
53static void power_event(struct input_handle *handle, unsigned int type, 53static void power_event(struct input_handle *handle, unsigned int type,
54 unsigned int code, int down) 54 unsigned int code, int down)
@@ -63,9 +63,9 @@ static void power_event(struct input_handle *handle, unsigned int type,
63 printk("Powering down entire device\n"); 63 printk("Powering down entire device\n");
64 64
65 if (!suspend_button_pushed) { 65 if (!suspend_button_pushed) {
66 suspend_button_pushed = 1; 66 suspend_button_pushed = 1;
67 schedule_work(&suspend_button_task); 67 schedule_work(&suspend_button_task);
68 } 68 }
69 break; 69 break;
70 case KEY_POWER: 70 case KEY_POWER:
71 /* Hum power down the machine. */ 71 /* Hum power down the machine. */
@@ -84,7 +84,7 @@ static void power_event(struct input_handle *handle, unsigned int type,
84 dev->state = PM_RESUME; 84 dev->state = PM_RESUME;
85 else 85 else
86 dev->state = PM_SUSPEND; 86 dev->state = PM_SUSPEND;
87 pm_send(dev->pm_dev, dev->state, dev); 87 /* pm_send(dev->pm_dev, dev->state, dev); */
88 break; 88 break;
89 case KEY_POWER: 89 case KEY_POWER:
90 /* Turn the input device off completely ? */ 90 /* Turn the input device off completely ? */
@@ -96,27 +96,41 @@ static void power_event(struct input_handle *handle, unsigned int type,
96 return; 96 return;
97} 97}
98 98
99static struct input_handle *power_connect(struct input_handler *handler, 99static int power_connect(struct input_handler *handler, struct input_dev *dev,
100 struct input_dev *dev, 100 const struct input_device_id *id)
101 const struct input_device_id *id)
102{ 101{
103 struct input_handle *handle; 102 struct input_handle *handle;
103 int error;
104 104
105 if (!(handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL))) 105 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
106 return NULL; 106 if (!handle)
107 return -ENOMEM;
107 108
108 handle->dev = dev; 109 handle->dev = dev;
109 handle->handler = handler; 110 handle->handler = handler;
111 handle->name = "power";
110 112
111 input_open_device(handle); 113 error = input_register_handle(handle);
114 if (error)
115 goto err_free_handle;
112 116
113 printk(KERN_INFO "power.c: Adding power management to input layer\n"); 117 error = input_open_device(handle);
114 return handle; 118 if (error)
119 goto err_unregister_handle;
120
121 return 0;
122
123 err_unregister_handle:
124 input_unregister_handle(handle);
125 err_free_handle:
126 kfree(handle);
127 return error;
115} 128}
116 129
117static void power_disconnect(struct input_handle *handle) 130static void power_disconnect(struct input_handle *handle)
118{ 131{
119 input_close_device(handle); 132 input_close_device(handle);
133 input_unregister_handle(handle);
120 kfree(handle); 134 kfree(handle);
121} 135}
122 136
@@ -135,7 +149,7 @@ static const struct input_device_id power_ids[] = {
135 .flags = INPUT_DEVICE_ID_MATCH_EVBIT, 149 .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
136 .evbit = { BIT(EV_PWR) }, 150 .evbit = { BIT(EV_PWR) },
137 }, 151 },
138 { }, /* Terminating entry */ 152 { }, /* Terminating entry */
139}; 153};
140 154
141MODULE_DEVICE_TABLE(input, power_ids); 155MODULE_DEVICE_TABLE(input, power_ids);