aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/button.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/button.c')
-rw-r--r--drivers/acpi/button.c56
1 files changed, 23 insertions, 33 deletions
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 63db284bb5cf..02594639c4d9 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -112,15 +112,14 @@ static int acpi_button_info_seq_show(struct seq_file *seq, void *offset)
112{ 112{
113 struct acpi_button *button = (struct acpi_button *)seq->private; 113 struct acpi_button *button = (struct acpi_button *)seq->private;
114 114
115 ACPI_FUNCTION_TRACE("acpi_button_info_seq_show");
116 115
117 if (!button || !button->device) 116 if (!button || !button->device)
118 return_VALUE(0); 117 return 0;
119 118
120 seq_printf(seq, "type: %s\n", 119 seq_printf(seq, "type: %s\n",
121 acpi_device_name(button->device)); 120 acpi_device_name(button->device));
122 121
123 return_VALUE(0); 122 return 0;
124} 123}
125 124
126static int acpi_button_info_open_fs(struct inode *inode, struct file *file) 125static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
@@ -134,10 +133,9 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
134 acpi_status status; 133 acpi_status status;
135 unsigned long state; 134 unsigned long state;
136 135
137 ACPI_FUNCTION_TRACE("acpi_button_state_seq_show");
138 136
139 if (!button || !button->device) 137 if (!button || !button->device)
140 return_VALUE(0); 138 return 0;
141 139
142 status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state); 140 status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state);
143 if (ACPI_FAILURE(status)) { 141 if (ACPI_FAILURE(status)) {
@@ -147,7 +145,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
147 (state ? "open" : "closed")); 145 (state ? "open" : "closed"));
148 } 146 }
149 147
150 return_VALUE(0); 148 return 0;
151} 149}
152 150
153static int acpi_button_state_open_fs(struct inode *inode, struct file *file) 151static int acpi_button_state_open_fs(struct inode *inode, struct file *file)
@@ -164,10 +162,9 @@ static int acpi_button_add_fs(struct acpi_device *device)
164 struct proc_dir_entry *entry = NULL; 162 struct proc_dir_entry *entry = NULL;
165 struct acpi_button *button = NULL; 163 struct acpi_button *button = NULL;
166 164
167 ACPI_FUNCTION_TRACE("acpi_button_add_fs");
168 165
169 if (!device || !acpi_driver_data(device)) 166 if (!device || !acpi_driver_data(device))
170 return_VALUE(-EINVAL); 167 return -EINVAL;
171 168
172 button = acpi_driver_data(device); 169 button = acpi_driver_data(device);
173 170
@@ -195,19 +192,19 @@ static int acpi_button_add_fs(struct acpi_device *device)
195 } 192 }
196 193
197 if (!entry) 194 if (!entry)
198 return_VALUE(-ENODEV); 195 return -ENODEV;
199 entry->owner = THIS_MODULE; 196 entry->owner = THIS_MODULE;
200 197
201 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); 198 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry);
202 if (!acpi_device_dir(device)) 199 if (!acpi_device_dir(device))
203 return_VALUE(-ENODEV); 200 return -ENODEV;
204 acpi_device_dir(device)->owner = THIS_MODULE; 201 acpi_device_dir(device)->owner = THIS_MODULE;
205 202
206 /* 'info' [R] */ 203 /* 'info' [R] */
207 entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, 204 entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
208 S_IRUGO, acpi_device_dir(device)); 205 S_IRUGO, acpi_device_dir(device));
209 if (!entry) 206 if (!entry)
210 return_VALUE(-ENODEV); 207 return -ENODEV;
211 else { 208 else {
212 entry->proc_fops = &acpi_button_info_fops; 209 entry->proc_fops = &acpi_button_info_fops;
213 entry->data = acpi_driver_data(device); 210 entry->data = acpi_driver_data(device);
@@ -227,14 +224,13 @@ static int acpi_button_add_fs(struct acpi_device *device)
227 } 224 }
228 } 225 }
229 226
230 return_VALUE(0); 227 return 0;
231} 228}
232 229
233static int acpi_button_remove_fs(struct acpi_device *device) 230static int acpi_button_remove_fs(struct acpi_device *device)
234{ 231{
235 struct acpi_button *button = NULL; 232 struct acpi_button *button = NULL;
236 233
237 ACPI_FUNCTION_TRACE("acpi_button_remove_fs");
238 234
239 button = acpi_driver_data(device); 235 button = acpi_driver_data(device);
240 if (acpi_device_dir(device)) { 236 if (acpi_device_dir(device)) {
@@ -249,7 +245,7 @@ static int acpi_button_remove_fs(struct acpi_device *device)
249 acpi_device_dir(device) = NULL; 245 acpi_device_dir(device) = NULL;
250 } 246 }
251 247
252 return_VALUE(0); 248 return 0;
253} 249}
254 250
255/* -------------------------------------------------------------------------- 251/* --------------------------------------------------------------------------
@@ -260,10 +256,9 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
260{ 256{
261 struct acpi_button *button = (struct acpi_button *)data; 257 struct acpi_button *button = (struct acpi_button *)data;
262 258
263 ACPI_FUNCTION_TRACE("acpi_button_notify");
264 259
265 if (!button || !button->device) 260 if (!button || !button->device)
266 return_VOID; 261 return;
267 262
268 switch (event) { 263 switch (event) {
269 case ACPI_BUTTON_NOTIFY_STATUS: 264 case ACPI_BUTTON_NOTIFY_STATUS:
@@ -276,21 +271,20 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
276 break; 271 break;
277 } 272 }
278 273
279 return_VOID; 274 return;
280} 275}
281 276
282static acpi_status acpi_button_notify_fixed(void *data) 277static acpi_status acpi_button_notify_fixed(void *data)
283{ 278{
284 struct acpi_button *button = (struct acpi_button *)data; 279 struct acpi_button *button = (struct acpi_button *)data;
285 280
286 ACPI_FUNCTION_TRACE("acpi_button_notify_fixed");
287 281
288 if (!button) 282 if (!button)
289 return_ACPI_STATUS(AE_BAD_PARAMETER); 283 return AE_BAD_PARAMETER;
290 284
291 acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button); 285 acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button);
292 286
293 return_ACPI_STATUS(AE_OK); 287 return AE_OK;
294} 288}
295 289
296static int acpi_button_add(struct acpi_device *device) 290static int acpi_button_add(struct acpi_device *device)
@@ -299,14 +293,13 @@ static int acpi_button_add(struct acpi_device *device)
299 acpi_status status = AE_OK; 293 acpi_status status = AE_OK;
300 struct acpi_button *button = NULL; 294 struct acpi_button *button = NULL;
301 295
302 ACPI_FUNCTION_TRACE("acpi_button_add");
303 296
304 if (!device) 297 if (!device)
305 return_VALUE(-EINVAL); 298 return -EINVAL;
306 299
307 button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL); 300 button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL);
308 if (!button) 301 if (!button)
309 return_VALUE(-ENOMEM); 302 return -ENOMEM;
310 memset(button, 0, sizeof(struct acpi_button)); 303 memset(button, 0, sizeof(struct acpi_button));
311 304
312 button->device = device; 305 button->device = device;
@@ -400,7 +393,7 @@ static int acpi_button_add(struct acpi_device *device)
400 kfree(button); 393 kfree(button);
401 } 394 }
402 395
403 return_VALUE(result); 396 return result;
404} 397}
405 398
406static int acpi_button_remove(struct acpi_device *device, int type) 399static int acpi_button_remove(struct acpi_device *device, int type)
@@ -408,10 +401,9 @@ static int acpi_button_remove(struct acpi_device *device, int type)
408 acpi_status status = 0; 401 acpi_status status = 0;
409 struct acpi_button *button = NULL; 402 struct acpi_button *button = NULL;
410 403
411 ACPI_FUNCTION_TRACE("acpi_button_remove");
412 404
413 if (!device || !acpi_driver_data(device)) 405 if (!device || !acpi_driver_data(device))
414 return_VALUE(-EINVAL); 406 return -EINVAL;
415 407
416 button = acpi_driver_data(device); 408 button = acpi_driver_data(device);
417 409
@@ -438,31 +430,29 @@ static int acpi_button_remove(struct acpi_device *device, int type)
438 430
439 kfree(button); 431 kfree(button);
440 432
441 return_VALUE(0); 433 return 0;
442} 434}
443 435
444static int __init acpi_button_init(void) 436static int __init acpi_button_init(void)
445{ 437{
446 int result = 0; 438 int result = 0;
447 439
448 ACPI_FUNCTION_TRACE("acpi_button_init");
449 440
450 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); 441 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
451 if (!acpi_button_dir) 442 if (!acpi_button_dir)
452 return_VALUE(-ENODEV); 443 return -ENODEV;
453 acpi_button_dir->owner = THIS_MODULE; 444 acpi_button_dir->owner = THIS_MODULE;
454 result = acpi_bus_register_driver(&acpi_button_driver); 445 result = acpi_bus_register_driver(&acpi_button_driver);
455 if (result < 0) { 446 if (result < 0) {
456 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); 447 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
457 return_VALUE(-ENODEV); 448 return -ENODEV;
458 } 449 }
459 450
460 return_VALUE(0); 451 return 0;
461} 452}
462 453
463static void __exit acpi_button_exit(void) 454static void __exit acpi_button_exit(void)
464{ 455{
465 ACPI_FUNCTION_TRACE("acpi_button_exit");
466 456
467 acpi_bus_unregister_driver(&acpi_button_driver); 457 acpi_bus_unregister_driver(&acpi_button_driver);
468 458
@@ -474,7 +464,7 @@ static void __exit acpi_button_exit(void)
474 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); 464 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
475 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); 465 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
476 466
477 return_VOID; 467 return;
478} 468}
479 469
480module_init(acpi_button_init); 470module_init(acpi_button_init);