Commit c299eba3c5a801657f275d33be588b34831cd30e

Authored by Linus Torvalds

Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6

* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (28 commits)
  ACPI:  delete stale reference in kernel-parameters.txt
  ACPI: add missing _OSI strings
  ACPI: remove NID_INVAL
  thermal: make THERMAL_HWMON implementation fully internal
  thermal: split hwmon lookup to a separate function
  thermal: hide CONFIG_THERMAL_HWMON
  ACPI print OSI(Linux) warning only once
  ACPI: DMI workaround for Asus A8N-SLI Premium and Asus A8N-SLI DELUX
  ACPI / Battery: propagate sysfs error in acpi_battery_add()
  ACPI / Battery: avoid acpi_battery_add() use-after-free
  ACPI: introduce "acpi_rsdp=" parameter for kdump
  ACPI: constify ops structs
  ACPI: fix CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS
  ACPI: fix 80 char overflow
  ACPI / Battery: Resolve the race condition in the sysfs_remove_battery()
  ACPI / Battery: Add the check before refresh sysfs in the battery_notify()
  ACPI / Battery: Add the hibernation process in the battery_notify()
  ACPI / Battery: Rename acpi_battery_quirks2 with acpi_battery_quirks
  ACPI / Battery: Change 16-bit signed negative battery current into correct value
  ACPI / Battery: Add the power unit macro
  ...

Showing 30 changed files Side-by-side Diff

Documentation/feature-removal-schedule.txt
... ... @@ -296,15 +296,6 @@
296 296  
297 297 ---------------------------
298 298  
299   -What: CONFIG_THERMAL_HWMON
300   -When: January 2009
301   -Why: This option was introduced just to allow older lm-sensors userspace
302   - to keep working over the upgrade to 2.6.26. At the scheduled time of
303   - removal fixed lm-sensors (2.x or 3.x) should be readily available.
304   -Who: Rene Herman <rene.herman@gmail.com>
305   -
306   ----------------------------
307   -
308 299 What: Code that is now under CONFIG_WIRELESS_EXT_SYSFS
309 300 (in net/core/net-sysfs.c)
310 301 When: After the only user (hal) has seen a release with the patches
Documentation/kernel-parameters.txt
... ... @@ -163,6 +163,11 @@
163 163  
164 164 See also Documentation/power/pm.txt, pci=noacpi
165 165  
  166 + acpi_rsdp= [ACPI,EFI,KEXEC]
  167 + Pass the RSDP address to the kernel, mostly used
  168 + on machines running EFI runtime service to boot the
  169 + second kernel for kdump.
  170 +
166 171 acpi_apic_instance= [ACPI, IOAPIC]
167 172 Format: <int>
168 173 2: use 2nd APIC table, if available
drivers/acpi/acpica/acglobal.h
... ... @@ -126,6 +126,12 @@
126 126 */
127 127 u8 ACPI_INIT_GLOBAL(acpi_gbl_truncate_io_addresses, FALSE);
128 128  
  129 +/*
  130 + * Disable runtime checking and repair of values returned by control methods.
  131 + * Use only if the repair is causing a problem on a particular machine.
  132 + */
  133 +u8 ACPI_INIT_GLOBAL(acpi_gbl_disable_auto_repair, FALSE);
  134 +
129 135 /* acpi_gbl_FADT is a local copy of the FADT, converted to a common format. */
130 136  
131 137 struct acpi_table_fadt acpi_gbl_FADT;
drivers/acpi/acpica/aclocal.h
... ... @@ -357,6 +357,7 @@
357 357 char *pathname;
358 358 const union acpi_predefined_info *predefined;
359 359 union acpi_operand_object *parent_package;
  360 + struct acpi_namespace_node *node;
360 361 u32 flags;
361 362 u8 node_flags;
362 363 };
drivers/acpi/acpica/acpredef.h
... ... @@ -468,6 +468,7 @@
468 468 {{"_SWS", 0, ACPI_RTYPE_INTEGER}},
469 469 {{"_TC1", 0, ACPI_RTYPE_INTEGER}},
470 470 {{"_TC2", 0, ACPI_RTYPE_INTEGER}},
  471 + {{"_TDL", 0, ACPI_RTYPE_INTEGER}},
471 472 {{"_TIP", 1, ACPI_RTYPE_INTEGER}},
472 473 {{"_TIV", 1, ACPI_RTYPE_INTEGER}},
473 474 {{"_TMP", 0, ACPI_RTYPE_INTEGER}},
drivers/acpi/acpica/nspredef.c
... ... @@ -193,14 +193,20 @@
193 193 }
194 194  
195 195 /*
196   - * 1) We have a return value, but if one wasn't expected, just exit, this is
197   - * not a problem. For example, if the "Implicit Return" feature is
198   - * enabled, methods will always return a value.
  196 + * Return value validation and possible repair.
199 197 *
200   - * 2) If the return value can be of any type, then we cannot perform any
201   - * validation, exit.
  198 + * 1) Don't perform return value validation/repair if this feature
  199 + * has been disabled via a global option.
  200 + *
  201 + * 2) We have a return value, but if one wasn't expected, just exit,
  202 + * this is not a problem. For example, if the "Implicit Return"
  203 + * feature is enabled, methods will always return a value.
  204 + *
  205 + * 3) If the return value can be of any type, then we cannot perform
  206 + * any validation, just exit.
202 207 */
203   - if ((!predefined->info.expected_btypes) ||
  208 + if (acpi_gbl_disable_auto_repair ||
  209 + (!predefined->info.expected_btypes) ||
204 210 (predefined->info.expected_btypes == ACPI_RTYPE_ALL)) {
205 211 goto cleanup;
206 212 }
... ... @@ -212,6 +218,7 @@
212 218 goto cleanup;
213 219 }
214 220 data->predefined = predefined;
  221 + data->node = node;
