aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/battery.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/battery.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/battery.c')
-rw-r--r--drivers/acpi/battery.c400
1 files changed, 183 insertions, 217 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index c55feca9b7d5..702e857e98c5 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -34,7 +34,6 @@
34#include <acpi/acpi_bus.h> 34#include <acpi/acpi_bus.h>
35#include <acpi/acpi_drivers.h> 35#include <acpi/acpi_drivers.h>
36 36
37
38#define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF 37#define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF
39 38
40#define ACPI_BATTERY_FORMAT_BIF "NNNNNNNNNSSSS" 39#define ACPI_BATTERY_FORMAT_BIF "NNNNNNNNNSSSS"
@@ -53,87 +52,85 @@
53#define ACPI_BATTERY_UNITS_WATTS "mW" 52#define ACPI_BATTERY_UNITS_WATTS "mW"
54#define ACPI_BATTERY_UNITS_AMPS "mA" 53#define ACPI_BATTERY_UNITS_AMPS "mA"
55 54
56
57#define _COMPONENT ACPI_BATTERY_COMPONENT 55#define _COMPONENT ACPI_BATTERY_COMPONENT
58ACPI_MODULE_NAME ("acpi_battery") 56ACPI_MODULE_NAME("acpi_battery")
59 57
60MODULE_AUTHOR("Paul Diefenbaugh"); 58 MODULE_AUTHOR("Paul Diefenbaugh");
61MODULE_DESCRIPTION(ACPI_BATTERY_DRIVER_NAME); 59MODULE_DESCRIPTION(ACPI_BATTERY_DRIVER_NAME);
62MODULE_LICENSE("GPL"); 60MODULE_LICENSE("GPL");
63 61
64static int acpi_battery_add (struct acpi_device *device); 62static int acpi_battery_add(struct acpi_device *device);
65static int acpi_battery_remove (struct acpi_device *device, int type); 63static int acpi_battery_remove(struct acpi_device *device, int type);
66 64
67static struct acpi_driver acpi_battery_driver = { 65static struct acpi_driver acpi_battery_driver = {
68 .name = ACPI_BATTERY_DRIVER_NAME, 66 .name = ACPI_BATTERY_DRIVER_NAME,
69 .class = ACPI_BATTERY_CLASS, 67 .class = ACPI_BATTERY_CLASS,
70 .ids = ACPI_BATTERY_HID, 68 .ids = ACPI_BATTERY_HID,
71 .ops = { 69 .ops = {
72 .add = acpi_battery_add, 70 .add = acpi_battery_add,
73 .remove = acpi_battery_remove, 71 .remove = acpi_battery_remove,
74 }, 72 },
75}; 73};
76 74
77struct acpi_battery_status { 75struct acpi_battery_status {
78 acpi_integer state; 76 acpi_integer state;
79 acpi_integer present_rate; 77 acpi_integer present_rate;
80 acpi_integer remaining_capacity; 78 acpi_integer remaining_capacity;
81 acpi_integer present_voltage; 79 acpi_integer present_voltage;
82}; 80};
83 81
84struct acpi_battery_info { 82struct acpi_battery_info {
85 acpi_integer power_unit; 83 acpi_integer power_unit;
86 acpi_integer design_capacity; 84 acpi_integer design_capacity;
87 acpi_integer last_full_capacity; 85 acpi_integer last_full_capacity;
88 acpi_integer battery_technology; 86 acpi_integer battery_technology;
89 acpi_integer design_voltage; 87 acpi_integer design_voltage;
90 acpi_integer design_capacity_warning; 88 acpi_integer design_capacity_warning;
91 acpi_integer design_capacity_low; 89 acpi_integer design_capacity_low;
92 acpi_integer battery_capacity_granularity_1; 90 acpi_integer battery_capacity_granularity_1;
93 acpi_integer battery_capacity_granularity_2; 91 acpi_integer battery_capacity_granularity_2;
94 acpi_string model_number; 92 acpi_string model_number;
95 acpi_string serial_number; 93 acpi_string serial_number;
96 acpi_string battery_type; 94 acpi_string battery_type;
97 acpi_string oem_info; 95 acpi_string oem_info;
98}; 96};
99 97
100struct acpi_battery_flags { 98struct acpi_battery_flags {
101 u8 present:1; /* Bay occupied? */ 99 u8 present:1; /* Bay occupied? */
102 u8 power_unit:1; /* 0=watts, 1=apms */ 100 u8 power_unit:1; /* 0=watts, 1=apms */
103 u8 alarm:1; /* _BTP present? */ 101 u8 alarm:1; /* _BTP present? */
104 u8 reserved:5; 102 u8 reserved:5;
105}; 103};
106 104
107struct acpi_battery_trips { 105struct acpi_battery_trips {
108 unsigned long warning; 106 unsigned long warning;
109 unsigned long low; 107 unsigned long low;
110}; 108};
111 109
112struct acpi_battery { 110struct acpi_battery {
113 acpi_handle handle; 111 acpi_handle handle;
114 struct acpi_battery_flags flags; 112 struct acpi_battery_flags flags;
115 struct acpi_battery_trips trips; 113 struct acpi_battery_trips trips;
116 unsigned long alarm; 114 unsigned long alarm;
117 struct acpi_battery_info *info; 115 struct acpi_battery_info *info;
118}; 116};
119 117
120
121/* -------------------------------------------------------------------------- 118/* --------------------------------------------------------------------------
122 Battery Management 119 Battery Management
123 -------------------------------------------------------------------------- */ 120 -------------------------------------------------------------------------- */
124 121
125static int 122static int
126acpi_battery_get_info ( 123acpi_battery_get_info(struct acpi_battery *battery,
127 struct acpi_battery *battery, 124 struct acpi_battery_info **bif)
128 struct acpi_battery_info **bif)
129{ 125{
130 int result = 0; 126 int result = 0;
131 acpi_status status = 0; 127 acpi_status status = 0;
132 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 128 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
133 struct acpi_buffer format = {sizeof(ACPI_BATTERY_FORMAT_BIF), 129 struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BIF),
134 ACPI_BATTERY_FORMAT_BIF}; 130 ACPI_BATTERY_FORMAT_BIF
135 struct acpi_buffer data = {0, NULL}; 131 };
136 union acpi_object *package = NULL; 132 struct acpi_buffer data = { 0, NULL };
133 union acpi_object *package = NULL;
137 134
138 ACPI_FUNCTION_TRACE("acpi_battery_get_info"); 135 ACPI_FUNCTION_TRACE("acpi_battery_get_info");
139 136
@@ -148,7 +145,7 @@ acpi_battery_get_info (
148 return_VALUE(-ENODEV); 145 return_VALUE(-ENODEV);
149 } 146 }
150 147
151 package = (union acpi_object *) buffer.pointer; 148 package = (union acpi_object *)buffer.pointer;
152 149
153 /* Extract Package Data */ 150 /* Extract Package Data */
154 151
@@ -174,27 +171,27 @@ acpi_battery_get_info (
174 goto end; 171 goto end;
175 } 172 }
176 173
177end: 174 end:
178 acpi_os_free(buffer.pointer); 175 acpi_os_free(buffer.pointer);
179 176
180 if (!result) 177 if (!result)
181 (*bif) = (struct acpi_battery_info *) data.pointer; 178 (*bif) = (struct acpi_battery_info *)data.pointer;
182 179
183 return_VALUE(result); 180 return_VALUE(result);
184} 181}
185 182
186static int 183static int
187acpi_battery_get_status ( 184acpi_battery_get_status(struct acpi_battery *battery,
188 struct acpi_battery *battery, 185 struct acpi_battery_status **bst)
189 struct acpi_battery_status **bst)
190{ 186{
191 int result = 0; 187 int result = 0;
192 acpi_status status = 0; 188 acpi_status status = 0;
193 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 189 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
194 struct acpi_buffer format = {sizeof(ACPI_BATTERY_FORMAT_BST), 190 struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BST),
195 ACPI_BATTERY_FORMAT_BST}; 191 ACPI_BATTERY_FORMAT_BST
196 struct acpi_buffer data = {0, NULL}; 192 };
197 union acpi_object *package = NULL; 193 struct acpi_buffer data = { 0, NULL };
194 union acpi_object *package = NULL;
198 195
199 ACPI_FUNCTION_TRACE("acpi_battery_get_status"); 196 ACPI_FUNCTION_TRACE("acpi_battery_get_status");
200 197
@@ -209,7 +206,7 @@ acpi_battery_get_status (
209 return_VALUE(-ENODEV); 206 return_VALUE(-ENODEV);
210 } 207 }
211 208
212 package = (union acpi_object *) buffer.pointer; 209 package = (union acpi_object *)buffer.pointer;
213 210
214 /* Extract Package Data */ 211 /* Extract Package Data */
215 212
@@ -235,24 +232,21 @@ acpi_battery_get_status (
235 goto end; 232 goto end;
236 } 233 }
237 234
238end: 235 end:
239 acpi_os_free(buffer.pointer); 236 acpi_os_free(buffer.pointer);
240 237
241 if (!result) 238 if (!result)
242 (*bst) = (struct acpi_battery_status *) data.pointer; 239 (*bst) = (struct acpi_battery_status *)data.pointer;
243 240
244 return_VALUE(result); 241 return_VALUE(result);
245} 242}
246 243
247
248static int 244static int
249acpi_battery_set_alarm ( 245acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm)
250 struct acpi_battery *battery,
251 unsigned long alarm)
252{ 246{
253 acpi_status status = 0; 247 acpi_status status = 0;
254 union acpi_object arg0 = {ACPI_TYPE_INTEGER}; 248 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
255 struct acpi_object_list arg_list = {1, &arg0}; 249 struct acpi_object_list arg_list = { 1, &arg0 };
256 250
257 ACPI_FUNCTION_TRACE("acpi_battery_set_alarm"); 251 ACPI_FUNCTION_TRACE("acpi_battery_set_alarm");
258 252
@@ -275,19 +269,16 @@ acpi_battery_set_alarm (
275 return_VALUE(0); 269 return_VALUE(0);
276} 270}
277 271
278 272static int acpi_battery_check(struct acpi_battery *battery)
279static int
280acpi_battery_check (
281 struct acpi_battery *battery)
282{ 273{
283 int result = 0; 274 int result = 0;
284 acpi_status status = AE_OK; 275 acpi_status status = AE_OK;
285 acpi_handle handle = NULL; 276 acpi_handle handle = NULL;
286 struct acpi_device *device = NULL; 277 struct acpi_device *device = NULL;
287 struct acpi_battery_info *bif = NULL; 278 struct acpi_battery_info *bif = NULL;
288 279
289 ACPI_FUNCTION_TRACE("acpi_battery_check"); 280 ACPI_FUNCTION_TRACE("acpi_battery_check");
290 281
291 if (!battery) 282 if (!battery)
292 return_VALUE(-EINVAL); 283 return_VALUE(-EINVAL);
293 284
@@ -336,18 +327,17 @@ acpi_battery_check (
336 return_VALUE(result); 327 return_VALUE(result);
337} 328}
338 329
339
340/* -------------------------------------------------------------------------- 330/* --------------------------------------------------------------------------
341 FS Interface (/proc) 331 FS Interface (/proc)
342 -------------------------------------------------------------------------- */ 332 -------------------------------------------------------------------------- */
343 333
344static struct proc_dir_entry *acpi_battery_dir; 334static struct proc_dir_entry *acpi_battery_dir;
345static int acpi_battery_read_info(struct seq_file *seq, void *offset) 335static int acpi_battery_read_info(struct seq_file *seq, void *offset)
346{ 336{
347 int result = 0; 337 int result = 0;
348 struct acpi_battery *battery = (struct acpi_battery *) seq->private; 338 struct acpi_battery *battery = (struct acpi_battery *)seq->private;
349 struct acpi_battery_info *bif = NULL; 339 struct acpi_battery_info *bif = NULL;
350 char *units = "?"; 340 char *units = "?";
351 341
352 ACPI_FUNCTION_TRACE("acpi_battery_read_info"); 342 ACPI_FUNCTION_TRACE("acpi_battery_read_info");
353 343
@@ -369,19 +359,21 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
369 goto end; 359 goto end;
370 } 360 }
371 361
372 units = bif->power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS; 362 units =
373 363 bif->
364 power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
365
374 if (bif->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN) 366 if (bif->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
375 seq_printf(seq, "design capacity: unknown\n"); 367 seq_printf(seq, "design capacity: unknown\n");
376 else 368 else
377 seq_printf(seq, "design capacity: %d %sh\n", 369 seq_printf(seq, "design capacity: %d %sh\n",
378 (u32) bif->design_capacity, units); 370 (u32) bif->design_capacity, units);
379 371
380 if (bif->last_full_capacity == ACPI_BATTERY_VALUE_UNKNOWN) 372 if (bif->last_full_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
381 seq_printf(seq, "last full capacity: unknown\n"); 373 seq_printf(seq, "last full capacity: unknown\n");
382 else 374 else
383 seq_printf(seq, "last full capacity: %d %sh\n", 375 seq_printf(seq, "last full capacity: %d %sh\n",
384 (u32) bif->last_full_capacity, units); 376 (u32) bif->last_full_capacity, units);
385 377
386 switch ((u32) bif->battery_technology) { 378 switch ((u32) bif->battery_technology) {
387 case 0: 379 case 0:
@@ -399,26 +391,22 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
399 seq_printf(seq, "design voltage: unknown\n"); 391 seq_printf(seq, "design voltage: unknown\n");
400 else 392 else
401 seq_printf(seq, "design voltage: %d mV\n", 393 seq_printf(seq, "design voltage: %d mV\n",
402 (u32) bif->design_voltage); 394 (u32) bif->design_voltage);
403 395
404 seq_printf(seq, "design capacity warning: %d %sh\n", 396 seq_printf(seq, "design capacity warning: %d %sh\n",
405 (u32) bif->design_capacity_warning, units); 397 (u32) bif->design_capacity_warning, units);
406 seq_printf(seq, "design capacity low: %d %sh\n", 398 seq_printf(seq, "design capacity low: %d %sh\n",
407 (u32) bif->design_capacity_low, units); 399 (u32) bif->design_capacity_low, units);
408 seq_printf(seq, "capacity granularity 1: %d %sh\n", 400 seq_printf(seq, "capacity granularity 1: %d %sh\n",
409 (u32) bif->battery_capacity_granularity_1, units); 401 (u32) bif->battery_capacity_granularity_1, units);
410 seq_printf(seq, "capacity granularity 2: %d %sh\n", 402 seq_printf(seq, "capacity granularity 2: %d %sh\n",
411 (u32) bif->battery_capacity_granularity_2, units); 403 (u32) bif->battery_capacity_granularity_2, units);
412 seq_printf(seq, "model number: %s\n", 404 seq_printf(seq, "model number: %s\n", bif->model_number);
413 bif->model_number); 405 seq_printf(seq, "serial number: %s\n", bif->serial_number);
414 seq_printf(seq, "serial number: %s\n", 406 seq_printf(seq, "battery type: %s\n", bif->battery_type);
415 bif->serial_number); 407 seq_printf(seq, "OEM info: %s\n", bif->oem_info);
416 seq_printf(seq, "battery type: %s\n", 408
417 bif->battery_type); 409 end:
418 seq_printf(seq, "OEM info: %s\n",
419 bif->oem_info);
420
421end:
422 kfree(bif); 410 kfree(bif);
423 411
424 return_VALUE(0); 412 return_VALUE(0);
@@ -429,14 +417,12 @@ static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
429 return single_open(file, acpi_battery_read_info, PDE(inode)->data); 417 return single_open(file, acpi_battery_read_info, PDE(inode)->data);
430} 418}
431 419
432 420static int acpi_battery_read_state(struct seq_file *seq, void *offset)
433static int
434acpi_battery_read_state (struct seq_file *seq, void *offset)
435{ 421{
436 int result = 0; 422 int result = 0;
437 struct acpi_battery *battery = (struct acpi_battery *) seq->private; 423 struct acpi_battery *battery = (struct acpi_battery *)seq->private;
438 struct acpi_battery_status *bst = NULL; 424 struct acpi_battery_status *bst = NULL;
439 char *units = "?"; 425 char *units = "?";
440 426
441 ACPI_FUNCTION_TRACE("acpi_battery_read_state"); 427 ACPI_FUNCTION_TRACE("acpi_battery_read_state");
442 428
@@ -452,7 +438,9 @@ acpi_battery_read_state (struct seq_file *seq, void *offset)
452 438
453 /* Battery Units */ 439 /* Battery Units */
454 440
455 units = battery->flags.power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS; 441 units =
442 battery->flags.
443 power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
456 444
457 /* Battery Status (_BST) */ 445 /* Battery Status (_BST) */
458 446
@@ -467,12 +455,12 @@ acpi_battery_read_state (struct seq_file *seq, void *offset)
467 else 455 else
468 seq_printf(seq, "capacity state: critical\n"); 456 seq_printf(seq, "capacity state: critical\n");
469 457
470 if ((bst->state & 0x01) && (bst->state & 0x02)){ 458 if ((bst->state & 0x01) && (bst->state & 0x02)) {
471 seq_printf(seq, "charging state: charging/discharging\n"); 459 seq_printf(seq,
472 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 460 "charging state: charging/discharging\n");
473 "Battery Charging and Discharging?\n")); 461 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
474 } 462 "Battery Charging and Discharging?\n"));
475 else if (bst->state & 0x01) 463 } else if (bst->state & 0x01)
476 seq_printf(seq, "charging state: discharging\n"); 464 seq_printf(seq, "charging state: discharging\n");
477 else if (bst->state & 0x02) 465 else if (bst->state & 0x02)
478 seq_printf(seq, "charging state: charging\n"); 466 seq_printf(seq, "charging state: charging\n");
@@ -484,21 +472,21 @@ acpi_battery_read_state (struct seq_file *seq, void *offset)
484 seq_printf(seq, "present rate: unknown\n"); 472 seq_printf(seq, "present rate: unknown\n");
485 else 473 else
486 seq_printf(seq, "present rate: %d %s\n", 474 seq_printf(seq, "present rate: %d %s\n",
487 (u32) bst->present_rate, units); 475 (u32) bst->present_rate, units);
488 476
489 if (bst->remaining_capacity == ACPI_BATTERY_VALUE_UNKNOWN) 477 if (bst->remaining_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
490 seq_printf(seq, "remaining capacity: unknown\n"); 478 seq_printf(seq, "remaining capacity: unknown\n");
491 else 479 else
492 seq_printf(seq, "remaining capacity: %d %sh\n", 480 seq_printf(seq, "remaining capacity: %d %sh\n",
493 (u32) bst->remaining_capacity, units); 481 (u32) bst->remaining_capacity, units);
494 482
495 if (bst->present_voltage == ACPI_BATTERY_VALUE_UNKNOWN) 483 if (bst->present_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
496 seq_printf(seq, "present voltage: unknown\n"); 484 seq_printf(seq, "present voltage: unknown\n");
497 else 485 else
498 seq_printf(seq, "present voltage: %d mV\n", 486 seq_printf(seq, "present voltage: %d mV\n",
499 (u32) bst->present_voltage); 487 (u32) bst->present_voltage);
500 488
501end: 489 end:
502 kfree(bst); 490 kfree(bst);
503 491
504 return_VALUE(0); 492 return_VALUE(0);
@@ -509,12 +497,10 @@ static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
509 return single_open(file, acpi_battery_read_state, PDE(inode)->data); 497 return single_open(file, acpi_battery_read_state, PDE(inode)->data);
510} 498}
511 499
512 500static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
513static int
514acpi_battery_read_alarm (struct seq_file *seq, void *offset)
515{ 501{
516 struct acpi_battery *battery = (struct acpi_battery *) seq->private; 502 struct acpi_battery *battery = (struct acpi_battery *)seq->private;
517 char *units = "?"; 503 char *units = "?";
518 504
519 ACPI_FUNCTION_TRACE("acpi_battery_read_alarm"); 505 ACPI_FUNCTION_TRACE("acpi_battery_read_alarm");
520 506
@@ -527,8 +513,10 @@ acpi_battery_read_alarm (struct seq_file *seq, void *offset)
527 } 513 }
528 514
529 /* Battery Units */ 515 /* Battery Units */
530 516
531 units = battery->flags.power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS; 517 units =
518 battery->flags.
519 power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
532 520
533 /* Battery Alarm */ 521 /* Battery Alarm */
534 522
@@ -538,22 +526,19 @@ acpi_battery_read_alarm (struct seq_file *seq, void *offset)
538 else 526 else
539 seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units); 527 seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units);
540 528
541end: 529 end:
542 return_VALUE(0); 530 return_VALUE(0);
543} 531}
544 532
545
546static ssize_t 533static ssize_t
547acpi_battery_write_alarm ( 534acpi_battery_write_alarm(struct file *file,
548 struct file *file, 535 const char __user * buffer,
549 const char __user *buffer, 536 size_t count, loff_t * ppos)
550 size_t count,
551 loff_t *ppos)
552{ 537{
553 int result = 0; 538 int result = 0;
554 char alarm_string[12] = {'\0'}; 539 char alarm_string[12] = { '\0' };
555 struct seq_file *m = (struct seq_file *)file->private_data; 540 struct seq_file *m = (struct seq_file *)file->private_data;
556 struct acpi_battery *battery = (struct acpi_battery *)m->private; 541 struct acpi_battery *battery = (struct acpi_battery *)m->private;
557 542
558 ACPI_FUNCTION_TRACE("acpi_battery_write_alarm"); 543 ACPI_FUNCTION_TRACE("acpi_battery_write_alarm");
559 544
@@ -565,11 +550,11 @@ acpi_battery_write_alarm (
565 550
566 if (copy_from_user(alarm_string, buffer, count)) 551 if (copy_from_user(alarm_string, buffer, count))
567 return_VALUE(-EFAULT); 552 return_VALUE(-EFAULT);
568 553
569 alarm_string[count] = '\0'; 554 alarm_string[count] = '\0';
570 555
571 result = acpi_battery_set_alarm(battery, 556 result = acpi_battery_set_alarm(battery,
572 simple_strtoul(alarm_string, NULL, 0)); 557 simple_strtoul(alarm_string, NULL, 0));
573 if (result) 558 if (result)
574 return_VALUE(result); 559 return_VALUE(result);
575 560
@@ -582,41 +567,39 @@ static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
582} 567}
583 568
584static struct file_operations acpi_battery_info_ops = { 569static struct file_operations acpi_battery_info_ops = {
585 .open = acpi_battery_info_open_fs, 570 .open = acpi_battery_info_open_fs,
586 .read = seq_read, 571 .read = seq_read,
587 .llseek = seq_lseek, 572 .llseek = seq_lseek,
588 .release = single_release, 573 .release = single_release,
589 .owner = THIS_MODULE, 574 .owner = THIS_MODULE,
590}; 575};
591 576
592static struct file_operations acpi_battery_state_ops = { 577static struct file_operations acpi_battery_state_ops = {
593 .open = acpi_battery_state_open_fs, 578 .open = acpi_battery_state_open_fs,
594 .read = seq_read, 579 .read = seq_read,
595 .llseek = seq_lseek, 580 .llseek = seq_lseek,
596 .release = single_release, 581 .release = single_release,
597 .owner = THIS_MODULE, 582 .owner = THIS_MODULE,
598}; 583};
599 584
600static struct file_operations acpi_battery_alarm_ops = { 585static struct file_operations acpi_battery_alarm_ops = {
601 .open = acpi_battery_alarm_open_fs, 586 .open = acpi_battery_alarm_open_fs,
602 .read = seq_read, 587 .read = seq_read,
603 .write = acpi_battery_write_alarm, 588 .write = acpi_battery_write_alarm,
604 .llseek = seq_lseek, 589 .llseek = seq_lseek,
605 .release = single_release, 590 .release = single_release,
606 .owner = THIS_MODULE, 591 .owner = THIS_MODULE,
607}; 592};
608 593
609static int 594static int acpi_battery_add_fs(struct acpi_device *device)
610acpi_battery_add_fs (
611 struct acpi_device *device)
612{ 595{
613 struct proc_dir_entry *entry = NULL; 596 struct proc_dir_entry *entry = NULL;
614 597
615 ACPI_FUNCTION_TRACE("acpi_battery_add_fs"); 598 ACPI_FUNCTION_TRACE("acpi_battery_add_fs");
616 599
617 if (!acpi_device_dir(device)) { 600 if (!acpi_device_dir(device)) {
618 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 601 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
619 acpi_battery_dir); 602 acpi_battery_dir);
620 if (!acpi_device_dir(device)) 603 if (!acpi_device_dir(device))
621 return_VALUE(-ENODEV); 604 return_VALUE(-ENODEV);
622 acpi_device_dir(device)->owner = THIS_MODULE; 605 acpi_device_dir(device)->owner = THIS_MODULE;
@@ -624,24 +607,24 @@ acpi_battery_add_fs (
624 607
625 /* 'info' [R] */ 608 /* 'info' [R] */
626 entry = create_proc_entry(ACPI_BATTERY_FILE_INFO, 609 entry = create_proc_entry(ACPI_BATTERY_FILE_INFO,
627 S_IRUGO, acpi_device_dir(device)); 610 S_IRUGO, acpi_device_dir(device));
628 if (!entry) 611 if (!entry)
629 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 612 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
630 "Unable to create '%s' fs entry\n", 613 "Unable to create '%s' fs entry\n",
631 ACPI_BATTERY_FILE_INFO)); 614 ACPI_BATTERY_FILE_INFO));
632 else { 615 else {
633 entry->proc_fops = &acpi_battery_info_ops; 616 entry->proc_fops = &acpi_battery_info_ops;
634 entry->data = acpi_driver_data(device); 617 entry->data = acpi_driver_data(device);
635 entry->owner = THIS_MODULE; 618 entry->owner = THIS_MODULE;
636 } 619 }
637 620
638 /* 'status' [R] */ 621 /* 'status' [R] */
639 entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS, 622 entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS,
640 S_IRUGO, acpi_device_dir(device)); 623 S_IRUGO, acpi_device_dir(device));
641 if (!entry) 624 if (!entry)
642 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 625 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
643 "Unable to create '%s' fs entry\n", 626 "Unable to create '%s' fs entry\n",
644 ACPI_BATTERY_FILE_STATUS)); 627 ACPI_BATTERY_FILE_STATUS));
645 else { 628 else {
646 entry->proc_fops = &acpi_battery_state_ops; 629 entry->proc_fops = &acpi_battery_state_ops;
647 entry->data = acpi_driver_data(device); 630 entry->data = acpi_driver_data(device);
@@ -650,11 +633,12 @@ acpi_battery_add_fs (
650 633
651 /* 'alarm' [R/W] */ 634 /* 'alarm' [R/W] */
652 entry = create_proc_entry(ACPI_BATTERY_FILE_ALARM, 635 entry = create_proc_entry(ACPI_BATTERY_FILE_ALARM,
653 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 636 S_IFREG | S_IRUGO | S_IWUSR,
637 acpi_device_dir(device));
654 if (!entry) 638 if (!entry)
655 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 639 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
656 "Unable to create '%s' fs entry\n", 640 "Unable to create '%s' fs entry\n",
657 ACPI_BATTERY_FILE_ALARM)); 641 ACPI_BATTERY_FILE_ALARM));
658 else { 642 else {
659 entry->proc_fops = &acpi_battery_alarm_ops; 643 entry->proc_fops = &acpi_battery_alarm_ops;
660 entry->data = acpi_driver_data(device); 644 entry->data = acpi_driver_data(device);
@@ -664,10 +648,7 @@ acpi_battery_add_fs (
664 return_VALUE(0); 648 return_VALUE(0);
665} 649}
666 650
667 651static int acpi_battery_remove_fs(struct acpi_device *device)
668static int
669acpi_battery_remove_fs (
670 struct acpi_device *device)
671{ 652{
672 ACPI_FUNCTION_TRACE("acpi_battery_remove_fs"); 653 ACPI_FUNCTION_TRACE("acpi_battery_remove_fs");
673 654
@@ -686,19 +667,14 @@ acpi_battery_remove_fs (
686 return_VALUE(0); 667 return_VALUE(0);
687} 668}
688 669
689
690/* -------------------------------------------------------------------------- 670/* --------------------------------------------------------------------------
691 Driver Interface 671 Driver Interface
692 -------------------------------------------------------------------------- */ 672 -------------------------------------------------------------------------- */
693 673
694static void 674static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
695acpi_battery_notify (
696 acpi_handle handle,
697 u32 event,
698 void *data)
699{ 675{
700 struct acpi_battery *battery = (struct acpi_battery *) data; 676 struct acpi_battery *battery = (struct acpi_battery *)data;
701 struct acpi_device *device = NULL; 677 struct acpi_device *device = NULL;
702 678
703 ACPI_FUNCTION_TRACE("acpi_battery_notify"); 679 ACPI_FUNCTION_TRACE("acpi_battery_notify");
704 680
@@ -716,24 +692,21 @@ acpi_battery_notify (
716 break; 692 break;
717 default: 693 default:
718 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 694 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
719 "Unsupported event [0x%x]\n", event)); 695 "Unsupported event [0x%x]\n", event));
720 break; 696 break;
721 } 697 }
722 698
723 return_VOID; 699 return_VOID;
724} 700}
725 701
726 702static int acpi_battery_add(struct acpi_device *device)
727static int
728acpi_battery_add (
729 struct acpi_device *device)
730{ 703{
731 int result = 0; 704 int result = 0;
732 acpi_status status = 0; 705 acpi_status status = 0;
733 struct acpi_battery *battery = NULL; 706 struct acpi_battery *battery = NULL;
734 707
735 ACPI_FUNCTION_TRACE("acpi_battery_add"); 708 ACPI_FUNCTION_TRACE("acpi_battery_add");
736 709
737 if (!device) 710 if (!device)
738 return_VALUE(-EINVAL); 711 return_VALUE(-EINVAL);
739 712
@@ -756,19 +729,20 @@ acpi_battery_add (
756 goto end; 729 goto end;
757 730
758 status = acpi_install_notify_handler(battery->handle, 731 status = acpi_install_notify_handler(battery->handle,
759 ACPI_DEVICE_NOTIFY, acpi_battery_notify, battery); 732 ACPI_DEVICE_NOTIFY,
733 acpi_battery_notify, battery);
760 if (ACPI_FAILURE(status)) { 734 if (ACPI_FAILURE(status)) {
761 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 735 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
762 "Error installing notify handler\n")); 736 "Error installing notify handler\n"));
763 result = -ENODEV; 737 result = -ENODEV;
764 goto end; 738 goto end;
765 } 739 }
766 740
767 printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n", 741 printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
768 ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), 742 ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
769 device->status.battery_present?"present":"absent"); 743 device->status.battery_present ? "present" : "absent");
770 744
771end: 745 end:
772 if (result) { 746 if (result) {
773 acpi_battery_remove_fs(device); 747 acpi_battery_remove_fs(device);
774 kfree(battery); 748 kfree(battery);
@@ -777,27 +751,24 @@ end:
777 return_VALUE(result); 751 return_VALUE(result);
778} 752}
779 753
780 754static int acpi_battery_remove(struct acpi_device *device, int type)
781static int
782acpi_battery_remove (
783 struct acpi_device *device,
784 int type)
785{ 755{
786 acpi_status status = 0; 756 acpi_status status = 0;
787 struct acpi_battery *battery = NULL; 757 struct acpi_battery *battery = NULL;
788 758
789 ACPI_FUNCTION_TRACE("acpi_battery_remove"); 759 ACPI_FUNCTION_TRACE("acpi_battery_remove");
790 760
791 if (!device || !acpi_driver_data(device)) 761 if (!device || !acpi_driver_data(device))
792 return_VALUE(-EINVAL); 762 return_VALUE(-EINVAL);
793 763
794 battery = (struct acpi_battery *) acpi_driver_data(device); 764 battery = (struct acpi_battery *)acpi_driver_data(device);
795 765
796 status = acpi_remove_notify_handler(battery->handle, 766 status = acpi_remove_notify_handler(battery->handle,
797 ACPI_DEVICE_NOTIFY, acpi_battery_notify); 767 ACPI_DEVICE_NOTIFY,
768 acpi_battery_notify);
798 if (ACPI_FAILURE(status)) 769 if (ACPI_FAILURE(status))
799 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 770 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
800 "Error removing notify handler\n")); 771 "Error removing notify handler\n"));
801 772
802 acpi_battery_remove_fs(device); 773 acpi_battery_remove_fs(device);
803 774
@@ -806,11 +777,9 @@ acpi_battery_remove (
806 return_VALUE(0); 777 return_VALUE(0);
807} 778}
808 779
809 780static int __init acpi_battery_init(void)
810static int __init
811acpi_battery_init (void)
812{ 781{
813 int result = 0; 782 int result = 0;
814 783
815 ACPI_FUNCTION_TRACE("acpi_battery_init"); 784 ACPI_FUNCTION_TRACE("acpi_battery_init");
816 785
@@ -828,9 +797,7 @@ acpi_battery_init (void)
828 return_VALUE(0); 797 return_VALUE(0);
829} 798}
830 799
831 800static void __exit acpi_battery_exit(void)
832static void __exit
833acpi_battery_exit (void)
834{ 801{
835 ACPI_FUNCTION_TRACE("acpi_battery_exit"); 802 ACPI_FUNCTION_TRACE("acpi_battery_exit");
836 803
@@ -841,6 +808,5 @@ acpi_battery_exit (void)
841 return_VOID; 808 return_VOID;
842} 809}
843 810
844
845module_init(acpi_battery_init); 811module_init(acpi_battery_init);
846module_exit(acpi_battery_exit); 812module_exit(acpi_battery_exit);