aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/battery.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/battery.c')
-rw-r--r--drivers/acpi/battery.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 026e40755cdd..5f43e0d14899 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -149,7 +149,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
149 return -ENODEV; 149 return -ENODEV;
150 } 150 }
151 151
152 package = (union acpi_object *)buffer.pointer; 152 package = buffer.pointer;
153 153
154 /* Extract Package Data */ 154 /* Extract Package Data */
155 155
@@ -160,12 +160,11 @@ acpi_battery_get_info(struct acpi_battery *battery,
160 goto end; 160 goto end;
161 } 161 }
162 162
163 data.pointer = kmalloc(data.length, GFP_KERNEL); 163 data.pointer = kzalloc(data.length, GFP_KERNEL);
164 if (!data.pointer) { 164 if (!data.pointer) {
165 result = -ENOMEM; 165 result = -ENOMEM;
166 goto end; 166 goto end;
167 } 167 }
168 memset(data.pointer, 0, data.length);
169 168
170 status = acpi_extract_package(package, &format, &data); 169 status = acpi_extract_package(package, &format, &data);
171 if (ACPI_FAILURE(status)) { 170 if (ACPI_FAILURE(status)) {
@@ -179,7 +178,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
179 kfree(buffer.pointer); 178 kfree(buffer.pointer);
180 179
181 if (!result) 180 if (!result)
182 (*bif) = (struct acpi_battery_info *)data.pointer; 181 (*bif) = data.pointer;
183 182
184 return result; 183 return result;
185} 184}
@@ -209,7 +208,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
209 return -ENODEV; 208 return -ENODEV;
210 } 209 }
211 210
212 package = (union acpi_object *)buffer.pointer; 211 package = buffer.pointer;
213 212
214 /* Extract Package Data */ 213 /* Extract Package Data */
215 214
@@ -220,12 +219,11 @@ acpi_battery_get_status(struct acpi_battery *battery,
220 goto end; 219 goto end;
221 } 220 }
222 221
223 data.pointer = kmalloc(data.length, GFP_KERNEL); 222 data.pointer = kzalloc(data.length, GFP_KERNEL);
224 if (!data.pointer) { 223 if (!data.pointer) {
225 result = -ENOMEM; 224 result = -ENOMEM;
226 goto end; 225 goto end;
227 } 226 }
228 memset(data.pointer, 0, data.length);
229 227
230 status = acpi_extract_package(package, &format, &data); 228 status = acpi_extract_package(package, &format, &data);
231 if (ACPI_FAILURE(status)) { 229 if (ACPI_FAILURE(status)) {
@@ -239,7 +237,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
239 kfree(buffer.pointer); 237 kfree(buffer.pointer);
240 238
241 if (!result) 239 if (!result)
242 (*bst) = (struct acpi_battery_status *)data.pointer; 240 (*bst) = data.pointer;
243 241
244 return result; 242 return result;
245} 243}
@@ -334,7 +332,7 @@ static struct proc_dir_entry *acpi_battery_dir;
334static int acpi_battery_read_info(struct seq_file *seq, void *offset) 332static int acpi_battery_read_info(struct seq_file *seq, void *offset)
335{ 333{
336 int result = 0; 334 int result = 0;
337 struct acpi_battery *battery = (struct acpi_battery *)seq->private; 335 struct acpi_battery *battery = seq->private;
338 struct acpi_battery_info *bif = NULL; 336 struct acpi_battery_info *bif = NULL;
339 char *units = "?"; 337 char *units = "?";
340 338
@@ -418,7 +416,7 @@ static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
418static int acpi_battery_read_state(struct seq_file *seq, void *offset) 416static int acpi_battery_read_state(struct seq_file *seq, void *offset)
419{ 417{
420 int result = 0; 418 int result = 0;
421 struct acpi_battery *battery = (struct acpi_battery *)seq->private; 419 struct acpi_battery *battery = seq->private;
422 struct acpi_battery_status *bst = NULL; 420 struct acpi_battery_status *bst = NULL;
423 char *units = "?"; 421 char *units = "?";
424 422
@@ -494,7 +492,7 @@ static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
494 492
495static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) 493static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
496{ 494{
497 struct acpi_battery *battery = (struct acpi_battery *)seq->private; 495 struct acpi_battery *battery = seq->private;
498 char *units = "?"; 496 char *units = "?";
499 497
500 498
@@ -531,8 +529,8 @@ acpi_battery_write_alarm(struct file *file,
531{ 529{
532 int result = 0; 530 int result = 0;
533 char alarm_string[12] = { '\0' }; 531 char alarm_string[12] = { '\0' };
534 struct seq_file *m = (struct seq_file *)file->private_data; 532 struct seq_file *m = file->private_data;
535 struct acpi_battery *battery = (struct acpi_battery *)m->private; 533 struct acpi_battery *battery = m->private;
536 534
537 535
538 if (!battery || (count > sizeof(alarm_string) - 1)) 536 if (!battery || (count > sizeof(alarm_string) - 1))
@@ -658,7 +656,7 @@ static int acpi_battery_remove_fs(struct acpi_device *device)
658 656
659static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) 657static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
660{ 658{
661 struct acpi_battery *battery = (struct acpi_battery *)data; 659 struct acpi_battery *battery = data;
662 struct acpi_device *device = NULL; 660 struct acpi_device *device = NULL;
663 661
664 662
@@ -694,10 +692,9 @@ static int acpi_battery_add(struct acpi_device *device)
694 if (!device) 692 if (!device)
695 return -EINVAL; 693 return -EINVAL;
696 694
697 battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL); 695 battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
698 if (!battery) 696 if (!battery)
699 return -ENOMEM; 697 return -ENOMEM;
700 memset(battery, 0, sizeof(struct acpi_battery));
701 698
702 battery->device = device; 699 battery->device = device;
703 strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); 700 strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
@@ -742,7 +739,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
742 if (!device || !acpi_driver_data(device)) 739 if (!device || !acpi_driver_data(device))
743 return -EINVAL; 740 return -EINVAL;
744 741
745 battery = (struct acpi_battery *)acpi_driver_data(device); 742 battery = acpi_driver_data(device);
746 743
747 status = acpi_remove_notify_handler(device->handle, 744 status = acpi_remove_notify_handler(device->handle,
748 ACPI_ALL_NOTIFY, 745 ACPI_ALL_NOTIFY,