215 222 data->node_flags = node->flags;
216 223 data->pathname = pathname;
217 224  
drivers/acpi/acpica/nsrepair2.c
... ... @@ -503,6 +503,21 @@
503 503 {
504 504 union acpi_operand_object *return_object = *return_object_ptr;
505 505 acpi_status status;
  506 + struct acpi_namespace_node *node;
  507 +
  508 + /*
  509 + * We can only sort the _TSS return package if there is no _PSS in the
  510 + * same scope. This is because if _PSS is present, the ACPI specification
  511 + * dictates that the _TSS Power Dissipation field is to be ignored, and
  512 + * therefore some BIOSs leave garbage values in the _TSS Power field(s).
  513 + * In this case, it is best to just return the _TSS package as-is.
  514 + * (May, 2011)
  515 + */
  516 + status =
  517 + acpi_ns_get_node(data->node, "^_PSS", ACPI_NS_NO_UPSEARCH, &node);
  518 + if (ACPI_SUCCESS(status)) {
  519 + return (AE_OK);
  520 + }
506 521  
507 522 status = acpi_ns_check_sorted_list(data, return_object, 5, 1,
508 523 ACPI_SORT_DESCENDING,
drivers/acpi/acpica/tbinstal.c
... ... @@ -126,12 +126,29 @@
126 126 }
127 127  
128 128 /*
129   - * Originally, we checked the table signature for "SSDT" or "PSDT" here.
130   - * Next, we added support for OEMx tables, signature "OEM".
131   - * Valid tables were encountered with a null signature, so we've just
132   - * given up on validating the signature, since it seems to be a waste
133   - * of code. The original code was removed (05/2008).
  129 + * Validate the incoming table signature.
  130 + *
  131 + * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
  132 + * 2) We added support for OEMx tables, signature "OEM".
  133 + * 3) Valid tables were encountered with a null signature, so we just
  134 + * gave up on validating the signature, (05/2008).
  135 + * 4) We encountered non-AML tables such as the MADT, which caused
  136 + * interpreter errors and kernel faults. So now, we once again allow
  137 + * only "SSDT", "OEMx", and now, also a null signature. (05/2011).
134 138 */
  139 + if ((table_desc->pointer->signature[0] != 0x00) &&
  140 + (!ACPI_COMPARE_NAME(table_desc->pointer->signature, ACPI_SIG_SSDT))
  141 + && (ACPI_STRNCMP(table_desc->pointer->signature, "OEM", 3))) {
  142 + ACPI_ERROR((AE_INFO,
  143 + "Table has invalid signature [%4.4s] (0x%8.8X), must be SSDT or OEMx",
  144 + acpi_ut_valid_acpi_name(*(u32 *)table_desc->
  145 + pointer->
  146 + signature) ? table_desc->
  147 + pointer->signature : "????",
  148 + *(u32 *)table_desc->pointer->signature));
  149 +
  150 + return_ACPI_STATUS(AE_BAD_SIGNATURE);
  151 + }
135 152  
136 153 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
137 154  
drivers/acpi/battery.c
... ... @@ -55,6 +55,9 @@
55 55 #define ACPI_BATTERY_NOTIFY_INFO 0x81
56 56 #define ACPI_BATTERY_NOTIFY_THRESHOLD 0x82
57 57  
  58 +/* Battery power unit: 0 means mW, 1 means mA */
  59 +#define ACPI_BATTERY_POWER_UNIT_MA 1
  60 +
58 61 #define _COMPONENT ACPI_BATTERY_COMPONENT
59 62  
60 63 ACPI_MODULE_NAME("battery");
... ... @@ -91,11 +94,6 @@
91 94 enum {
92 95 ACPI_BATTERY_ALARM_PRESENT,
93 96 ACPI_BATTERY_XINFO_PRESENT,
94   - /* For buggy DSDTs that report negative 16-bit values for either
95   - * charging or discharging current and/or report 0 as 65536
96   - * due to bad math.
97   - */
98   - ACPI_BATTERY_QUIRK_SIGNED16_CURRENT,
99 97 ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY,
100 98 };
101 99  
... ... @@ -301,7 +299,8 @@
301 299 #ifdef CONFIG_ACPI_PROCFS_POWER
302 300 inline char *acpi_battery_units(struct acpi_battery *battery)
303 301 {
304   - return (battery->power_unit)?"mA":"mW";
  302 + return (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA) ?
  303 + "mA" : "mW";
305 304 }
306 305 #endif
307 306  
308 307  
... ... @@ -461,9 +460,17 @@
461 460 battery->update_time = jiffies;
462 461 kfree(buffer.pointer);
463 462  
464   - if (test_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags) &&
465   - battery->rate_now != -1)
  463 + /* For buggy DSDTs that report negative 16-bit values for either
  464 + * charging or discharging current and/or report 0 as 65536
  465 + * due to bad math.
  466 + */
  467 + if (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA &&
  468 + battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN &&
  469 + (s16)(battery->rate_now) < 0) {
466 470 battery->rate_now = abs((s16)battery->rate_now);
  471 + printk_once(KERN_WARNING FW_BUG "battery: (dis)charge rate"
  472 + " invalid.\n");
  473 + }
467 474  
468 475 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)
469 476 && battery->capacity_now >= 0 && battery->capacity_now <= 100)
... ... @@ -544,7 +551,7 @@
544 551 {
545 552 int result;
546 553  
547   - if (battery->power_unit) {
  554 + if (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA) {
548 555 battery->bat.properties = charge_battery_props;
549 556 battery->bat.num_properties =
550 557 ARRAY_SIZE(charge_battery_props);
551 558  
552 559  
553 560  
... ... @@ -566,20 +573,18 @@
566 573  
567 574 static void sysfs_remove_battery(struct acpi_battery *battery)
568 575 {
569   - if (!battery->bat.dev)
  576 + mutex_lock(&battery->lock);
  577 + if (!battery->bat.dev) {
  578 + mutex_unlock(&battery->lock);
570 579 return;
  580 + }
  581 +
571 582 device_remove_file(battery->bat.dev, &alarm_attr);
572 583 power_supply_unregister(&battery->bat);
573 584 battery->bat.dev = NULL;
  585 + mutex_unlock(&battery->lock);
574 586 }
575 587  
576   -static void acpi_battery_quirks(struct acpi_battery *battery)
577   -{
578   - if (dmi_name_in_vendors("Acer") && battery->power_unit) {
579   - set_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags);
580   - }
581   -}
582   -
583 588 /*
584 589 * According to the ACPI spec, some kinds of primary batteries can
585 590 * report percentage battery remaining capacity directly to OS.
... ... @@ -592,7 +597,7 @@
592 597 *
593 598 * Handle this correctly so that they won't break userspace.
594 599 */
595   -static void acpi_battery_quirks2(struct acpi_battery *battery)
  600 +static void acpi_battery_quirks(struct acpi_battery *battery)
596 601 {
597 602 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags))
598 603 return ;
599 604  
600 605  
... ... @@ -623,13 +628,15 @@
623 628 result = acpi_battery_get_info(battery);
624 629 if (result)
625 630 return result;
626   - acpi_battery_quirks(battery);
627 631 acpi_battery_init_alarm(battery);
628 632 }
629   - if (!battery->bat.dev)
630   - sysfs_add_battery(battery);
  633 + if (!battery->bat.dev) {
  634 + result = sysfs_add_battery(battery);
  635 + if (result)
  636 + return result;
  637 + }
631 638 result = acpi_battery_get_state(battery);
632   - acpi_battery_quirks2(battery);
  639 + acpi_battery_quirks(battery);
633 640 return result;
634 641 }
635 642  
... ... @@ -863,7 +870,7 @@
863 870 }, \
864 871 }
865 872  
866   -static struct battery_file {
  873 +static const struct battery_file {
867 874 struct file_operations ops;
868 875 mode_t mode;
869 876 const char *name;
870 877  
... ... @@ -948,9 +955,12 @@
948 955 struct acpi_battery *battery = container_of(nb, struct acpi_battery,
949 956 pm_nb);
950 957 switch (mode) {
  958 + case PM_POST_HIBERNATION:
951 959 case PM_POST_SUSPEND:
952   - sysfs_remove_battery(battery);
953   - sysfs_add_battery(battery);
  960 + if (battery->bat.dev) {
  961 + sysfs_remove_battery(battery);
  962 + sysfs_add_battery(battery);
  963 + }
954 964 break;
955 965 }
956 966  
957 967  
958 968  
959 969  
960 970  
... ... @@ -975,24 +985,32 @@
975 985 if (ACPI_SUCCESS(acpi_get_handle(battery->device->handle,
976 986 "_BIX", &handle)))
977 987 set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
978   - acpi_battery_update(battery);
  988 + result = acpi_battery_update(battery);
  989 + if (result)
  990 + goto fail;
979 991 #ifdef CONFIG_ACPI_PROCFS_POWER
980 992 result = acpi_battery_add_fs(device);
981 993 #endif
982   - if (!result) {
983   - printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
984   - ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
985   - device->status.battery_present ? "present" : "absent");
986   - } else {
  994 + if (result) {
987 995 #ifdef CONFIG_ACPI_PROCFS_POWER
988 996 acpi_battery_remove_fs(device);
989 997 #endif
990   - kfree(battery);
  998 + goto fail;
991 999 }
992 1000  
  1001 + printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
  1002 + ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
  1003 + device->status.battery_present ? "present" : "absent");
  1004 +
993 1005 battery->pm_nb.notifier_call = battery_notify;
994 1006 register_pm_notifier(&battery->pm_nb);
995 1007  
  1008 + return result;
  1009 +
  1010 +fail:
  1011 + sysfs_remove_battery(battery);
  1012 + mutex_destroy(&battery->lock);
  1013 + kfree(battery);
996 1014 return result;
997 1015 }
998 1016  
... ... @@ -77,7 +77,7 @@
77 77 struct list_head list;
78 78 struct list_head hotplug_list;
79 79 acpi_handle handle;
80   - struct acpi_dock_ops *ops;
  80 + const struct acpi_dock_ops *ops;
81 81 void *context;
82 82 };
83 83  
... ... @@ -589,7 +589,7 @@
589 589 * the dock driver after _DCK is executed.
590 590 */
591 591 int
592   -register_hotplug_dock_device(acpi_handle handle, struct acpi_dock_ops *ops,
  592 +register_hotplug_dock_device(acpi_handle handle, const struct acpi_dock_ops *ops,
593 593 void *context)
594 594 {
595 595 struct dock_dependent_device *dd;
drivers/acpi/ec_sys.c
... ... @@ -92,7 +92,7 @@
92 92 return count;
93 93 }
94 94  
95   -static struct file_operations acpi_ec_io_ops = {
  95 +static const struct file_operations acpi_ec_io_ops = {
96 96 .owner = THIS_MODULE,
97 97 .open = acpi_ec_open_io,
98 98 .read = acpi_ec_read_io,
... ... @@ -110,7 +110,7 @@
110 110 return result;
111 111 }
112 112  
113   -static struct thermal_cooling_device_ops fan_cooling_ops = {
  113 +static const struct thermal_cooling_device_ops fan_cooling_ops = {
114 114 .get_max_state = fan_get_max_state,
115 115 .get_cur_state = fan_get_cur_state,
116 116 .set_cur_state = fan_set_cur_state,
... ... @@ -155,7 +155,7 @@
155 155 {
156 156 if (!strcmp("Linux", interface)) {
157 157  
158   - printk(KERN_NOTICE FW_BUG PREFIX
  158 + printk_once(KERN_NOTICE FW_BUG PREFIX
159 159 "BIOS _OSI(Linux) query %s%s\n",
160 160 osi_linux.enable ? "honored" : "ignored",
161 161 osi_linux.cmdline ? " via cmdline" :
162 162  
... ... @@ -237,8 +237,23 @@
237 237 #endif
238 238 }
239 239  
  240 +#ifdef CONFIG_KEXEC
  241 +static unsigned long acpi_rsdp;
  242 +static int __init setup_acpi_rsdp(char *arg)
  243 +{
  244 + acpi_rsdp = simple_strtoul(arg, NULL, 16);
  245 + return 0;
  246 +}
  247 +early_param("acpi_rsdp", setup_acpi_rsdp);
  248 +#endif
  249 +
240 250 acpi_physical_address __init acpi_os_get_root_pointer(void)
241 251 {
  252 +#ifdef CONFIG_KEXEC
  253 + if (acpi_rsdp)
  254 + return acpi_rsdp;
  255 +#endif
  256 +
242 257 if (efi_enabled) {
243 258 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
244 259 return efi.acpi20;
... ... @@ -1083,7 +1098,13 @@
1083 1098 bool enable;
1084 1099 };
1085 1100  
1086   -static struct osi_setup_entry __initdata osi_setup_entries[OSI_STRING_ENTRIES_MAX];
  1101 +static struct osi_setup_entry __initdata
  1102 + osi_setup_entries[OSI_STRING_ENTRIES_MAX] = {
  1103 + {"Module Device", true},
  1104 + {"Processor Device", true},
  1105 + {"3.0 _SCP Extensions", true},
  1106 + {"Processor Aggregator Device", true},
  1107 +};
1087 1108  
1088 1109 void __init acpi_osi_setup(char *str)
1089 1110 {
drivers/acpi/pci_irq.c
... ... @@ -303,6 +303,61 @@
303 303 /* --------------------------------------------------------------------------
304 304 PCI Interrupt Routing Support
305 305 -------------------------------------------------------------------------- */
  306 +#ifdef CONFIG_X86_IO_APIC
  307 +extern int noioapicquirk;
  308 +extern int noioapicreroute;
  309 +
  310 +static int bridge_has_boot_interrupt_variant(struct pci_bus *bus)
  311 +{
  312 + struct pci_bus *bus_it;
  313 +
  314 + for (bus_it = bus ; bus_it ; bus_it = bus_it->parent) {
  315 + if (!bus_it->self)
  316 + return 0;
  317 + if (bus_it->self->irq_reroute_variant)
  318 + return bus_it->self->irq_reroute_variant;
  319 + }
  320 + return 0;
  321 +}
  322 +
  323 +/*
  324 + * Some chipsets (e.g. Intel 6700PXH) generate a legacy INTx when the IRQ
  325 + * entry in the chipset's IO-APIC is masked (as, e.g. the RT kernel does
  326 + * during interrupt handling). When this INTx generation cannot be disabled,
  327 + * we reroute these interrupts to their legacy equivalent to get rid of
  328 + * spurious interrupts.
  329 + */
  330 +static int acpi_reroute_boot_interrupt(struct pci_dev *dev,
  331 + struct acpi_prt_entry *entry)
  332 +{
  333 + if (noioapicquirk || noioapicreroute) {
  334 + return 0;
  335 + } else {
  336 + switch (bridge_has_boot_interrupt_variant(dev->bus)) {
  337 + case 0:
  338 + /* no rerouting necessary */
  339 + return 0;
  340 + case INTEL_IRQ_REROUTE_VARIANT:
  341 + /*
  342 + * Remap according to INTx routing table in 6700PXH
  343 + * specs, intel order number 302628-002, section
  344 + * 2.15.2. Other chipsets (80332, ...) have the same
  345 + * mapping and are handled here as well.
  346 + */
  347 + dev_info(&dev->dev, "PCI IRQ %d -> rerouted to legacy "
  348 + "IRQ %d\n", entry->index,
  349 + (entry->index % 4) + 16);
  350 + entry->index = (entry->index % 4) + 16;
  351 + return 1;
  352 + default:
  353 + dev_warn(&dev->dev, "Cannot reroute IRQ %d to legacy "
  354 + "IRQ: unknown mapping\n", entry->index);
  355 + return -1;
  356 + }
  357 + }
  358 +}
  359 +#endif /* CONFIG_X86_IO_APIC */
  360 +
306 361 static struct acpi_prt_entry *acpi_pci_irq_lookup(struct pci_dev *dev, int pin)
307 362 {
308 363 struct acpi_prt_entry *entry;
... ... @@ -311,6 +366,9 @@
311 366  
312 367 entry = acpi_pci_irq_find_prt_entry(dev, pin);
313 368 if (entry) {
  369 +#ifdef CONFIG_X86_IO_APIC
  370 + acpi_reroute_boot_interrupt(dev, entry);
  371 +#endif /* CONFIG_X86_IO_APIC */
314 372 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %s[%c] _PRT entry\n",
315 373 pci_name(dev), pin_name(pin)));
316 374 return entry;
drivers/acpi/pci_root.c
... ... @@ -485,7 +485,8 @@
485 485 root->secondary.end = 0xFF;
486 486 printk(KERN_WARNING FW_BUG PREFIX
487 487 "no secondary bus range in _CRS\n");
488   - status = acpi_evaluate_integer(device->handle, METHOD_NAME__BBN, NULL, &bus);
  488 + status = acpi_evaluate_integer(device->handle, METHOD_NAME__BBN,
  489 + NULL, &bus);
489 490 if (ACPI_SUCCESS(status))
490 491 root->secondary.start = bus;
491 492 else if (status == AE_NOT_FOUND)
drivers/acpi/processor_thermal.c
... ... @@ -244,7 +244,7 @@
244 244 return result;
245 245 }
246 246  
247   -struct thermal_cooling_device_ops processor_cooling_ops = {
  247 +const struct thermal_cooling_device_ops processor_cooling_ops = {
248 248 .get_max_state = processor_get_max_state,
249 249 .get_cur_state = processor_get_cur_state,
250 250 .set_cur_state = processor_set_cur_state,
... ... @@ -130,6 +130,9 @@
130 130  
131 131 #define to_acpi_sbs(x) container_of(x, struct acpi_sbs, charger)
132 132  
  133 +static int acpi_sbs_remove(struct acpi_device *device, int type);
  134 +static int acpi_battery_get_state(struct acpi_battery *battery);
  135 +
133 136 static inline int battery_scale(int log)
134 137 {
135 138 int scale = 1;
... ... @@ -195,6 +198,8 @@
195 198  
196 199 if ((!battery->present) && psp != POWER_SUPPLY_PROP_PRESENT)
197 200 return -ENODEV;
  201 +
  202 + acpi_battery_get_state(battery);
198 203 switch (psp) {
199 204 case POWER_SUPPLY_PROP_STATUS:
200 205 if (battery->rate_now < 0)
201 206  
... ... @@ -225,11 +230,17 @@
225 230 case POWER_SUPPLY_PROP_POWER_NOW:
226 231 val->intval = abs(battery->rate_now) *
227 232 acpi_battery_ipscale(battery) * 1000;
  233 + val->intval *= (acpi_battery_mode(battery)) ?
  234 + (battery->voltage_now *
  235 + acpi_battery_vscale(battery) / 1000) : 1;
228 236 break;
229 237 case POWER_SUPPLY_PROP_CURRENT_AVG:
230 238 case POWER_SUPPLY_PROP_POWER_AVG:
231 239 val->intval = abs(battery->rate_avg) *
232 240 acpi_battery_ipscale(battery) * 1000;
  241 + val->intval *= (acpi_battery_mode(battery)) ?
  242 + (battery->voltage_now *
  243 + acpi_battery_vscale(battery) / 1000) : 1;
233 244 break;
234 245 case POWER_SUPPLY_PROP_CAPACITY:
235 246 val->intval = battery->state_of_charge;
... ... @@ -902,8 +913,6 @@
902 913 }
903 914 }
904 915 }
905   -
906   -static int acpi_sbs_remove(struct acpi_device *device, int type);
907 916  
908 917 static int acpi_sbs_add(struct acpi_device *device)
909 918 {
drivers/acpi/sleep.c
... ... @@ -428,6 +428,22 @@
428 428 DMI_MATCH(DMI_PRODUCT_NAME, "1000 Series"),
429 429 },
430 430 },
  431 + {
  432 + .callback = init_old_suspend_ordering,
  433 + .ident = "Asus A8N-SLI DELUXE",
  434 + .matches = {
  435 + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  436 + DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI DELUXE"),
  437 + },
  438 + },
  439 + {
  440 + .callback = init_old_suspend_ordering,
  441 + .ident = "Asus A8N-SLI Premium",
  442 + .matches = {
  443 + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  444 + DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI Premium"),
  445 + },
  446 + },
431 447 {},
432 448 };
433 449 #endif /* CONFIG_SUSPEND */
drivers/acpi/sysfs.c
... ... @@ -149,12 +149,12 @@
149 149 return result;
150 150 }
151 151  
152   -static struct kernel_param_ops param_ops_debug_layer = {
  152 +static const struct kernel_param_ops param_ops_debug_layer = {
153 153 .set = param_set_uint,
154 154 .get = param_get_debug_layer,
155 155 };
156 156  
157   -static struct kernel_param_ops param_ops_debug_level = {
  157 +static const struct kernel_param_ops param_ops_debug_level = {
158 158 .set = param_set_uint,
159 159 .get = param_get_debug_level,
160 160 };
drivers/acpi/thermal.c
... ... @@ -812,7 +812,7 @@
812 812 thermal_zone_unbind_cooling_device);
813 813 }
814 814  
815   -static struct thermal_zone_device_ops acpi_thermal_zone_ops = {
  815 +static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {
816 816 .bind = acpi_thermal_bind_cooling_device,
817 817 .unbind = acpi_thermal_unbind_cooling_device,
818 818 .get_temp = thermal_get_temp,
drivers/acpi/video.c
... ... @@ -307,7 +307,7 @@
307 307 return acpi_video_device_lcd_set_level(video, level);
308 308 }
309 309  
310   -static struct thermal_cooling_device_ops video_cooling_ops = {
  310 +static const struct thermal_cooling_device_ops video_cooling_ops = {
311 311 .get_max_state = video_get_max_state,
312 312 .get_cur_state = video_get_cur_state,
313 313 .set_cur_state = video_set_cur_state,
drivers/ata/libata-acpi.c
... ... @@ -218,12 +218,12 @@
218 218 ata_acpi_uevent(dev->link->ap, dev, event);
219 219 }
220 220  
221   -static struct acpi_dock_ops ata_acpi_dev_dock_ops = {
  221 +static const struct acpi_dock_ops ata_acpi_dev_dock_ops = {
222 222 .handler = ata_acpi_dev_notify_dock,
223 223 .uevent = ata_acpi_dev_uevent,
224 224 };
225 225  
226   -static struct acpi_dock_ops ata_acpi_ap_dock_ops = {
  226 +static const struct acpi_dock_ops ata_acpi_ap_dock_ops = {
227 227 .handler = ata_acpi_ap_notify_dock,
228 228 .uevent = ata_acpi_ap_uevent,
229 229 };
drivers/pci/hotplug/acpiphp_glue.c
... ... @@ -110,7 +110,7 @@
110 110 }
111 111  
112 112  
113   -static struct acpi_dock_ops acpiphp_dock_ops = {
  113 +static const struct acpi_dock_ops acpiphp_dock_ops = {
114 114 .handler = handle_hotplug_event_func,
115 115 };
116 116  
drivers/thermal/Kconfig
... ... @@ -14,12 +14,8 @@
14 14 If you want this support, you should say Y or M here.
15 15  
16 16 config THERMAL_HWMON
17   - bool "Hardware monitoring support"
  17 + bool
18 18 depends on THERMAL
19 19 depends on HWMON=y || HWMON=THERMAL
20   - help
21   - The generic thermal sysfs driver's hardware monitoring support
22   - requires a 2.10.7/3.0.2 or later lm-sensors userspace.
23   -
24   - Say Y if your user-space is new enough.
  20 + default y
drivers/thermal/thermal_sys.c
... ... @@ -420,6 +420,29 @@
420 420  
421 421 /* hwmon sys I/F */
422 422 #include <linux/hwmon.h>
  423 +
  424 +/* thermal zone devices with the same type share one hwmon device */
  425 +struct thermal_hwmon_device {
  426 + char type[THERMAL_NAME_LENGTH];
  427 + struct device *device;
  428 + int count;
  429 + struct list_head tz_list;
  430 + struct list_head node;
  431 +};
  432 +
  433 +struct thermal_hwmon_attr {
  434 + struct device_attribute attr;
  435 + char name[16];
  436 +};
  437 +
  438 +/* one temperature input for each thermal zone */
  439 +struct thermal_hwmon_temp {
  440 + struct list_head hwmon_node;
  441 + struct thermal_zone_device *tz;
  442 + struct thermal_hwmon_attr temp_input; /* hwmon sys attr */
  443 + struct thermal_hwmon_attr temp_crit; /* hwmon sys attr */
  444 +};
  445 +
423 446 static LIST_HEAD(thermal_hwmon_list);
424 447  
425 448 static ssize_t
426 449  
... ... @@ -437,9 +460,10 @@
437 460 int ret;
438 461 struct thermal_hwmon_attr *hwmon_attr
439 462 = container_of(attr, struct thermal_hwmon_attr, attr);
440   - struct thermal_zone_device *tz
441   - = container_of(hwmon_attr, struct thermal_zone_device,
  463 + struct thermal_hwmon_temp *temp
  464 + = container_of(hwmon_attr, struct thermal_hwmon_temp,
442 465 temp_input);
  466 + struct thermal_zone_device *tz = temp->tz;
443 467  
444 468 ret = tz->ops->get_temp(tz, &temperature);
445 469  
446 470  
... ... @@ -455,9 +479,10 @@
455 479 {
456 480 struct thermal_hwmon_attr *hwmon_attr
457 481 = container_of(attr, struct thermal_hwmon_attr, attr);
458   - struct thermal_zone_device *tz
459   - = container_of(hwmon_attr, struct thermal_zone_device,
  482 + struct thermal_hwmon_temp *temp
  483 + = container_of(hwmon_attr, struct thermal_hwmon_temp,
460 484 temp_crit);
  485 + struct thermal_zone_device *tz = temp->tz;
461 486 long temperature;
462 487 int ret;
463 488  
464 489  
465 490  
466 491  
467 492  
... ... @@ -469,22 +494,54 @@
469 494 }
470 495  
471 496  
472   -static int
473   -thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
  497 +static struct thermal_hwmon_device *
  498 +thermal_hwmon_lookup_by_type(const struct thermal_zone_device *tz)
474 499 {
475 500 struct thermal_hwmon_device *hwmon;
476   - int new_hwmon_device = 1;
477   - int result;
478 501  
479 502 mutex_lock(&thermal_list_lock);
480 503 list_for_each_entry(hwmon, &thermal_hwmon_list, node)
481 504 if (!strcmp(hwmon->type, tz->type)) {
482   - new_hwmon_device = 0;
483 505 mutex_unlock(&thermal_list_lock);
484   - goto register_sys_interface;
  506 + return hwmon;
485 507 }
486 508 mutex_unlock(&thermal_list_lock);
487 509  
  510 + return NULL;
  511 +}
  512 +
  513 +/* Find the temperature input matching a given thermal zone */
  514 +static struct thermal_hwmon_temp *
  515 +thermal_hwmon_lookup_temp(const struct thermal_hwmon_device *hwmon,
  516 + const struct thermal_zone_device *tz)
  517 +{
  518 + struct thermal_hwmon_temp *temp;
  519 +
  520 + mutex_lock(&thermal_list_lock);
  521 + list_for_each_entry(temp, &hwmon->tz_list, hwmon_node)
  522 + if (temp->tz == tz) {
  523 + mutex_unlock(&thermal_list_lock);
  524 + return temp;
  525 + }
  526 + mutex_unlock(&thermal_list_lock);
  527 +
  528 + return NULL;
  529 +}
  530 +
  531 +static int
  532 +thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
  533 +{
  534 + struct thermal_hwmon_device *hwmon;
  535 + struct thermal_hwmon_temp *temp;
  536 + int new_hwmon_device = 1;
  537 + int result;
  538 +
  539 + hwmon = thermal_hwmon_lookup_by_type(tz);
  540 + if (hwmon) {
  541 + new_hwmon_device = 0;
  542 + goto register_sys_interface;
  543 + }
  544 +
488 545 hwmon = kzalloc(sizeof(struct thermal_hwmon_device), GFP_KERNEL);
489 546 if (!hwmon)
490 547 return -ENOMEM;
491 548  
492 549  
493 550  
494 551  
495 552  
496 553  
... ... @@ -502,30 +559,36 @@
502 559 goto free_mem;
503 560  
504 561 register_sys_interface:
505   - tz->hwmon = hwmon;
  562 + temp = kzalloc(sizeof(struct thermal_hwmon_temp), GFP_KERNEL);
  563 + if (!temp) {
  564 + result = -ENOMEM;
  565 + goto unregister_name;
  566 + }
  567 +
  568 + temp->tz = tz;
506 569 hwmon->count++;
507 570  
508   - snprintf(tz->temp_input.name, THERMAL_NAME_LENGTH,
  571 + snprintf(temp->temp_input.name, THERMAL_NAME_LENGTH,
509 572 "temp%d_input", hwmon->count);
510   - tz->temp_input.attr.attr.name = tz->temp_input.name;
511   - tz->temp_input.attr.attr.mode = 0444;
512   - tz->temp_input.attr.show = temp_input_show;
513   - sysfs_attr_init(&tz->temp_input.attr.attr);
514   - result = device_create_file(hwmon->device, &tz->temp_input.attr);
  573 + temp->temp_input.attr.attr.name = temp->temp_input.name;
  574 + temp->temp_input.attr.attr.mode = 0444;
  575 + temp->temp_input.attr.show = temp_input_show;
  576 + sysfs_attr_init(&temp->temp_input.attr.attr);
  577 + result = device_create_file(hwmon->device, &temp->temp_input.attr);
515 578 if (result)
516   - goto unregister_name;
  579 + goto free_temp_mem;
517 580  
518 581 if (tz->ops->get_crit_temp) {
519 582 unsigned long temperature;
520 583 if (!tz->ops->get_crit_temp(tz, &temperature)) {
521   - snprintf(tz->temp_crit.name, THERMAL_NAME_LENGTH,
  584 + snprintf(temp->temp_crit.name, THERMAL_NAME_LENGTH,
522 585 "temp%d_crit", hwmon->count);
523   - tz->temp_crit.attr.attr.name = tz->temp_crit.name;
524   - tz->temp_crit.attr.attr.mode = 0444;
525   - tz->temp_crit.attr.show = temp_crit_show;
526   - sysfs_attr_init(&tz->temp_crit.attr.attr);
  586 + temp->temp_crit.attr.attr.name = temp->temp_crit.name;
  587 + temp->temp_crit.attr.attr.mode = 0444;
  588 + temp->temp_crit.attr.show = temp_crit_show;
  589 + sysfs_attr_init(&temp->temp_crit.attr.attr);
527 590 result = device_create_file(hwmon->device,
528   - &tz->temp_crit.attr);
  591 + &temp->temp_crit.attr);
529 592 if (result)
530 593 goto unregister_input;
531 594 }
532 595  
... ... @@ -534,13 +597,15 @@
534 597 mutex_lock(&thermal_list_lock);
535 598 if (new_hwmon_device)
536 599 list_add_tail(&hwmon->node, &thermal_hwmon_list);
537   - list_add_tail(&tz->hwmon_node, &hwmon->tz_list);
  600 + list_add_tail(&temp->hwmon_node, &hwmon->tz_list);
538 601 mutex_unlock(&thermal_list_lock);
539 602  
540 603 return 0;
541 604  
542 605 unregister_input:
543   - device_remove_file(hwmon->device, &tz->temp_input.attr);
  606 + device_remove_file(hwmon->device, &temp->temp_input.attr);
  607 + free_temp_mem:
  608 + kfree(temp);
544 609 unregister_name:
545 610 if (new_hwmon_device) {
546 611 device_remove_file(hwmon->device, &dev_attr_name);
547 612  
548 613  
549 614  
... ... @@ -556,15 +621,30 @@
556 621 static void
557 622 thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
558 623 {
559   - struct thermal_hwmon_device *hwmon = tz->hwmon;
  624 + struct thermal_hwmon_device *hwmon;
  625 + struct thermal_hwmon_temp *temp;
560 626  
561   - tz->hwmon = NULL;
562   - device_remove_file(hwmon->device, &tz->temp_input.attr);
  627 + hwmon = thermal_hwmon_lookup_by_type(tz);
  628 + if (unlikely(!hwmon)) {
  629 + /* Should never happen... */
  630 + dev_dbg(&tz->device, "hwmon device lookup failed!\n");
  631 + return;
  632 + }
  633 +
  634 + temp = thermal_hwmon_lookup_temp(hwmon, tz);
  635 + if (unlikely(!temp)) {
  636 + /* Should never happen... */
  637 + dev_dbg(&tz->device, "temperature input lookup failed!\n");
  638 + return;
  639 + }
  640 +
  641 + device_remove_file(hwmon->device, &temp->temp_input.attr);
563 642 if (tz->ops->get_crit_temp)
564   - device_remove_file(hwmon->device, &tz->temp_crit.attr);
  643 + device_remove_file(hwmon->device, &temp->temp_crit.attr);
565 644  
566 645 mutex_lock(&thermal_list_lock);
567   - list_del(&tz->hwmon_node);
  646 + list_del(&temp->hwmon_node);
  647 + kfree(temp);
568 648 if (!list_empty(&hwmon->tz_list)) {
569 649 mutex_unlock(&thermal_list_lock);
570 650 return;
include/acpi/acpi_drivers.h
... ... @@ -128,7 +128,7 @@
128 128 extern int register_dock_notifier(struct notifier_block *nb);
129 129 extern void unregister_dock_notifier(struct notifier_block *nb);
130 130 extern int register_hotplug_dock_device(acpi_handle handle,
131   - struct acpi_dock_ops *ops,
  131 + const struct acpi_dock_ops *ops,
132 132 void *context);
133 133 extern void unregister_hotplug_dock_device(acpi_handle handle);
134 134 #else
include/acpi/acpixf.h
... ... @@ -47,7 +47,7 @@
47 47  
48 48 /* Current ACPICA subsystem version in YYYYMMDD format */
49 49  
50   -#define ACPI_CA_VERSION 0x20110413
  50 +#define ACPI_CA_VERSION 0x20110623
51 51  
52 52 #include "actypes.h"
53 53 #include "actbl.h"
... ... @@ -69,6 +69,7 @@
69 69 extern u32 acpi_gbl_enable_aml_debug_object;
70 70 extern u8 acpi_gbl_copy_dsdt_locally;
71 71 extern u8 acpi_gbl_truncate_io_addresses;
  72 +extern u8 acpi_gbl_disable_auto_repair;
72 73  
73 74 extern u32 acpi_current_gpe_count;
74 75 extern struct acpi_table_fadt acpi_gbl_FADT;
include/acpi/processor.h
... ... @@ -337,7 +337,7 @@
337 337  
338 338 /* in processor_thermal.c */
339 339 int acpi_processor_get_limit_info(struct acpi_processor *pr);
340   -extern struct thermal_cooling_device_ops processor_cooling_ops;
  340 +extern const struct thermal_cooling_device_ops processor_cooling_ops;
341 341 #ifdef CONFIG_CPU_FREQ
342 342 void acpi_thermal_cpufreq_init(void);
343 343 void acpi_thermal_cpufreq_exit(void);
include/linux/acpi.h
... ... @@ -238,7 +238,6 @@
238 238 extern int pnpacpi_disabled;
239 239  
240 240 #define PXM_INVAL (-1)
241   -#define NID_INVAL (-1)
242 241  
243 242 int acpi_check_resource_conflict(const struct resource *res);
244 243  
include/linux/thermal.h
... ... @@ -85,22 +85,6 @@
85 85 ((long)t-2732+5)/10 : ((long)t-2732-5)/10)
86 86 #define CELSIUS_TO_KELVIN(t) ((t)*10+2732)
87 87  
88   -#if defined(CONFIG_THERMAL_HWMON)
89   -/* thermal zone devices with the same type share one hwmon device */
90   -struct thermal_hwmon_device {
91   - char type[THERMAL_NAME_LENGTH];
92   - struct device *device;
93   - int count;
94   - struct list_head tz_list;
95   - struct list_head node;
96   -};
97   -
98   -struct thermal_hwmon_attr {
99   - struct device_attribute attr;
100   - char name[16];
101   -};
102   -#endif
103   -
104 88 struct thermal_zone_device {
105 89 int id;
106 90 char type[THERMAL_NAME_LENGTH];
... ... @@ -120,12 +104,6 @@
120 104 struct mutex lock; /* protect cooling devices list */
121 105 struct list_head node;
122 106 struct delayed_work poll_queue;
123   -#if defined(CONFIG_THERMAL_HWMON)
124   - struct list_head hwmon_node;
125   - struct thermal_hwmon_device *hwmon;
126   - struct thermal_hwmon_attr temp_input; /* hwmon sys attr */
127   - struct thermal_hwmon_attr temp_crit; /* hwmon sys attr */
128   -#endif
129 107 };
130 108 /* Adding event notification support elements */
131 109 #define THERMAL_GENL_FAMILY_NAME "thermal_event"