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:
gcc-4.6: ACPI: fix unused but set variables in ACPI
ACPI thermal: make procfs I/F depend on CONFIG_ACPI_PROCFS
ACPI video: make procfs I/F depend on CONFIG_ACPI_PROCFS
ACPI processor: remove deprecated ACPI procfs I/F
ACPI power_resource: remove unused procfs I/F
ACPI: remove deprecated ACPI procfs I/F
ACPI: introduce drivers/acpi/sysfs.c
ACPI: introduce module parameter acpi.aml_debug_output
ACPI: introduce drivers/acpi/debugfs.c
ACPI, APEI, ERST debug support
ACPI, APEI, Manage GHES as platform devices
ACPI, APEI, Rename CPER and GHES severity constants
ACPI, APEI, Fix a typo of error path of apei_resources_request
ACPI / ACPICA: Fix reference counting problems with GPE handlers
ACPI: Add the check of ADR flag in course of finding ACPI handle for PCI device
ACPI / Sleep: Drop acpi_suspend_finish()
ACPI / Sleep: Consolidate suspend and hibernation routines
ACPI / Wakeup: Simplify enabling of wakeup devices
ACPI / Sleep: Rework enabling wakeup devices
ACPI / Sleep: Free NVS copy if suspending of devices fails

Fixed up totally buggered "ACPI: fix unused but set variables in ACPI"
patch that doesn't even compile in the merge.

Thanks to Sedat Dilek <sedat.dilek@googlemail.com> for noticing the
breakage before I even pulled. And a big "Grrr.." at Len for not even
bothering to compile the tree before asking me to pull.

+1087 -1495
+2
Documentation/acpi/method-customizing.txt
··· 19 "Device", "OperationRegion", are not recognized. 20 Note: The same ACPI control method can be overridden for many times, 21 and it's always the latest one that used by Linux/kernel. 22 23 1. override an existing method 24 a) get the ACPI table via ACPI sysfs I/F. e.g. to get the DSDT,
··· 19 "Device", "OperationRegion", are not recognized. 20 Note: The same ACPI control method can be overridden for many times, 21 and it's always the latest one that used by Linux/kernel. 22 + Note: To get the ACPI debug object output (Store (AAAA, Debug)), 23 + please run "echo 1 > /sys/module/acpi/parameters/aml_debug_output". 24 25 1. override an existing method 26 a) get the ACPI table via ACPI sysfs I/F. e.g. to get the DSDT,
+2 -2
arch/x86/kernel/cpu/mcheck/mce-apei.c
··· 80 rcd.hdr.revision = CPER_RECORD_REV; 81 rcd.hdr.signature_end = CPER_SIG_END; 82 rcd.hdr.section_count = 1; 83 - rcd.hdr.error_severity = CPER_SER_FATAL; 84 /* timestamp, platform_id, partition_id are all invalid */ 85 rcd.hdr.validation_bits = 0; 86 rcd.hdr.record_length = sizeof(rcd); ··· 96 rcd.sec_hdr.validation_bits = 0; 97 rcd.sec_hdr.flags = CPER_SEC_PRIMARY; 98 rcd.sec_hdr.section_type = CPER_SECTION_TYPE_MCE; 99 - rcd.sec_hdr.section_severity = CPER_SER_FATAL; 100 101 memcpy(&rcd.mce, m, sizeof(*m)); 102
··· 80 rcd.hdr.revision = CPER_RECORD_REV; 81 rcd.hdr.signature_end = CPER_SIG_END; 82 rcd.hdr.section_count = 1; 83 + rcd.hdr.error_severity = CPER_SEV_FATAL; 84 /* timestamp, platform_id, partition_id are all invalid */ 85 rcd.hdr.validation_bits = 0; 86 rcd.hdr.record_length = sizeof(rcd); ··· 96 rcd.sec_hdr.validation_bits = 0; 97 rcd.sec_hdr.flags = CPER_SEC_PRIMARY; 98 rcd.sec_hdr.section_type = CPER_SECTION_TYPE_MCE; 99 + rcd.sec_hdr.section_severity = CPER_SEV_FATAL; 100 101 memcpy(&rcd.mce, m, sizeof(*m)); 102
+2 -9
drivers/acpi/Kconfig
··· 54 they have been replaced by functions in /sys. 55 The deprecated files (and their replacements) include: 56 57 - /proc/acpi/sleep (/sys/power/state) 58 - /proc/acpi/info (/sys/module/acpi/parameters/acpica_version) 59 - /proc/acpi/dsdt (/sys/firmware/acpi/tables/DSDT) 60 - /proc/acpi/fadt (/sys/firmware/acpi/tables/FACP) 61 - /proc/acpi/debug_layer (/sys/module/acpi/parameters/debug_layer) 62 - /proc/acpi/debug_level (/sys/module/acpi/parameters/debug_level) 63 - /proc/acpi/processor/*/power (/sys/devices/system/cpu/*/cpuidle/*) 64 - /proc/acpi/processor/*/performance (/sys/devices/system/cpu/*/ 65 - cpufreq/*) 66 /proc/acpi/processor/*/throttling (/sys/class/thermal/ 67 cooling_device*/*) 68 This option has no effect on /proc/acpi/ files 69 and functions which do not yet exist in /sys. 70
··· 54 they have been replaced by functions in /sys. 55 The deprecated files (and their replacements) include: 56 57 /proc/acpi/processor/*/throttling (/sys/class/thermal/ 58 cooling_device*/*) 59 + /proc/acpi/video/*/brightness (/sys/class/backlight/) 60 + /proc/acpi/thermal_zone/*/* (/sys/class/thermal/) 61 This option has no effect on /proc/acpi/ files 62 and functions which do not yet exist in /sys. 63
+3 -2
drivers/acpi/Makefile
··· 37 acpi-$(CONFIG_ACPI_DOCK) += dock.o 38 acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o 39 acpi-y += power.o 40 - acpi-y += system.o event.o 41 - acpi-$(CONFIG_ACPI_DEBUG) += debug.o 42 acpi-$(CONFIG_ACPI_NUMA) += numa.o 43 acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o 44 ifdef CONFIG_ACPI_VIDEO
··· 37 acpi-$(CONFIG_ACPI_DOCK) += dock.o 38 acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o 39 acpi-y += power.o 40 + acpi-y += event.o 41 + acpi-y += sysfs.o 42 + acpi-$(CONFIG_DEBUG_FS) += debugfs.o 43 acpi-$(CONFIG_ACPI_NUMA) += numa.o 44 acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o 45 ifdef CONFIG_ACPI_VIDEO
+4
drivers/acpi/acpica/acevents.h
··· 82 83 acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info); 84 85 struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, 86 u32 gpe_number); 87
··· 82 83 acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info); 84 85 + acpi_status acpi_raw_enable_gpe(struct acpi_gpe_event_info *gpe_event_info); 86 + 87 + acpi_status acpi_raw_disable_gpe(struct acpi_gpe_event_info *gpe_event_info); 88 + 89 struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, 90 u32 gpe_number); 91
+1 -1
drivers/acpi/acpica/acglobal.h
··· 108 /* 109 * Optionally enable output from the AML Debug Object. 110 */ 111 - u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE); 112 113 /* 114 * Optionally copy the entire DSDT to local memory (instead of simply
··· 108 /* 109 * Optionally enable output from the AML Debug Object. 110 */ 111 + u32 ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE); 112 113 /* 114 * Optionally copy the entire DSDT to local memory (instead of simply
+1
drivers/acpi/acpica/aclocal.h
··· 412 acpi_event_handler address; /* Address of handler, if any */ 413 void *context; /* Context to be passed to handler */ 414 struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */ 415 }; 416 417 union acpi_gpe_dispatch_info {
··· 412 acpi_event_handler address; /* Address of handler, if any */ 413 void *context; /* Context to be passed to handler */ 414 struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */ 415 + u8 orig_flags; /* Original misc info about this GPE */ 416 }; 417 418 union acpi_gpe_dispatch_info {
+73
drivers/acpi/acpica/evgpe.c
··· 137 138 /******************************************************************************* 139 * 140 * FUNCTION: acpi_ev_low_get_gpe_info 141 * 142 * PARAMETERS: gpe_number - Raw GPE number
··· 137 138 /******************************************************************************* 139 * 140 + * FUNCTION: acpi_raw_enable_gpe 141 + * 142 + * PARAMETERS: gpe_event_info - GPE to enable 143 + * 144 + * RETURN: Status 145 + * 146 + * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is 147 + * hardware-enabled. 148 + * 149 + ******************************************************************************/ 150 + 151 + acpi_status acpi_raw_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) 152 + { 153 + acpi_status status = AE_OK; 154 + 155 + if (gpe_event_info->runtime_count == ACPI_UINT8_MAX) { 156 + return_ACPI_STATUS(AE_LIMIT); 157 + } 158 + 159 + gpe_event_info->runtime_count++; 160 + if (gpe_event_info->runtime_count == 1) { 161 + status = acpi_ev_update_gpe_enable_mask(gpe_event_info); 162 + if (ACPI_SUCCESS(status)) { 163 + status = acpi_ev_enable_gpe(gpe_event_info); 164 + } 165 + 166 + if (ACPI_FAILURE(status)) { 167 + gpe_event_info->runtime_count--; 168 + } 169 + } 170 + 171 + return_ACPI_STATUS(status); 172 + } 173 + 174 + /******************************************************************************* 175 + * 176 + * FUNCTION: acpi_raw_disable_gpe 177 + * 178 + * PARAMETERS: gpe_event_info - GPE to disable 179 + * 180 + * RETURN: Status 181 + * 182 + * DESCRIPTION: Remove a reference to a GPE. When the last reference is 183 + * removed, the GPE is hardware-disabled. 184 + * 185 + ******************************************************************************/ 186 + 187 + acpi_status acpi_raw_disable_gpe(struct acpi_gpe_event_info *gpe_event_info) 188 + { 189 + acpi_status status = AE_OK; 190 + 191 + if (!gpe_event_info->runtime_count) { 192 + return_ACPI_STATUS(AE_LIMIT); 193 + } 194 + 195 + gpe_event_info->runtime_count--; 196 + if (!gpe_event_info->runtime_count) { 197 + status = acpi_ev_update_gpe_enable_mask(gpe_event_info); 198 + if (ACPI_SUCCESS(status)) { 199 + status = acpi_hw_low_set_gpe(gpe_event_info, 200 + ACPI_GPE_DISABLE); 201 + } 202 + 203 + if (ACPI_FAILURE(status)) { 204 + gpe_event_info->runtime_count++; 205 + } 206 + } 207 + 208 + return_ACPI_STATUS(status); 209 + } 210 + 211 + /******************************************************************************* 212 + * 213 * FUNCTION: acpi_ev_low_get_gpe_info 214 * 215 * PARAMETERS: gpe_number - Raw GPE number
+61 -34
drivers/acpi/acpica/evxface.c
··· 691 return_ACPI_STATUS(status); 692 } 693 694 - /* Ensure that we have a valid GPE number */ 695 - 696 - gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 697 - if (!gpe_event_info) { 698 - status = AE_BAD_PARAMETER; 699 - goto unlock_and_exit; 700 - } 701 - 702 - /* Make sure that there isn't a handler there already */ 703 - 704 - if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == 705 - ACPI_GPE_DISPATCH_HANDLER) { 706 - status = AE_ALREADY_EXISTS; 707 - goto unlock_and_exit; 708 - } 709 - 710 - /* Allocate and init handler object */ 711 712 handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info)); 713 if (!handler) { ··· 699 goto unlock_and_exit; 700 } 701 702 handler->address = address; 703 handler->context = context; 704 handler->method_node = gpe_event_info->dispatch.method_node; 705 706 /* Install the handler */ 707 708 - flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 709 gpe_event_info->dispatch.handler = handler; 710 711 /* Setup up dispatch flags to indicate handler (vs. method) */ ··· 751 unlock_and_exit: 752 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 753 return_ACPI_STATUS(status); 754 } 755 756 ACPI_EXPORT_SYMBOL(acpi_install_gpe_handler) ··· 791 return_ACPI_STATUS(AE_BAD_PARAMETER); 792 } 793 794 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 795 if (ACPI_FAILURE(status)) { 796 return_ACPI_STATUS(status); 797 } 798 799 /* Ensure that we have a valid GPE number */ 800 ··· 825 goto unlock_and_exit; 826 } 827 828 - /* Make sure all deferred tasks are completed */ 829 - 830 - (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 831 - acpi_os_wait_events_complete(NULL); 832 - status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 833 - if (ACPI_FAILURE(status)) { 834 - return_ACPI_STATUS(status); 835 - } 836 - 837 /* Remove the handler */ 838 839 - flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 840 handler = gpe_event_info->dispatch.handler; 841 842 /* Restore Method node (if any), set dispatch flags */ 843 844 gpe_event_info->dispatch.method_node = handler->method_node; 845 - gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */ 846 - if (handler->method_node) { 847 - gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD; 848 - } 849 - acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 850 851 /* Now we can free the handler object */ 852 853 ACPI_FREE(handler); 854 855 - unlock_and_exit: 856 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 857 return_ACPI_STATUS(status); 858 }
··· 691 return_ACPI_STATUS(status); 692 } 693 694 + /* Allocate memory for the handler object */ 695 696 handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info)); 697 if (!handler) { ··· 715 goto unlock_and_exit; 716 } 717 718 + flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 719 + 720 + /* Ensure that we have a valid GPE number */ 721 + 722 + gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 723 + if (!gpe_event_info) { 724 + status = AE_BAD_PARAMETER; 725 + goto free_and_exit; 726 + } 727 + 728 + /* Make sure that there isn't a handler there already */ 729 + 730 + if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == 731 + ACPI_GPE_DISPATCH_HANDLER) { 732 + status = AE_ALREADY_EXISTS; 733 + goto free_and_exit; 734 + } 735 + 736 + /* Allocate and init handler object */ 737 + 738 handler->address = address; 739 handler->context = context; 740 handler->method_node = gpe_event_info->dispatch.method_node; 741 + handler->orig_flags = gpe_event_info->flags & 742 + (ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); 743 + 744 + /* 745 + * If the GPE is associated with a method and it cannot wake up the 746 + * system from sleep states, it was enabled automatically during 747 + * initialization, so it has to be disabled now to avoid spurious 748 + * execution of the handler. 749 + */ 750 + 751 + if ((handler->orig_flags & ACPI_GPE_DISPATCH_METHOD) 752 + && !(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) 753 + (void)acpi_raw_disable_gpe(gpe_event_info); 754 755 /* Install the handler */ 756 757 gpe_event_info->dispatch.handler = handler; 758 759 /* Setup up dispatch flags to indicate handler (vs. method) */ ··· 735 unlock_and_exit: 736 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 737 return_ACPI_STATUS(status); 738 + 739 + free_and_exit: 740 + acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 741 + ACPI_FREE(handler); 742 + goto unlock_and_exit; 743 } 744 745 ACPI_EXPORT_SYMBOL(acpi_install_gpe_handler) ··· 770 return_ACPI_STATUS(AE_BAD_PARAMETER); 771 } 772 773 + /* Make sure all deferred tasks are completed */ 774 + 775 + acpi_os_wait_events_complete(NULL); 776 + 777 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 778 if (ACPI_FAILURE(status)) { 779 return_ACPI_STATUS(status); 780 } 781 + 782 + flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 783 784 /* Ensure that we have a valid GPE number */ 785 ··· 798 goto unlock_and_exit; 799 } 800 801 /* Remove the handler */ 802 803 handler = gpe_event_info->dispatch.handler; 804 805 /* Restore Method node (if any), set dispatch flags */ 806 807 gpe_event_info->dispatch.method_node = handler->method_node; 808 + gpe_event_info->flags &= 809 + ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); 810 + gpe_event_info->flags |= handler->orig_flags; 811 + 812 + /* 813 + * If the GPE was previously associated with a method and it cannot wake 814 + * up the system from sleep states, it should be enabled at this point 815 + * to restore the post-initialization configuration. 816 + */ 817 + 818 + if ((handler->orig_flags & ACPI_GPE_DISPATCH_METHOD) 819 + && !(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) 820 + (void)acpi_raw_enable_gpe(gpe_event_info); 821 822 /* Now we can free the handler object */ 823 824 ACPI_FREE(handler); 825 826 + unlock_and_exit: 827 + acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 828 + 829 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 830 return_ACPI_STATUS(status); 831 }
+9 -53
drivers/acpi/acpica/evxfevnt.c
··· 294 ******************************************************************************/ 295 acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number) 296 { 297 - acpi_status status = AE_OK; 298 struct acpi_gpe_event_info *gpe_event_info; 299 acpi_cpu_flags flags; 300 ··· 305 /* Ensure that we have a valid GPE number */ 306 307 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 308 - if (!gpe_event_info) { 309 - status = AE_BAD_PARAMETER; 310 - goto unlock_and_exit; 311 } 312 313 - if (gpe_event_info->runtime_count == ACPI_UINT8_MAX) { 314 - status = AE_LIMIT; /* Too many references */ 315 - goto unlock_and_exit; 316 - } 317 - 318 - gpe_event_info->runtime_count++; 319 - if (gpe_event_info->runtime_count == 1) { 320 - status = acpi_ev_update_gpe_enable_mask(gpe_event_info); 321 - if (ACPI_SUCCESS(status)) { 322 - status = acpi_ev_enable_gpe(gpe_event_info); 323 - } 324 - if (ACPI_FAILURE(status)) { 325 - gpe_event_info->runtime_count--; 326 - } 327 - } 328 - 329 - unlock_and_exit: 330 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 331 return_ACPI_STATUS(status); 332 } ··· 330 ******************************************************************************/ 331 acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number) 332 { 333 - acpi_status status = AE_OK; 334 struct acpi_gpe_event_info *gpe_event_info; 335 acpi_cpu_flags flags; 336 ··· 341 /* Ensure that we have a valid GPE number */ 342 343 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 344 - if (!gpe_event_info) { 345 - status = AE_BAD_PARAMETER; 346 - goto unlock_and_exit; 347 } 348 349 - /* Hardware-disable a runtime GPE on removal of the last reference */ 350 - 351 - if (!gpe_event_info->runtime_count) { 352 - status = AE_LIMIT; /* There are no references to remove */ 353 - goto unlock_and_exit; 354 - } 355 - 356 - gpe_event_info->runtime_count--; 357 - if (!gpe_event_info->runtime_count) { 358 - status = acpi_ev_update_gpe_enable_mask(gpe_event_info); 359 - if (ACPI_SUCCESS(status)) { 360 - status = 361 - acpi_hw_low_set_gpe(gpe_event_info, 362 - ACPI_GPE_DISABLE); 363 - } 364 - if (ACPI_FAILURE(status)) { 365 - gpe_event_info->runtime_count++; 366 - } 367 - } 368 - 369 - unlock_and_exit: 370 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 371 return_ACPI_STATUS(status); 372 } ··· 371 acpi_status status = AE_OK; 372 struct acpi_gpe_event_info *gpe_event_info; 373 acpi_cpu_flags flags; 374 - u8 disable = 0; 375 376 ACPI_FUNCTION_TRACE(acpi_gpe_can_wake); 377 ··· 389 } 390 391 gpe_event_info->flags |= ACPI_GPE_CAN_WAKE; 392 - disable = (gpe_event_info->flags & ACPI_GPE_DISPATCH_METHOD) 393 - && gpe_event_info->runtime_count; 394 395 unlock_and_exit: 396 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 397 - 398 - if (disable) 399 - status = acpi_disable_gpe(gpe_device, gpe_number); 400 - 401 return_ACPI_STATUS(status); 402 } 403 ACPI_EXPORT_SYMBOL(acpi_gpe_can_wake)
··· 294 ******************************************************************************/ 295 acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number) 296 { 297 + acpi_status status = AE_BAD_PARAMETER; 298 struct acpi_gpe_event_info *gpe_event_info; 299 acpi_cpu_flags flags; 300 ··· 305 /* Ensure that we have a valid GPE number */ 306 307 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 308 + if (gpe_event_info) { 309 + status = acpi_raw_enable_gpe(gpe_event_info); 310 } 311 312 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 313 return_ACPI_STATUS(status); 314 } ··· 348 ******************************************************************************/ 349 acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number) 350 { 351 + acpi_status status = AE_BAD_PARAMETER; 352 struct acpi_gpe_event_info *gpe_event_info; 353 acpi_cpu_flags flags; 354 ··· 359 /* Ensure that we have a valid GPE number */ 360 361 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 362 + if (gpe_event_info) { 363 + status = acpi_raw_disable_gpe(gpe_event_info) ; 364 } 365 366 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 367 return_ACPI_STATUS(status); 368 } ··· 411 acpi_status status = AE_OK; 412 struct acpi_gpe_event_info *gpe_event_info; 413 acpi_cpu_flags flags; 414 415 ACPI_FUNCTION_TRACE(acpi_gpe_can_wake); 416 ··· 430 } 431 432 gpe_event_info->flags |= ACPI_GPE_CAN_WAKE; 433 + if (gpe_event_info->flags & ACPI_GPE_DISPATCH_METHOD) { 434 + (void)acpi_raw_disable_gpe(gpe_event_info); 435 + } 436 437 unlock_and_exit: 438 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 439 return_ACPI_STATUS(status); 440 } 441 ACPI_EXPORT_SYMBOL(acpi_gpe_can_wake)
+1 -4
drivers/acpi/acpica/utmutex.c
··· 279 280 acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) 281 { 282 - acpi_thread_id this_thread_id; 283 - 284 ACPI_FUNCTION_NAME(ut_release_mutex); 285 286 - this_thread_id = acpi_os_get_thread_id(); 287 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Thread %p releasing Mutex [%s]\n", 288 - ACPI_CAST_PTR(void, this_thread_id), 289 acpi_ut_get_mutex_name(mutex_id))); 290 291 if (mutex_id > ACPI_MAX_MUTEX) {
··· 279 280 acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) 281 { 282 ACPI_FUNCTION_NAME(ut_release_mutex); 283 284 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Thread %p releasing Mutex [%s]\n", 285 + ACPI_CAST_PTR(void, acpi_os_get_thread_id()), 286 acpi_ut_get_mutex_name(mutex_id))); 287 288 if (mutex_id > ACPI_MAX_MUTEX) {
+9
drivers/acpi/apei/Kconfig
··· 28 EINJ provides a hardware error injection mechanism, it is 29 mainly used for debugging and testing the other parts of 30 APEI and some other RAS features.
··· 28 EINJ provides a hardware error injection mechanism, it is 29 mainly used for debugging and testing the other parts of 30 APEI and some other RAS features. 31 + 32 + config ACPI_APEI_ERST_DEBUG 33 + tristate "APEI Error Record Serialization Table (ERST) Debug Support" 34 + depends on ACPI_APEI 35 + help 36 + ERST is a way provided by APEI to save and retrieve hardware 37 + error infomation to and from a persistent store. Enable this 38 + if you want to debugging and testing the ERST kernel support 39 + and firmware implementation.
+1
drivers/acpi/apei/Makefile
··· 1 obj-$(CONFIG_ACPI_APEI) += apei.o 2 obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o 3 obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o 4 5 apei-y := apei-base.o hest.o cper.o erst.o
··· 1 obj-$(CONFIG_ACPI_APEI) += apei.o 2 obj-$(CONFIG_ACPI_APEI_GHES) += ghes.o 3 obj-$(CONFIG_ACPI_APEI_EINJ) += einj.o 4 + obj-$(CONFIG_ACPI_APEI_ERST_DEBUG) += erst-dbg.o 5 6 apei-y := apei-base.o hest.o cper.o erst.o
+2 -2
drivers/acpi/apei/apei-base.c
··· 482 list_for_each_entry(res, &resources->ioport, list) { 483 if (res == res_bak) 484 break; 485 - release_mem_region(res->start, res->end - res->start); 486 } 487 res_bak = NULL; 488 err_unmap_iomem: 489 list_for_each_entry(res, &resources->iomem, list) { 490 if (res == res_bak) 491 break; 492 - release_region(res->start, res->end - res->start); 493 } 494 return -EINVAL; 495 }
··· 482 list_for_each_entry(res, &resources->ioport, list) { 483 if (res == res_bak) 484 break; 485 + release_region(res->start, res->end - res->start); 486 } 487 res_bak = NULL; 488 err_unmap_iomem: 489 list_for_each_entry(res, &resources->iomem, list) { 490 if (res == res_bak) 491 break; 492 + release_mem_region(res->start, res->end - res->start); 493 } 494 return -EINVAL; 495 }
+207
drivers/acpi/apei/erst-dbg.c
···
··· 1 + /* 2 + * APEI Error Record Serialization Table debug support 3 + * 4 + * ERST is a way provided by APEI to save and retrieve hardware error 5 + * infomation to and from a persistent store. This file provide the 6 + * debugging/testing support for ERST kernel support and firmware 7 + * implementation. 8 + * 9 + * Copyright 2010 Intel Corp. 10 + * Author: Huang Ying <ying.huang@intel.com> 11 + * 12 + * This program is free software; you can redistribute it and/or 13 + * modify it under the terms of the GNU General Public License version 14 + * 2 as published by the Free Software Foundation. 15 + * 16 + * This program is distributed in the hope that it will be useful, 17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 + * GNU General Public License for more details. 20 + * 21 + * You should have received a copy of the GNU General Public License 22 + * along with this program; if not, write to the Free Software 23 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 + */ 25 + 26 + #include <linux/kernel.h> 27 + #include <linux/module.h> 28 + #include <linux/uaccess.h> 29 + #include <acpi/apei.h> 30 + #include <linux/miscdevice.h> 31 + 32 + #include "apei-internal.h" 33 + 34 + #define ERST_DBG_PFX "ERST DBG: " 35 + 36 + #define ERST_DBG_RECORD_LEN_MAX 4096 37 + 38 + static void *erst_dbg_buf; 39 + static unsigned int erst_dbg_buf_len; 40 + 41 + /* Prevent erst_dbg_read/write from being invoked concurrently */ 42 + static DEFINE_MUTEX(erst_dbg_mutex); 43 + 44 + static int erst_dbg_open(struct inode *inode, struct file *file) 45 + { 46 + if (erst_disable) 47 + return -ENODEV; 48 + 49 + return nonseekable_open(inode, file); 50 + } 51 + 52 + static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg) 53 + { 54 + int rc; 55 + u64 record_id; 56 + u32 record_count; 57 + 58 + switch (cmd) { 59 + case APEI_ERST_CLEAR_RECORD: 60 + rc = copy_from_user(&record_id, (void __user *)arg, 61 + sizeof(record_id)); 62 + if (rc) 63 + return -EFAULT; 64 + return erst_clear(record_id); 65 + case APEI_ERST_GET_RECORD_COUNT: 66 + rc = erst_get_record_count(); 67 + if (rc < 0) 68 + return rc; 69 + record_count = rc; 70 + rc = put_user(record_count, (u32 __user *)arg); 71 + if (rc) 72 + return rc; 73 + return 0; 74 + default: 75 + return -ENOTTY; 76 + } 77 + } 78 + 79 + static ssize_t erst_dbg_read(struct file *filp, char __user *ubuf, 80 + size_t usize, loff_t *off) 81 + { 82 + int rc; 83 + ssize_t len = 0; 84 + u64 id; 85 + 86 + if (*off != 0) 87 + return -EINVAL; 88 + 89 + if (mutex_lock_interruptible(&erst_dbg_mutex) != 0) 90 + return -EINTR; 91 + 92 + retry_next: 93 + rc = erst_get_next_record_id(&id); 94 + if (rc) 95 + goto out; 96 + /* no more record */ 97 + if (id == APEI_ERST_INVALID_RECORD_ID) 98 + goto out; 99 + retry: 100 + rc = len = erst_read(id, erst_dbg_buf, erst_dbg_buf_len); 101 + /* The record may be cleared by others, try read next record */ 102 + if (rc == -ENOENT) 103 + goto retry_next; 104 + if (rc < 0) 105 + goto out; 106 + if (len > ERST_DBG_RECORD_LEN_MAX) { 107 + pr_warning(ERST_DBG_PFX 108 + "Record (ID: 0x%llx) length is too long: %zd\n", 109 + id, len); 110 + rc = -EIO; 111 + goto out; 112 + } 113 + if (len > erst_dbg_buf_len) { 114 + kfree(erst_dbg_buf); 115 + rc = -ENOMEM; 116 + erst_dbg_buf = kmalloc(len, GFP_KERNEL); 117 + if (!erst_dbg_buf) 118 + goto out; 119 + erst_dbg_buf_len = len; 120 + goto retry; 121 + } 122 + 123 + rc = -EINVAL; 124 + if (len > usize) 125 + goto out; 126 + 127 + rc = -EFAULT; 128 + if (copy_to_user(ubuf, erst_dbg_buf, len)) 129 + goto out; 130 + rc = 0; 131 + out: 132 + mutex_unlock(&erst_dbg_mutex); 133 + return rc ? rc : len; 134 + } 135 + 136 + static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf, 137 + size_t usize, loff_t *off) 138 + { 139 + int rc; 140 + struct cper_record_header *rcd; 141 + 142 + if (!capable(CAP_SYS_ADMIN)) 143 + return -EPERM; 144 + 145 + if (usize > ERST_DBG_RECORD_LEN_MAX) { 146 + pr_err(ERST_DBG_PFX "Too long record to be written\n"); 147 + return -EINVAL; 148 + } 149 + 150 + if (mutex_lock_interruptible(&erst_dbg_mutex)) 151 + return -EINTR; 152 + if (usize > erst_dbg_buf_len) { 153 + kfree(erst_dbg_buf); 154 + rc = -ENOMEM; 155 + erst_dbg_buf = kmalloc(usize, GFP_KERNEL); 156 + if (!erst_dbg_buf) 157 + goto out; 158 + erst_dbg_buf_len = usize; 159 + } 160 + rc = copy_from_user(erst_dbg_buf, ubuf, usize); 161 + if (rc) { 162 + rc = -EFAULT; 163 + goto out; 164 + } 165 + rcd = erst_dbg_buf; 166 + rc = -EINVAL; 167 + if (rcd->record_length != usize) 168 + goto out; 169 + 170 + rc = erst_write(erst_dbg_buf); 171 + 172 + out: 173 + mutex_unlock(&erst_dbg_mutex); 174 + return rc < 0 ? rc : usize; 175 + } 176 + 177 + static const struct file_operations erst_dbg_ops = { 178 + .owner = THIS_MODULE, 179 + .open = erst_dbg_open, 180 + .read = erst_dbg_read, 181 + .write = erst_dbg_write, 182 + .unlocked_ioctl = erst_dbg_ioctl, 183 + }; 184 + 185 + static struct miscdevice erst_dbg_dev = { 186 + .minor = MISC_DYNAMIC_MINOR, 187 + .name = "erst_dbg", 188 + .fops = &erst_dbg_ops, 189 + }; 190 + 191 + static __init int erst_dbg_init(void) 192 + { 193 + return misc_register(&erst_dbg_dev); 194 + } 195 + 196 + static __exit void erst_dbg_exit(void) 197 + { 198 + misc_deregister(&erst_dbg_dev); 199 + kfree(erst_dbg_buf); 200 + } 201 + 202 + module_init(erst_dbg_init); 203 + module_exit(erst_dbg_exit); 204 + 205 + MODULE_AUTHOR("Huang Ying"); 206 + MODULE_DESCRIPTION("APEI Error Record Serialization Table debug support"); 207 + MODULE_LICENSE("GPL");
+97 -87
drivers/acpi/apei/ghes.c
··· 41 #include <linux/interrupt.h> 42 #include <linux/cper.h> 43 #include <linux/kdebug.h> 44 #include <acpi/apei.h> 45 #include <acpi/atomicio.h> 46 #include <acpi/hed.h> ··· 89 * used for that. 90 */ 91 static LIST_HEAD(ghes_sci); 92 93 static struct ghes *ghes_new(struct acpi_hest_generic *generic) 94 { ··· 135 } 136 137 enum { 138 - GHES_SER_NO = 0x0, 139 - GHES_SER_CORRECTED = 0x1, 140 - GHES_SER_RECOVERABLE = 0x2, 141 - GHES_SER_PANIC = 0x3, 142 }; 143 144 static inline int ghes_severity(int severity) 145 { 146 switch (severity) { 147 - case CPER_SER_INFORMATIONAL: 148 - return GHES_SER_NO; 149 - case CPER_SER_CORRECTED: 150 - return GHES_SER_CORRECTED; 151 - case CPER_SER_RECOVERABLE: 152 - return GHES_SER_RECOVERABLE; 153 - case CPER_SER_FATAL: 154 - return GHES_SER_PANIC; 155 default: 156 /* Unkown, go panic */ 157 - return GHES_SER_PANIC; 158 } 159 } 160 ··· 240 241 static void ghes_do_proc(struct ghes *ghes) 242 { 243 - int ser, processed = 0; 244 struct acpi_hest_generic_data *gdata; 245 246 - ser = ghes_severity(ghes->estatus->error_severity); 247 apei_estatus_for_each_section(ghes->estatus, gdata) { 248 #ifdef CONFIG_X86_MCE 249 if (!uuid_le_cmp(*(uuid_le *)gdata->section_type, 250 CPER_SEC_PLATFORM_MEM)) { 251 apei_mce_report_mem_error( 252 - ser == GHES_SER_CORRECTED, 253 (struct cper_sec_mem_err *)(gdata+1)); 254 processed = 1; 255 } ··· 296 .notifier_call = ghes_notify_sci, 297 }; 298 299 - static int hest_ghes_parse(struct acpi_hest_header *hest_hdr, void *data) 300 { 301 struct acpi_hest_generic *generic; 302 struct ghes *ghes = NULL; 303 - int rc = 0; 304 305 - if (hest_hdr->type != ACPI_HEST_TYPE_GENERIC_ERROR) 306 - return 0; 307 - 308 - generic = (struct acpi_hest_generic *)hest_hdr; 309 if (!generic->enabled) 310 - return 0; 311 312 if (generic->error_block_length < 313 sizeof(struct acpi_hest_generic_status)) { ··· 327 ghes = NULL; 328 goto err; 329 } 330 - switch (generic->notify.type) { 331 - case ACPI_HEST_NOTIFY_POLLED: 332 - pr_warning(GHES_PFX 333 - "Generic hardware error source: %d notified via POLL is not supported!\n", 334 - generic->header.source_id); 335 - break; 336 - case ACPI_HEST_NOTIFY_EXTERNAL: 337 - case ACPI_HEST_NOTIFY_LOCAL: 338 - pr_warning(GHES_PFX 339 - "Generic hardware error source: %d notified via IRQ is not supported!\n", 340 - generic->header.source_id); 341 - break; 342 - case ACPI_HEST_NOTIFY_SCI: 343 if (list_empty(&ghes_sci)) 344 register_acpi_hed_notifier(&ghes_notifier_sci); 345 list_add_rcu(&ghes->list, &ghes_sci); 346 - break; 347 - case ACPI_HEST_NOTIFY_NMI: 348 - pr_warning(GHES_PFX 349 - "Generic hardware error source: %d notified via NMI is not supported!\n", 350 - generic->header.source_id); 351 - break; 352 - default: 353 - pr_warning(FW_WARN GHES_PFX 354 - "Unknown notification type: %u for generic hardware error source: %d\n", 355 - generic->notify.type, generic->header.source_id); 356 - break; 357 } 358 359 return 0; 360 err: 361 - if (ghes) 362 - ghes_fini(ghes); 363 - return rc; 364 - } 365 - 366 - static void ghes_cleanup(void) 367 - { 368 - struct ghes *ghes, *nghes; 369 - 370 - if (!list_empty(&ghes_sci)) 371 - unregister_acpi_hed_notifier(&ghes_notifier_sci); 372 - 373 - synchronize_rcu(); 374 - 375 - list_for_each_entry_safe(ghes, nghes, &ghes_sci, list) { 376 - list_del(&ghes->list); 377 ghes_fini(ghes); 378 kfree(ghes); 379 } 380 } 381 382 static int __init ghes_init(void) 383 { 384 - int rc; 385 - 386 if (acpi_disabled) 387 return -ENODEV; 388 ··· 420 return -EINVAL; 421 } 422 423 - rc = apei_hest_parse(hest_ghes_parse, NULL); 424 - if (rc) { 425 - pr_err(GHES_PFX 426 - "Error during parsing HEST generic hardware error sources.\n"); 427 - goto err_cleanup; 428 - } 429 - 430 - if (list_empty(&ghes_sci)) { 431 - pr_info(GHES_PFX 432 - "No functional generic hardware error sources.\n"); 433 - rc = -ENODEV; 434 - goto err_cleanup; 435 - } 436 - 437 - pr_info(GHES_PFX 438 - "Generic Hardware Error Source support is initialized.\n"); 439 - 440 - return 0; 441 - err_cleanup: 442 - ghes_cleanup(); 443 - return rc; 444 } 445 446 static void __exit ghes_exit(void) 447 { 448 - ghes_cleanup(); 449 } 450 451 module_init(ghes_init); ··· 434 MODULE_AUTHOR("Huang Ying"); 435 MODULE_DESCRIPTION("APEI Generic Hardware Error Source support"); 436 MODULE_LICENSE("GPL");
··· 41 #include <linux/interrupt.h> 42 #include <linux/cper.h> 43 #include <linux/kdebug.h> 44 + #include <linux/platform_device.h> 45 + #include <linux/mutex.h> 46 #include <acpi/apei.h> 47 #include <acpi/atomicio.h> 48 #include <acpi/hed.h> ··· 87 * used for that. 88 */ 89 static LIST_HEAD(ghes_sci); 90 + static DEFINE_MUTEX(ghes_list_mutex); 91 92 static struct ghes *ghes_new(struct acpi_hest_generic *generic) 93 { ··· 132 } 133 134 enum { 135 + GHES_SEV_NO = 0x0, 136 + GHES_SEV_CORRECTED = 0x1, 137 + GHES_SEV_RECOVERABLE = 0x2, 138 + GHES_SEV_PANIC = 0x3, 139 }; 140 141 static inline int ghes_severity(int severity) 142 { 143 switch (severity) { 144 + case CPER_SEV_INFORMATIONAL: 145 + return GHES_SEV_NO; 146 + case CPER_SEV_CORRECTED: 147 + return GHES_SEV_CORRECTED; 148 + case CPER_SEV_RECOVERABLE: 149 + return GHES_SEV_RECOVERABLE; 150 + case CPER_SEV_FATAL: 151 + return GHES_SEV_PANIC; 152 default: 153 /* Unkown, go panic */ 154 + return GHES_SEV_PANIC; 155 } 156 } 157 ··· 237 238 static void ghes_do_proc(struct ghes *ghes) 239 { 240 + int sev, processed = 0; 241 struct acpi_hest_generic_data *gdata; 242 243 + sev = ghes_severity(ghes->estatus->error_severity); 244 apei_estatus_for_each_section(ghes->estatus, gdata) { 245 #ifdef CONFIG_X86_MCE 246 if (!uuid_le_cmp(*(uuid_le *)gdata->section_type, 247 CPER_SEC_PLATFORM_MEM)) { 248 apei_mce_report_mem_error( 249 + sev == GHES_SEV_CORRECTED, 250 (struct cper_sec_mem_err *)(gdata+1)); 251 processed = 1; 252 } ··· 293 .notifier_call = ghes_notify_sci, 294 }; 295 296 + static int __devinit ghes_probe(struct platform_device *ghes_dev) 297 { 298 struct acpi_hest_generic *generic; 299 struct ghes *ghes = NULL; 300 + int rc = -EINVAL; 301 302 + generic = ghes_dev->dev.platform_data; 303 if (!generic->enabled) 304 + return -ENODEV; 305 306 if (generic->error_block_length < 307 sizeof(struct acpi_hest_generic_status)) { ··· 327 ghes = NULL; 328 goto err; 329 } 330 + if (generic->notify.type == ACPI_HEST_NOTIFY_SCI) { 331 + mutex_lock(&ghes_list_mutex); 332 if (list_empty(&ghes_sci)) 333 register_acpi_hed_notifier(&ghes_notifier_sci); 334 list_add_rcu(&ghes->list, &ghes_sci); 335 + mutex_unlock(&ghes_list_mutex); 336 + } else { 337 + unsigned char *notify = NULL; 338 + 339 + switch (generic->notify.type) { 340 + case ACPI_HEST_NOTIFY_POLLED: 341 + notify = "POLL"; 342 + break; 343 + case ACPI_HEST_NOTIFY_EXTERNAL: 344 + case ACPI_HEST_NOTIFY_LOCAL: 345 + notify = "IRQ"; 346 + break; 347 + case ACPI_HEST_NOTIFY_NMI: 348 + notify = "NMI"; 349 + break; 350 + } 351 + if (notify) { 352 + pr_warning(GHES_PFX 353 + "Generic hardware error source: %d notified via %s is not supported!\n", 354 + generic->header.source_id, notify); 355 + } else { 356 + pr_warning(FW_WARN GHES_PFX 357 + "Unknown notification type: %u for generic hardware error source: %d\n", 358 + generic->notify.type, generic->header.source_id); 359 + } 360 + rc = -ENODEV; 361 + goto err; 362 } 363 + platform_set_drvdata(ghes_dev, ghes); 364 365 return 0; 366 err: 367 + if (ghes) { 368 ghes_fini(ghes); 369 kfree(ghes); 370 } 371 + return rc; 372 } 373 + 374 + static int __devexit ghes_remove(struct platform_device *ghes_dev) 375 + { 376 + struct ghes *ghes; 377 + struct acpi_hest_generic *generic; 378 + 379 + ghes = platform_get_drvdata(ghes_dev); 380 + generic = ghes->generic; 381 + 382 + switch (generic->notify.type) { 383 + case ACPI_HEST_NOTIFY_SCI: 384 + mutex_lock(&ghes_list_mutex); 385 + list_del_rcu(&ghes->list); 386 + if (list_empty(&ghes_sci)) 387 + unregister_acpi_hed_notifier(&ghes_notifier_sci); 388 + mutex_unlock(&ghes_list_mutex); 389 + break; 390 + default: 391 + BUG(); 392 + break; 393 + } 394 + 395 + synchronize_rcu(); 396 + ghes_fini(ghes); 397 + kfree(ghes); 398 + 399 + platform_set_drvdata(ghes_dev, NULL); 400 + 401 + return 0; 402 + } 403 + 404 + static struct platform_driver ghes_platform_driver = { 405 + .driver = { 406 + .name = "GHES", 407 + .owner = THIS_MODULE, 408 + }, 409 + .probe = ghes_probe, 410 + .remove = ghes_remove, 411 + }; 412 413 static int __init ghes_init(void) 414 { 415 if (acpi_disabled) 416 return -ENODEV; 417 ··· 391 return -EINVAL; 392 } 393 394 + return platform_driver_register(&ghes_platform_driver); 395 } 396 397 static void __exit ghes_exit(void) 398 { 399 + platform_driver_unregister(&ghes_platform_driver); 400 } 401 402 module_init(ghes_init); ··· 425 MODULE_AUTHOR("Huang Ying"); 426 MODULE_DESCRIPTION("APEI Generic Hardware Error Source support"); 427 MODULE_LICENSE("GPL"); 428 + MODULE_ALIAS("platform:GHES");
+70 -6
drivers/acpi/apei/hest.c
··· 34 #include <linux/kdebug.h> 35 #include <linux/highmem.h> 36 #include <linux/io.h> 37 #include <acpi/apei.h> 38 39 #include "apei-internal.h" ··· 47 /* HEST table parsing */ 48 49 static struct acpi_table_hest *hest_tab; 50 - 51 - static int hest_void_parse(struct acpi_hest_header *hest_hdr, void *data) 52 - { 53 - return 0; 54 - } 55 56 static int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = { 57 [ACPI_HEST_TYPE_IA32_CHECK] = -1, /* need further calculation */ ··· 121 } 122 EXPORT_SYMBOL_GPL(apei_hest_parse); 123 124 static int __init setup_hest_disable(char *str) 125 { 126 hest_disable = 1; ··· 196 { 197 acpi_status status; 198 int rc = -ENODEV; 199 200 if (acpi_disabled) 201 goto err; ··· 218 goto err; 219 } 220 221 - rc = apei_hest_parse(hest_void_parse, NULL); 222 if (rc) 223 goto err; 224
··· 34 #include <linux/kdebug.h> 35 #include <linux/highmem.h> 36 #include <linux/io.h> 37 + #include <linux/platform_device.h> 38 #include <acpi/apei.h> 39 40 #include "apei-internal.h" ··· 46 /* HEST table parsing */ 47 48 static struct acpi_table_hest *hest_tab; 49 50 static int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = { 51 [ACPI_HEST_TYPE_IA32_CHECK] = -1, /* need further calculation */ ··· 125 } 126 EXPORT_SYMBOL_GPL(apei_hest_parse); 127 128 + struct ghes_arr { 129 + struct platform_device **ghes_devs; 130 + unsigned int count; 131 + }; 132 + 133 + static int hest_parse_ghes_count(struct acpi_hest_header *hest_hdr, void *data) 134 + { 135 + int *count = data; 136 + 137 + if (hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR) 138 + (*count)++; 139 + return 0; 140 + } 141 + 142 + static int hest_parse_ghes(struct acpi_hest_header *hest_hdr, void *data) 143 + { 144 + struct acpi_hest_generic *generic; 145 + struct platform_device *ghes_dev; 146 + struct ghes_arr *ghes_arr = data; 147 + int rc; 148 + 149 + if (hest_hdr->type != ACPI_HEST_TYPE_GENERIC_ERROR) 150 + return 0; 151 + generic = (struct acpi_hest_generic *)hest_hdr; 152 + if (!generic->enabled) 153 + return 0; 154 + ghes_dev = platform_device_alloc("GHES", hest_hdr->source_id); 155 + if (!ghes_dev) 156 + return -ENOMEM; 157 + ghes_dev->dev.platform_data = generic; 158 + rc = platform_device_add(ghes_dev); 159 + if (rc) 160 + goto err; 161 + ghes_arr->ghes_devs[ghes_arr->count++] = ghes_dev; 162 + 163 + return 0; 164 + err: 165 + platform_device_put(ghes_dev); 166 + return rc; 167 + } 168 + 169 + static int hest_ghes_dev_register(unsigned int ghes_count) 170 + { 171 + int rc, i; 172 + struct ghes_arr ghes_arr; 173 + 174 + ghes_arr.count = 0; 175 + ghes_arr.ghes_devs = kmalloc(sizeof(void *) * ghes_count, GFP_KERNEL); 176 + if (!ghes_arr.ghes_devs) 177 + return -ENOMEM; 178 + 179 + rc = apei_hest_parse(hest_parse_ghes, &ghes_arr); 180 + if (rc) 181 + goto err; 182 + out: 183 + kfree(ghes_arr.ghes_devs); 184 + return rc; 185 + err: 186 + for (i = 0; i < ghes_arr.count; i++) 187 + platform_device_unregister(ghes_arr.ghes_devs[i]); 188 + goto out; 189 + } 190 + 191 static int __init setup_hest_disable(char *str) 192 { 193 hest_disable = 1; ··· 137 { 138 acpi_status status; 139 int rc = -ENODEV; 140 + unsigned int ghes_count = 0; 141 142 if (acpi_disabled) 143 goto err; ··· 158 goto err; 159 } 160 161 + rc = apei_hest_parse(hest_parse_ghes_count, &ghes_count); 162 + if (rc) 163 + goto err; 164 + 165 + rc = hest_ghes_dev_register(ghes_count); 166 if (rc) 167 goto err; 168
+2 -2
drivers/acpi/bus.c
··· 1034 acpi_scan_init(); 1035 acpi_ec_init(); 1036 acpi_power_init(); 1037 - acpi_system_init(); 1038 - acpi_debug_init(); 1039 acpi_sleep_proc_init(); 1040 acpi_wakeup_device_init(); 1041 return result;
··· 1034 acpi_scan_init(); 1035 acpi_ec_init(); 1036 acpi_power_init(); 1037 + acpi_sysfs_init(); 1038 + acpi_debugfs_init(); 1039 acpi_sleep_proc_init(); 1040 acpi_wakeup_device_init(); 1041 return result;
-422
drivers/acpi/debug.c
··· 1 - /* 2 - * debug.c - ACPI debug interface to userspace. 3 - */ 4 - 5 - #include <linux/proc_fs.h> 6 - #include <linux/seq_file.h> 7 - #include <linux/init.h> 8 - #include <linux/module.h> 9 - #include <linux/kernel.h> 10 - #include <linux/moduleparam.h> 11 - #include <linux/debugfs.h> 12 - #include <linux/slab.h> 13 - #include <asm/uaccess.h> 14 - #include <acpi/acpi_drivers.h> 15 - 16 - #define _COMPONENT ACPI_SYSTEM_COMPONENT 17 - ACPI_MODULE_NAME("debug"); 18 - 19 - struct acpi_dlayer { 20 - const char *name; 21 - unsigned long value; 22 - }; 23 - struct acpi_dlevel { 24 - const char *name; 25 - unsigned long value; 26 - }; 27 - #define ACPI_DEBUG_INIT(v) { .name = #v, .value = v } 28 - 29 - static const struct acpi_dlayer acpi_debug_layers[] = { 30 - ACPI_DEBUG_INIT(ACPI_UTILITIES), 31 - ACPI_DEBUG_INIT(ACPI_HARDWARE), 32 - ACPI_DEBUG_INIT(ACPI_EVENTS), 33 - ACPI_DEBUG_INIT(ACPI_TABLES), 34 - ACPI_DEBUG_INIT(ACPI_NAMESPACE), 35 - ACPI_DEBUG_INIT(ACPI_PARSER), 36 - ACPI_DEBUG_INIT(ACPI_DISPATCHER), 37 - ACPI_DEBUG_INIT(ACPI_EXECUTER), 38 - ACPI_DEBUG_INIT(ACPI_RESOURCES), 39 - ACPI_DEBUG_INIT(ACPI_CA_DEBUGGER), 40 - ACPI_DEBUG_INIT(ACPI_OS_SERVICES), 41 - ACPI_DEBUG_INIT(ACPI_CA_DISASSEMBLER), 42 - ACPI_DEBUG_INIT(ACPI_COMPILER), 43 - ACPI_DEBUG_INIT(ACPI_TOOLS), 44 - 45 - ACPI_DEBUG_INIT(ACPI_BUS_COMPONENT), 46 - ACPI_DEBUG_INIT(ACPI_AC_COMPONENT), 47 - ACPI_DEBUG_INIT(ACPI_BATTERY_COMPONENT), 48 - ACPI_DEBUG_INIT(ACPI_BUTTON_COMPONENT), 49 - ACPI_DEBUG_INIT(ACPI_SBS_COMPONENT), 50 - ACPI_DEBUG_INIT(ACPI_FAN_COMPONENT), 51 - ACPI_DEBUG_INIT(ACPI_PCI_COMPONENT), 52 - ACPI_DEBUG_INIT(ACPI_POWER_COMPONENT), 53 - ACPI_DEBUG_INIT(ACPI_CONTAINER_COMPONENT), 54 - ACPI_DEBUG_INIT(ACPI_SYSTEM_COMPONENT), 55 - ACPI_DEBUG_INIT(ACPI_THERMAL_COMPONENT), 56 - ACPI_DEBUG_INIT(ACPI_MEMORY_DEVICE_COMPONENT), 57 - ACPI_DEBUG_INIT(ACPI_VIDEO_COMPONENT), 58 - ACPI_DEBUG_INIT(ACPI_PROCESSOR_COMPONENT), 59 - }; 60 - 61 - static const struct acpi_dlevel acpi_debug_levels[] = { 62 - ACPI_DEBUG_INIT(ACPI_LV_INIT), 63 - ACPI_DEBUG_INIT(ACPI_LV_DEBUG_OBJECT), 64 - ACPI_DEBUG_INIT(ACPI_LV_INFO), 65 - 66 - ACPI_DEBUG_INIT(ACPI_LV_INIT_NAMES), 67 - ACPI_DEBUG_INIT(ACPI_LV_PARSE), 68 - ACPI_DEBUG_INIT(ACPI_LV_LOAD), 69 - ACPI_DEBUG_INIT(ACPI_LV_DISPATCH), 70 - ACPI_DEBUG_INIT(ACPI_LV_EXEC), 71 - ACPI_DEBUG_INIT(ACPI_LV_NAMES), 72 - ACPI_DEBUG_INIT(ACPI_LV_OPREGION), 73 - ACPI_DEBUG_INIT(ACPI_LV_BFIELD), 74 - ACPI_DEBUG_INIT(ACPI_LV_TABLES), 75 - ACPI_DEBUG_INIT(ACPI_LV_VALUES), 76 - ACPI_DEBUG_INIT(ACPI_LV_OBJECTS), 77 - ACPI_DEBUG_INIT(ACPI_LV_RESOURCES), 78 - ACPI_DEBUG_INIT(ACPI_LV_USER_REQUESTS), 79 - ACPI_DEBUG_INIT(ACPI_LV_PACKAGE), 80 - 81 - ACPI_DEBUG_INIT(ACPI_LV_ALLOCATIONS), 82 - ACPI_DEBUG_INIT(ACPI_LV_FUNCTIONS), 83 - ACPI_DEBUG_INIT(ACPI_LV_OPTIMIZATIONS), 84 - 85 - ACPI_DEBUG_INIT(ACPI_LV_MUTEX), 86 - ACPI_DEBUG_INIT(ACPI_LV_THREADS), 87 - ACPI_DEBUG_INIT(ACPI_LV_IO), 88 - ACPI_DEBUG_INIT(ACPI_LV_INTERRUPTS), 89 - 90 - ACPI_DEBUG_INIT(ACPI_LV_AML_DISASSEMBLE), 91 - ACPI_DEBUG_INIT(ACPI_LV_VERBOSE_INFO), 92 - ACPI_DEBUG_INIT(ACPI_LV_FULL_TABLES), 93 - ACPI_DEBUG_INIT(ACPI_LV_EVENTS), 94 - }; 95 - 96 - /* -------------------------------------------------------------------------- 97 - FS Interface (/sys) 98 - -------------------------------------------------------------------------- */ 99 - static int param_get_debug_layer(char *buffer, const struct kernel_param *kp) 100 - { 101 - int result = 0; 102 - int i; 103 - 104 - result = sprintf(buffer, "%-25s\tHex SET\n", "Description"); 105 - 106 - for(i = 0; i <ARRAY_SIZE(acpi_debug_layers); i++) { 107 - result += sprintf(buffer+result, "%-25s\t0x%08lX [%c]\n", 108 - acpi_debug_layers[i].name, 109 - acpi_debug_layers[i].value, 110 - (acpi_dbg_layer & acpi_debug_layers[i].value) ? '*' : ' '); 111 - } 112 - result += sprintf(buffer+result, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS", 113 - ACPI_ALL_DRIVERS, 114 - (acpi_dbg_layer & ACPI_ALL_DRIVERS) == 115 - ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer & 116 - ACPI_ALL_DRIVERS) == 0 ? ' ' : '-'); 117 - result += sprintf(buffer+result, "--\ndebug_layer = 0x%08X ( * = enabled)\n", acpi_dbg_layer); 118 - 119 - return result; 120 - } 121 - 122 - static int param_get_debug_level(char *buffer, const struct kernel_param *kp) 123 - { 124 - int result = 0; 125 - int i; 126 - 127 - result = sprintf(buffer, "%-25s\tHex SET\n", "Description"); 128 - 129 - for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) { 130 - result += sprintf(buffer+result, "%-25s\t0x%08lX [%c]\n", 131 - acpi_debug_levels[i].name, 132 - acpi_debug_levels[i].value, 133 - (acpi_dbg_level & acpi_debug_levels[i]. 134 - value) ? '*' : ' '); 135 - } 136 - result += sprintf(buffer+result, "--\ndebug_level = 0x%08X (* = enabled)\n", 137 - acpi_dbg_level); 138 - 139 - return result; 140 - } 141 - 142 - static struct kernel_param_ops acpi_debug_layer_ops = { 143 - .set = param_set_uint, 144 - .get = param_get_debug_layer, 145 - }; 146 - 147 - static struct kernel_param_ops acpi_debug_level_ops = { 148 - .set = param_set_uint, 149 - .get = param_get_debug_level, 150 - }; 151 - 152 - module_param_cb(debug_layer, &acpi_debug_layer_ops, &acpi_dbg_layer, 0644); 153 - module_param_cb(debug_level, &acpi_debug_level_ops, &acpi_dbg_level, 0644); 154 - 155 - static char trace_method_name[6]; 156 - module_param_string(trace_method_name, trace_method_name, 6, 0644); 157 - static unsigned int trace_debug_layer; 158 - module_param(trace_debug_layer, uint, 0644); 159 - static unsigned int trace_debug_level; 160 - module_param(trace_debug_level, uint, 0644); 161 - 162 - static int param_set_trace_state(const char *val, const struct kernel_param *kp) 163 - { 164 - int result = 0; 165 - 166 - if (!strncmp(val, "enable", strlen("enable") - 1)) { 167 - result = acpi_debug_trace(trace_method_name, trace_debug_level, 168 - trace_debug_layer, 0); 169 - if (result) 170 - result = -EBUSY; 171 - goto exit; 172 - } 173 - 174 - if (!strncmp(val, "disable", strlen("disable") - 1)) { 175 - int name = 0; 176 - result = acpi_debug_trace((char *)&name, trace_debug_level, 177 - trace_debug_layer, 0); 178 - if (result) 179 - result = -EBUSY; 180 - goto exit; 181 - } 182 - 183 - if (!strncmp(val, "1", 1)) { 184 - result = acpi_debug_trace(trace_method_name, trace_debug_level, 185 - trace_debug_layer, 1); 186 - if (result) 187 - result = -EBUSY; 188 - goto exit; 189 - } 190 - 191 - result = -EINVAL; 192 - exit: 193 - return result; 194 - } 195 - 196 - static int param_get_trace_state(char *buffer, const struct kernel_param *kp) 197 - { 198 - if (!acpi_gbl_trace_method_name) 199 - return sprintf(buffer, "disable"); 200 - else { 201 - if (acpi_gbl_trace_flags & 1) 202 - return sprintf(buffer, "1"); 203 - else 204 - return sprintf(buffer, "enable"); 205 - } 206 - return 0; 207 - } 208 - 209 - static struct kernel_param_ops param_ops_trace_state = { 210 - .set = param_set_trace_state, 211 - .get = param_get_trace_state, 212 - }; 213 - 214 - module_param_cb(trace_state, &param_ops_trace_state, NULL, 0644); 215 - 216 - /* -------------------------------------------------------------------------- 217 - DebugFS Interface 218 - -------------------------------------------------------------------------- */ 219 - 220 - static ssize_t cm_write(struct file *file, const char __user *user_buf, 221 - size_t count, loff_t *ppos) 222 - { 223 - static char *buf; 224 - static int uncopied_bytes; 225 - struct acpi_table_header table; 226 - acpi_status status; 227 - 228 - if (!(*ppos)) { 229 - /* parse the table header to get the table length */ 230 - if (count <= sizeof(struct acpi_table_header)) 231 - return -EINVAL; 232 - if (copy_from_user(&table, user_buf, 233 - sizeof(struct acpi_table_header))) 234 - return -EFAULT; 235 - uncopied_bytes = table.length; 236 - buf = kzalloc(uncopied_bytes, GFP_KERNEL); 237 - if (!buf) 238 - return -ENOMEM; 239 - } 240 - 241 - if (uncopied_bytes < count) { 242 - kfree(buf); 243 - return -EINVAL; 244 - } 245 - 246 - if (copy_from_user(buf + (*ppos), user_buf, count)) { 247 - kfree(buf); 248 - return -EFAULT; 249 - } 250 - 251 - uncopied_bytes -= count; 252 - *ppos += count; 253 - 254 - if (!uncopied_bytes) { 255 - status = acpi_install_method(buf); 256 - kfree(buf); 257 - if (ACPI_FAILURE(status)) 258 - return -EINVAL; 259 - add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); 260 - } 261 - 262 - return count; 263 - } 264 - 265 - static const struct file_operations cm_fops = { 266 - .write = cm_write, 267 - }; 268 - 269 - static int acpi_debugfs_init(void) 270 - { 271 - struct dentry *acpi_dir, *cm_dentry; 272 - 273 - acpi_dir = debugfs_create_dir("acpi", NULL); 274 - if (!acpi_dir) 275 - goto err; 276 - 277 - cm_dentry = debugfs_create_file("custom_method", S_IWUGO, 278 - acpi_dir, NULL, &cm_fops); 279 - if (!cm_dentry) 280 - goto err; 281 - 282 - return 0; 283 - 284 - err: 285 - if (acpi_dir) 286 - debugfs_remove(acpi_dir); 287 - return -EINVAL; 288 - } 289 - 290 - /* -------------------------------------------------------------------------- 291 - FS Interface (/proc) 292 - -------------------------------------------------------------------------- */ 293 - #ifdef CONFIG_ACPI_PROCFS 294 - #define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer" 295 - #define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level" 296 - 297 - static int acpi_system_debug_proc_show(struct seq_file *m, void *v) 298 - { 299 - unsigned int i; 300 - 301 - seq_printf(m, "%-25s\tHex SET\n", "Description"); 302 - 303 - switch ((unsigned long)m->private) { 304 - case 0: 305 - for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) { 306 - seq_printf(m, "%-25s\t0x%08lX [%c]\n", 307 - acpi_debug_layers[i].name, 308 - acpi_debug_layers[i].value, 309 - (acpi_dbg_layer & acpi_debug_layers[i]. 310 - value) ? '*' : ' '); 311 - } 312 - seq_printf(m, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS", 313 - ACPI_ALL_DRIVERS, 314 - (acpi_dbg_layer & ACPI_ALL_DRIVERS) == 315 - ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer & 316 - ACPI_ALL_DRIVERS) == 317 - 0 ? ' ' : '-'); 318 - seq_printf(m, 319 - "--\ndebug_layer = 0x%08X (* = enabled, - = partial)\n", 320 - acpi_dbg_layer); 321 - break; 322 - case 1: 323 - for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) { 324 - seq_printf(m, "%-25s\t0x%08lX [%c]\n", 325 - acpi_debug_levels[i].name, 326 - acpi_debug_levels[i].value, 327 - (acpi_dbg_level & acpi_debug_levels[i]. 328 - value) ? '*' : ' '); 329 - } 330 - seq_printf(m, "--\ndebug_level = 0x%08X (* = enabled)\n", 331 - acpi_dbg_level); 332 - break; 333 - } 334 - return 0; 335 - } 336 - 337 - static int acpi_system_debug_proc_open(struct inode *inode, struct file *file) 338 - { 339 - return single_open(file, acpi_system_debug_proc_show, PDE(inode)->data); 340 - } 341 - 342 - static ssize_t acpi_system_debug_proc_write(struct file *file, 343 - const char __user * buffer, 344 - size_t count, loff_t *pos) 345 - { 346 - char debug_string[12] = { '\0' }; 347 - 348 - 349 - if (count > sizeof(debug_string) - 1) 350 - return -EINVAL; 351 - 352 - if (copy_from_user(debug_string, buffer, count)) 353 - return -EFAULT; 354 - 355 - debug_string[count] = '\0'; 356 - 357 - switch ((unsigned long)PDE(file->f_path.dentry->d_inode)->data) { 358 - case 0: 359 - acpi_dbg_layer = simple_strtoul(debug_string, NULL, 0); 360 - break; 361 - case 1: 362 - acpi_dbg_level = simple_strtoul(debug_string, NULL, 0); 363 - break; 364 - default: 365 - return -EINVAL; 366 - } 367 - 368 - return count; 369 - } 370 - 371 - static const struct file_operations acpi_system_debug_proc_fops = { 372 - .owner = THIS_MODULE, 373 - .open = acpi_system_debug_proc_open, 374 - .read = seq_read, 375 - .llseek = seq_lseek, 376 - .release = single_release, 377 - .write = acpi_system_debug_proc_write, 378 - }; 379 - #endif 380 - 381 - int __init acpi_procfs_init(void) 382 - { 383 - #ifdef CONFIG_ACPI_PROCFS 384 - struct proc_dir_entry *entry; 385 - int error = 0; 386 - char *name; 387 - 388 - /* 'debug_layer' [R/W] */ 389 - name = ACPI_SYSTEM_FILE_DEBUG_LAYER; 390 - entry = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUSR, 391 - acpi_root_dir, &acpi_system_debug_proc_fops, 392 - (void *)0); 393 - if (!entry) 394 - goto Error; 395 - 396 - /* 'debug_level' [R/W] */ 397 - name = ACPI_SYSTEM_FILE_DEBUG_LEVEL; 398 - entry = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUSR, 399 - acpi_root_dir, &acpi_system_debug_proc_fops, 400 - (void *)1); 401 - if (!entry) 402 - goto Error; 403 - 404 - Done: 405 - return error; 406 - 407 - Error: 408 - remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir); 409 - remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir); 410 - error = -ENODEV; 411 - goto Done; 412 - #else 413 - return 0; 414 - #endif 415 - } 416 - 417 - int __init acpi_debug_init(void) 418 - { 419 - acpi_debugfs_init(); 420 - acpi_procfs_init(); 421 - return 0; 422 - }
···
+93
drivers/acpi/debugfs.c
···
··· 1 + /* 2 + * debugfs.c - ACPI debugfs interface to userspace. 3 + */ 4 + 5 + #include <linux/init.h> 6 + #include <linux/module.h> 7 + #include <linux/kernel.h> 8 + #include <linux/uaccess.h> 9 + #include <linux/debugfs.h> 10 + #include <acpi/acpi_drivers.h> 11 + 12 + #define _COMPONENT ACPI_SYSTEM_COMPONENT 13 + ACPI_MODULE_NAME("debugfs"); 14 + 15 + 16 + /* /sys/modules/acpi/parameters/aml_debug_output */ 17 + 18 + module_param_named(aml_debug_output, acpi_gbl_enable_aml_debug_object, 19 + bool, 0644); 20 + MODULE_PARM_DESC(aml_debug_output, 21 + "To enable/disable the ACPI Debug Object output."); 22 + 23 + /* /sys/kernel/debug/acpi/custom_method */ 24 + 25 + static ssize_t cm_write(struct file *file, const char __user * user_buf, 26 + size_t count, loff_t *ppos) 27 + { 28 + static char *buf; 29 + static int uncopied_bytes; 30 + struct acpi_table_header table; 31 + acpi_status status; 32 + 33 + if (!(*ppos)) { 34 + /* parse the table header to get the table length */ 35 + if (count <= sizeof(struct acpi_table_header)) 36 + return -EINVAL; 37 + if (copy_from_user(&table, user_buf, 38 + sizeof(struct acpi_table_header))) 39 + return -EFAULT; 40 + uncopied_bytes = table.length; 41 + buf = kzalloc(uncopied_bytes, GFP_KERNEL); 42 + if (!buf) 43 + return -ENOMEM; 44 + } 45 + 46 + if (uncopied_bytes < count) { 47 + kfree(buf); 48 + return -EINVAL; 49 + } 50 + 51 + if (copy_from_user(buf + (*ppos), user_buf, count)) { 52 + kfree(buf); 53 + return -EFAULT; 54 + } 55 + 56 + uncopied_bytes -= count; 57 + *ppos += count; 58 + 59 + if (!uncopied_bytes) { 60 + status = acpi_install_method(buf); 61 + kfree(buf); 62 + if (ACPI_FAILURE(status)) 63 + return -EINVAL; 64 + add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); 65 + } 66 + 67 + return count; 68 + } 69 + 70 + static const struct file_operations cm_fops = { 71 + .write = cm_write, 72 + }; 73 + 74 + int __init acpi_debugfs_init(void) 75 + { 76 + struct dentry *acpi_dir, *cm_dentry; 77 + 78 + acpi_dir = debugfs_create_dir("acpi", NULL); 79 + if (!acpi_dir) 80 + goto err; 81 + 82 + cm_dentry = debugfs_create_file("custom_method", S_IWUGO, 83 + acpi_dir, NULL, &cm_fops); 84 + if (!cm_dentry) 85 + goto err; 86 + 87 + return 0; 88 + 89 + err: 90 + if (acpi_dir) 91 + debugfs_remove(acpi_dir); 92 + return -EINVAL; 93 + }
+2 -1
drivers/acpi/glue.c
··· 100 101 status = acpi_get_object_info(handle, &info); 102 if (ACPI_SUCCESS(status)) { 103 - if (info->address == find->address) 104 find->handle = handle; 105 kfree(info); 106 }
··· 100 101 status = acpi_get_object_info(handle, &info); 102 if (ACPI_SUCCESS(status)) { 103 + if ((info->address == find->address) 104 + && (info->valid & ACPI_VALID_ADR)) 105 find->handle = handle; 106 kfree(info); 107 }
+4 -4
drivers/acpi/internal.h
··· 27 28 int init_acpi_device_notify(void); 29 int acpi_scan_init(void); 30 - int acpi_system_init(void); 31 32 - #ifdef CONFIG_ACPI_DEBUG 33 - int acpi_debug_init(void); 34 #else 35 - static inline int acpi_debug_init(void) { return 0; } 36 #endif 37 38 /* --------------------------------------------------------------------------
··· 27 28 int init_acpi_device_notify(void); 29 int acpi_scan_init(void); 30 + int acpi_sysfs_init(void); 31 32 + #ifdef CONFIG_DEBUG_FS 33 + int acpi_debugfs_init(void); 34 #else 35 + static inline int acpi_debugfs_init(void) { return 0; } 36 #endif 37 38 /* --------------------------------------------------------------------------
+1 -3
drivers/acpi/numa.c
··· 255 256 static int __init acpi_parse_srat(struct acpi_table_header *table) 257 { 258 - struct acpi_table_srat *srat; 259 - 260 if (!table) 261 return -EINVAL; 262 263 - srat = (struct acpi_table_srat *)table; 264 265 return 0; 266 }
··· 255 256 static int __init acpi_parse_srat(struct acpi_table_header *table) 257 { 258 if (!table) 259 return -EINVAL; 260 261 + /* Real work done in acpi_table_parse_srat below. */ 262 263 return 0; 264 }
+3 -4
drivers/acpi/osl.c
··· 141 static void __init acpi_request_region (struct acpi_generic_address *addr, 142 unsigned int length, char *desc) 143 { 144 - struct resource *res; 145 - 146 if (!addr->address || !length) 147 return; 148 149 if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO) 150 - res = request_region(addr->address, length, desc); 151 else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) 152 - res = request_mem_region(addr->address, length, desc); 153 } 154 155 static int __init acpi_reserve_resources(void)
··· 141 static void __init acpi_request_region (struct acpi_generic_address *addr, 142 unsigned int length, char *desc) 143 { 144 if (!addr->address || !length) 145 return; 146 147 + /* Resources are never freed */ 148 if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO) 149 + request_region(addr->address, length, desc); 150 else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) 151 + request_mem_region(addr->address, length, desc); 152 } 153 154 static int __init acpi_reserve_resources(void)
+1 -128
drivers/acpi/power.c
··· 40 #include <linux/init.h> 41 #include <linux/types.h> 42 #include <linux/slab.h> 43 - #include <linux/proc_fs.h> 44 - #include <linux/seq_file.h> 45 #include <acpi/acpi_bus.h> 46 #include <acpi/acpi_drivers.h> 47 #include "sleep.h" ··· 62 static int acpi_power_add(struct acpi_device *device); 63 static int acpi_power_remove(struct acpi_device *device, int type); 64 static int acpi_power_resume(struct acpi_device *device); 65 - static int acpi_power_open_fs(struct inode *inode, struct file *file); 66 67 static const struct acpi_device_id power_device_ids[] = { 68 {ACPI_POWER_HID, 0}, ··· 95 }; 96 97 static struct list_head acpi_power_resource_list; 98 - 99 - static const struct file_operations acpi_power_fops = { 100 - .owner = THIS_MODULE, 101 - .open = acpi_power_open_fs, 102 - .read = seq_read, 103 - .llseek = seq_lseek, 104 - .release = single_release, 105 - }; 106 107 /* -------------------------------------------------------------------------- 108 Power Resource Management ··· 243 struct acpi_power_resource *resource = NULL; 244 struct list_head *node, *next; 245 struct acpi_power_reference *ref; 246 - 247 248 result = acpi_power_get_context(handle, &resource); 249 if (result) ··· 530 } 531 532 /* -------------------------------------------------------------------------- 533 - FS Interface (/proc) 534 - -------------------------------------------------------------------------- */ 535 - 536 - static struct proc_dir_entry *acpi_power_dir; 537 - 538 - static int acpi_power_seq_show(struct seq_file *seq, void *offset) 539 - { 540 - int count = 0; 541 - int result = 0, state; 542 - struct acpi_power_resource *resource = NULL; 543 - struct list_head *node, *next; 544 - struct acpi_power_reference *ref; 545 - 546 - 547 - resource = seq->private; 548 - 549 - if (!resource) 550 - goto end; 551 - 552 - result = acpi_power_get_state(resource->device->handle, &state); 553 - if (result) 554 - goto end; 555 - 556 - seq_puts(seq, "state: "); 557 - switch (state) { 558 - case ACPI_POWER_RESOURCE_STATE_ON: 559 - seq_puts(seq, "on\n"); 560 - break; 561 - case ACPI_POWER_RESOURCE_STATE_OFF: 562 - seq_puts(seq, "off\n"); 563 - break; 564 - default: 565 - seq_puts(seq, "unknown\n"); 566 - break; 567 - } 568 - 569 - mutex_lock(&resource->resource_lock); 570 - list_for_each_safe(node, next, &resource->reference) { 571 - ref = container_of(node, struct acpi_power_reference, node); 572 - count++; 573 - } 574 - mutex_unlock(&resource->resource_lock); 575 - 576 - seq_printf(seq, "system level: S%d\n" 577 - "order: %d\n" 578 - "reference count: %d\n", 579 - resource->system_level, 580 - resource->order, count); 581 - 582 - end: 583 - return 0; 584 - } 585 - 586 - static int acpi_power_open_fs(struct inode *inode, struct file *file) 587 - { 588 - return single_open(file, acpi_power_seq_show, PDE(inode)->data); 589 - } 590 - 591 - static int acpi_power_add_fs(struct acpi_device *device) 592 - { 593 - struct proc_dir_entry *entry = NULL; 594 - 595 - 596 - if (!device) 597 - return -EINVAL; 598 - 599 - if (!acpi_device_dir(device)) { 600 - acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 601 - acpi_power_dir); 602 - if (!acpi_device_dir(device)) 603 - return -ENODEV; 604 - } 605 - 606 - /* 'status' [R] */ 607 - entry = proc_create_data(ACPI_POWER_FILE_STATUS, 608 - S_IRUGO, acpi_device_dir(device), 609 - &acpi_power_fops, acpi_driver_data(device)); 610 - if (!entry) 611 - return -EIO; 612 - return 0; 613 - } 614 - 615 - static int acpi_power_remove_fs(struct acpi_device *device) 616 - { 617 - 618 - if (acpi_device_dir(device)) { 619 - remove_proc_entry(ACPI_POWER_FILE_STATUS, 620 - acpi_device_dir(device)); 621 - remove_proc_entry(acpi_device_bid(device), acpi_power_dir); 622 - acpi_device_dir(device) = NULL; 623 - } 624 - 625 - return 0; 626 - } 627 - 628 - /* -------------------------------------------------------------------------- 629 Driver Interface 630 -------------------------------------------------------------------------- */ 631 ··· 582 break; 583 } 584 585 - result = acpi_power_add_fs(device); 586 - if (result) 587 - goto end; 588 - 589 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device), 590 acpi_device_bid(device), state ? "on" : "off"); 591 ··· 602 return -EINVAL; 603 604 resource = acpi_driver_data(device); 605 - 606 - acpi_power_remove_fs(device); 607 608 mutex_lock(&resource->resource_lock); 609 list_for_each_safe(node, next, &resource->reference) { ··· 646 647 int __init acpi_power_init(void) 648 { 649 - int result = 0; 650 - 651 INIT_LIST_HEAD(&acpi_power_resource_list); 652 - 653 - acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir); 654 - if (!acpi_power_dir) 655 - return -ENODEV; 656 - 657 - result = acpi_bus_register_driver(&acpi_power_driver); 658 - if (result < 0) { 659 - remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir); 660 - return -ENODEV; 661 - } 662 - 663 - return 0; 664 }
··· 40 #include <linux/init.h> 41 #include <linux/types.h> 42 #include <linux/slab.h> 43 #include <acpi/acpi_bus.h> 44 #include <acpi/acpi_drivers.h> 45 #include "sleep.h" ··· 64 static int acpi_power_add(struct acpi_device *device); 65 static int acpi_power_remove(struct acpi_device *device, int type); 66 static int acpi_power_resume(struct acpi_device *device); 67 68 static const struct acpi_device_id power_device_ids[] = { 69 {ACPI_POWER_HID, 0}, ··· 98 }; 99 100 static struct list_head acpi_power_resource_list; 101 102 /* -------------------------------------------------------------------------- 103 Power Resource Management ··· 254 struct acpi_power_resource *resource = NULL; 255 struct list_head *node, *next; 256 struct acpi_power_reference *ref; 257 258 result = acpi_power_get_context(handle, &resource); 259 if (result) ··· 542 } 543 544 /* -------------------------------------------------------------------------- 545 Driver Interface 546 -------------------------------------------------------------------------- */ 547 ··· 690 break; 691 } 692 693 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device), 694 acpi_device_bid(device), state ? "on" : "off"); 695 ··· 714 return -EINVAL; 715 716 resource = acpi_driver_data(device); 717 718 mutex_lock(&resource->resource_lock); 719 list_for_each_safe(node, next, &resource->reference) { ··· 760 761 int __init acpi_power_init(void) 762 { 763 INIT_LIST_HEAD(&acpi_power_resource_list); 764 + return acpi_bus_register_driver(&acpi_power_driver); 765 }
-70
drivers/acpi/proc.c
··· 17 18 /* 19 * this file provides support for: 20 - * /proc/acpi/sleep 21 * /proc/acpi/alarm 22 * /proc/acpi/wakeup 23 */ 24 25 ACPI_MODULE_NAME("sleep") 26 - #ifdef CONFIG_ACPI_PROCFS 27 - static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset) 28 - { 29 - int i; 30 - 31 - for (i = 0; i <= ACPI_STATE_S5; i++) { 32 - if (sleep_states[i]) { 33 - seq_printf(seq, "S%d ", i); 34 - } 35 - } 36 - 37 - seq_puts(seq, "\n"); 38 - 39 - return 0; 40 - } 41 - 42 - static int acpi_system_sleep_open_fs(struct inode *inode, struct file *file) 43 - { 44 - return single_open(file, acpi_system_sleep_seq_show, PDE(inode)->data); 45 - } 46 - 47 - static ssize_t 48 - acpi_system_write_sleep(struct file *file, 49 - const char __user * buffer, size_t count, loff_t * ppos) 50 - { 51 - char str[12]; 52 - u32 state = 0; 53 - int error = 0; 54 - 55 - if (count > sizeof(str) - 1) 56 - goto Done; 57 - memset(str, 0, sizeof(str)); 58 - if (copy_from_user(str, buffer, count)) 59 - return -EFAULT; 60 - 61 - /* Check for S4 bios request */ 62 - if (!strcmp(str, "4b")) { 63 - error = acpi_suspend(4); 64 - goto Done; 65 - } 66 - state = simple_strtoul(str, NULL, 0); 67 - #ifdef CONFIG_HIBERNATION 68 - if (state == 4) { 69 - error = hibernate(); 70 - goto Done; 71 - } 72 - #endif 73 - error = acpi_suspend(state); 74 - Done: 75 - return error ? error : count; 76 - } 77 - #endif /* CONFIG_ACPI_PROCFS */ 78 79 #if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE) || !defined(CONFIG_X86) 80 /* use /sys/class/rtc/rtcX/wakealarm instead; it's not ACPI-specific */ ··· 410 .release = single_release, 411 }; 412 413 - #ifdef CONFIG_ACPI_PROCFS 414 - static const struct file_operations acpi_system_sleep_fops = { 415 - .owner = THIS_MODULE, 416 - .open = acpi_system_sleep_open_fs, 417 - .read = seq_read, 418 - .write = acpi_system_write_sleep, 419 - .llseek = seq_lseek, 420 - .release = single_release, 421 - }; 422 - #endif /* CONFIG_ACPI_PROCFS */ 423 - 424 #ifdef HAVE_ACPI_LEGACY_ALARM 425 static const struct file_operations acpi_system_alarm_fops = { 426 .owner = THIS_MODULE, ··· 431 432 int __init acpi_sleep_proc_init(void) 433 { 434 - #ifdef CONFIG_ACPI_PROCFS 435 - /* 'sleep' [R/W] */ 436 - proc_create("sleep", S_IFREG | S_IRUGO | S_IWUSR, 437 - acpi_root_dir, &acpi_system_sleep_fops); 438 - #endif /* CONFIG_ACPI_PROCFS */ 439 - 440 #ifdef HAVE_ACPI_LEGACY_ALARM 441 /* 'alarm' [R/W] */ 442 proc_create("alarm", S_IFREG | S_IRUGO | S_IWUSR,
··· 17 18 /* 19 * this file provides support for: 20 * /proc/acpi/alarm 21 * /proc/acpi/wakeup 22 */ 23 24 ACPI_MODULE_NAME("sleep") 25 26 #if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE) || !defined(CONFIG_X86) 27 /* use /sys/class/rtc/rtcX/wakealarm instead; it's not ACPI-specific */ ··· 463 .release = single_release, 464 }; 465 466 #ifdef HAVE_ACPI_LEGACY_ALARM 467 static const struct file_operations acpi_system_alarm_fops = { 468 .owner = THIS_MODULE, ··· 495 496 int __init acpi_sleep_proc_init(void) 497 { 498 #ifdef HAVE_ACPI_LEGACY_ALARM 499 /* 'alarm' [R/W] */ 500 proc_create("alarm", S_IFREG | S_IRUGO | S_IWUSR,
-85
drivers/acpi/processor_driver.c
··· 83 84 static int acpi_processor_add(struct acpi_device *device); 85 static int acpi_processor_remove(struct acpi_device *device, int type); 86 - #ifdef CONFIG_ACPI_PROCFS 87 - static int acpi_processor_info_open_fs(struct inode *inode, struct file *file); 88 - #endif 89 static void acpi_processor_notify(struct acpi_device *device, u32 event); 90 static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu); 91 static int acpi_processor_handle_eject(struct acpi_processor *pr); ··· 110 111 #define INSTALL_NOTIFY_HANDLER 1 112 #define UNINSTALL_NOTIFY_HANDLER 2 113 - #ifdef CONFIG_ACPI_PROCFS 114 - static const struct file_operations acpi_processor_info_fops = { 115 - .owner = THIS_MODULE, 116 - .open = acpi_processor_info_open_fs, 117 - .read = seq_read, 118 - .llseek = seq_lseek, 119 - .release = single_release, 120 - }; 121 - #endif 122 123 DEFINE_PER_CPU(struct acpi_processor *, processors); 124 EXPORT_PER_CPU_SYMBOL(processors); ··· 244 return result; 245 } 246 247 - /* -------------------------------------------------------------------------- 248 - FS Interface (/proc) 249 - -------------------------------------------------------------------------- */ 250 - 251 - #ifdef CONFIG_ACPI_PROCFS 252 static struct proc_dir_entry *acpi_processor_dir = NULL; 253 - 254 - static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset) 255 - { 256 - struct acpi_processor *pr = seq->private; 257 - 258 - 259 - if (!pr) 260 - goto end; 261 - 262 - seq_printf(seq, "processor id: %d\n" 263 - "acpi id: %d\n" 264 - "bus mastering control: %s\n" 265 - "power management: %s\n" 266 - "throttling control: %s\n" 267 - "limit interface: %s\n", 268 - pr->id, 269 - pr->acpi_id, 270 - pr->flags.bm_control ? "yes" : "no", 271 - pr->flags.power ? "yes" : "no", 272 - pr->flags.throttling ? "yes" : "no", 273 - pr->flags.limit ? "yes" : "no"); 274 - 275 - end: 276 - return 0; 277 - } 278 - 279 - static int acpi_processor_info_open_fs(struct inode *inode, struct file *file) 280 - { 281 - return single_open(file, acpi_processor_info_seq_show, 282 - PDE(inode)->data); 283 - } 284 285 static int __cpuinit acpi_processor_add_fs(struct acpi_device *device) 286 { ··· 258 return -ENODEV; 259 } 260 261 - /* 'info' [R] */ 262 - entry = proc_create_data(ACPI_PROCESSOR_FILE_INFO, 263 - S_IRUGO, acpi_device_dir(device), 264 - &acpi_processor_info_fops, 265 - acpi_driver_data(device)); 266 - if (!entry) 267 - return -EIO; 268 - 269 /* 'throttling' [R/W] */ 270 entry = proc_create_data(ACPI_PROCESSOR_FILE_THROTTLING, 271 S_IFREG | S_IRUGO | S_IWUSR, 272 acpi_device_dir(device), 273 &acpi_processor_throttling_fops, 274 - acpi_driver_data(device)); 275 - if (!entry) 276 - return -EIO; 277 - 278 - /* 'limit' [R/W] */ 279 - entry = proc_create_data(ACPI_PROCESSOR_FILE_LIMIT, 280 - S_IFREG | S_IRUGO | S_IWUSR, 281 - acpi_device_dir(device), 282 - &acpi_processor_limit_fops, 283 acpi_driver_data(device)); 284 if (!entry) 285 return -EIO; ··· 272 { 273 274 if (acpi_device_dir(device)) { 275 - remove_proc_entry(ACPI_PROCESSOR_FILE_INFO, 276 - acpi_device_dir(device)); 277 remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING, 278 - acpi_device_dir(device)); 279 - remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT, 280 acpi_device_dir(device)); 281 remove_proc_entry(acpi_device_bid(device), acpi_processor_dir); 282 acpi_device_dir(device) = NULL; ··· 280 281 return 0; 282 } 283 - #else 284 - static inline int acpi_processor_add_fs(struct acpi_device *device) 285 - { 286 - return 0; 287 - } 288 - static inline int acpi_processor_remove_fs(struct acpi_device *device) 289 - { 290 - return 0; 291 - } 292 - #endif 293 294 /* -------------------------------------------------------------------------- 295 Driver Interface ··· 842 843 memset(&errata, 0, sizeof(errata)); 844 845 - #ifdef CONFIG_ACPI_PROCFS 846 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); 847 if (!acpi_processor_dir) 848 return -ENOMEM; 849 - #endif 850 851 if (!cpuidle_register_driver(&acpi_idle_driver)) { 852 printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n", ··· 871 out_cpuidle: 872 cpuidle_unregister_driver(&acpi_idle_driver); 873 874 - #ifdef CONFIG_ACPI_PROCFS 875 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); 876 - #endif 877 878 return result; 879 } ··· 891 892 cpuidle_unregister_driver(&acpi_idle_driver); 893 894 - #ifdef CONFIG_ACPI_PROCFS 895 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); 896 - #endif 897 898 return; 899 }
··· 83 84 static int acpi_processor_add(struct acpi_device *device); 85 static int acpi_processor_remove(struct acpi_device *device, int type); 86 static void acpi_processor_notify(struct acpi_device *device, u32 event); 87 static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu); 88 static int acpi_processor_handle_eject(struct acpi_processor *pr); ··· 113 114 #define INSTALL_NOTIFY_HANDLER 1 115 #define UNINSTALL_NOTIFY_HANDLER 2 116 117 DEFINE_PER_CPU(struct acpi_processor *, processors); 118 EXPORT_PER_CPU_SYMBOL(processors); ··· 256 return result; 257 } 258 259 static struct proc_dir_entry *acpi_processor_dir = NULL; 260 261 static int __cpuinit acpi_processor_add_fs(struct acpi_device *device) 262 { ··· 306 return -ENODEV; 307 } 308 309 /* 'throttling' [R/W] */ 310 entry = proc_create_data(ACPI_PROCESSOR_FILE_THROTTLING, 311 S_IFREG | S_IRUGO | S_IWUSR, 312 acpi_device_dir(device), 313 &acpi_processor_throttling_fops, 314 acpi_driver_data(device)); 315 if (!entry) 316 return -EIO; ··· 337 { 338 339 if (acpi_device_dir(device)) { 340 remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING, 341 acpi_device_dir(device)); 342 remove_proc_entry(acpi_device_bid(device), acpi_processor_dir); 343 acpi_device_dir(device) = NULL; ··· 349 350 return 0; 351 } 352 353 /* -------------------------------------------------------------------------- 354 Driver Interface ··· 921 922 memset(&errata, 0, sizeof(errata)); 923 924 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); 925 if (!acpi_processor_dir) 926 return -ENOMEM; 927 928 if (!cpuidle_register_driver(&acpi_idle_driver)) { 929 printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n", ··· 952 out_cpuidle: 953 cpuidle_unregister_driver(&acpi_idle_driver); 954 955 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); 956 957 return result; 958 } ··· 974 975 cpuidle_unregister_driver(&acpi_idle_driver); 976 977 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); 978 979 return; 980 }
+1 -101
drivers/acpi/processor_idle.c
··· 33 #include <linux/init.h> 34 #include <linux/cpufreq.h> 35 #include <linux/slab.h> 36 - #include <linux/proc_fs.h> 37 - #include <linux/seq_file.h> 38 #include <linux/acpi.h> 39 #include <linux/dmi.h> 40 #include <linux/moduleparam.h> ··· 79 80 static unsigned int latency_factor __read_mostly = 2; 81 module_param(latency_factor, uint, 0644); 82 - 83 - #ifdef CONFIG_ACPI_PROCFS 84 - static u64 us_to_pm_timer_ticks(s64 t) 85 - { 86 - return div64_u64(t * PM_TIMER_FREQUENCY, 1000000); 87 - } 88 - #endif 89 90 /* 91 * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3. ··· 680 return 0; 681 } 682 683 - #ifdef CONFIG_ACPI_PROCFS 684 - static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) 685 - { 686 - struct acpi_processor *pr = seq->private; 687 - unsigned int i; 688 - 689 - 690 - if (!pr) 691 - goto end; 692 - 693 - seq_printf(seq, "active state: C%zd\n" 694 - "max_cstate: C%d\n" 695 - "maximum allowed latency: %d usec\n", 696 - pr->power.state ? pr->power.state - pr->power.states : 0, 697 - max_cstate, pm_qos_request(PM_QOS_CPU_DMA_LATENCY)); 698 - 699 - seq_puts(seq, "states:\n"); 700 - 701 - for (i = 1; i <= pr->power.count; i++) { 702 - seq_printf(seq, " %cC%d: ", 703 - (&pr->power.states[i] == 704 - pr->power.state ? '*' : ' '), i); 705 - 706 - if (!pr->power.states[i].valid) { 707 - seq_puts(seq, "<not supported>\n"); 708 - continue; 709 - } 710 - 711 - switch (pr->power.states[i].type) { 712 - case ACPI_STATE_C1: 713 - seq_printf(seq, "type[C1] "); 714 - break; 715 - case ACPI_STATE_C2: 716 - seq_printf(seq, "type[C2] "); 717 - break; 718 - case ACPI_STATE_C3: 719 - seq_printf(seq, "type[C3] "); 720 - break; 721 - default: 722 - seq_printf(seq, "type[--] "); 723 - break; 724 - } 725 - 726 - seq_puts(seq, "promotion[--] "); 727 - 728 - seq_puts(seq, "demotion[--] "); 729 - 730 - seq_printf(seq, "latency[%03d] usage[%08d] duration[%020Lu]\n", 731 - pr->power.states[i].latency, 732 - pr->power.states[i].usage, 733 - us_to_pm_timer_ticks(pr->power.states[i].time)); 734 - } 735 - 736 - end: 737 - return 0; 738 - } 739 - 740 - static int acpi_processor_power_open_fs(struct inode *inode, struct file *file) 741 - { 742 - return single_open(file, acpi_processor_power_seq_show, 743 - PDE(inode)->data); 744 - } 745 - 746 - static const struct file_operations acpi_processor_power_fops = { 747 - .owner = THIS_MODULE, 748 - .open = acpi_processor_power_open_fs, 749 - .read = seq_read, 750 - .llseek = seq_lseek, 751 - .release = single_release, 752 - }; 753 - #endif 754 - 755 /** 756 * acpi_idle_bm_check - checks if bus master activity was detected 757 */ ··· 722 } else if (cx->entry_method == ACPI_CSTATE_HALT) { 723 acpi_safe_halt(); 724 } else { 725 - int unused; 726 /* IO port based C-state */ 727 inb(cx->address); 728 /* Dummy wait op - must do something useless after P_LVL2 read 729 because chipsets cannot guarantee that STPCLK# signal 730 gets asserted in time to freeze execution properly. */ 731 - unused = inl(acpi_gbl_FADT.xpm_timer_block.address); 732 } 733 start_critical_timings(); 734 } ··· 1090 { 1091 acpi_status status = 0; 1092 static int first_run; 1093 - #ifdef CONFIG_ACPI_PROCFS 1094 - struct proc_dir_entry *entry = NULL; 1095 - #endif 1096 1097 if (boot_option_idle_override) 1098 return 0; ··· 1138 if (cpuidle_register_device(&pr->power.dev)) 1139 return -EIO; 1140 } 1141 - #ifdef CONFIG_ACPI_PROCFS 1142 - /* 'power' [R] */ 1143 - entry = proc_create_data(ACPI_PROCESSOR_FILE_POWER, 1144 - S_IRUGO, acpi_device_dir(device), 1145 - &acpi_processor_power_fops, 1146 - acpi_driver_data(device)); 1147 - if (!entry) 1148 - return -EIO; 1149 - #endif 1150 return 0; 1151 } 1152 ··· 1149 1150 cpuidle_unregister_device(&pr->power.dev); 1151 pr->flags.power_setup_done = 0; 1152 - 1153 - #ifdef CONFIG_ACPI_PROCFS 1154 - if (acpi_device_dir(device)) 1155 - remove_proc_entry(ACPI_PROCESSOR_FILE_POWER, 1156 - acpi_device_dir(device)); 1157 - #endif 1158 1159 return 0; 1160 }
··· 33 #include <linux/init.h> 34 #include <linux/cpufreq.h> 35 #include <linux/slab.h> 36 #include <linux/acpi.h> 37 #include <linux/dmi.h> 38 #include <linux/moduleparam.h> ··· 81 82 static unsigned int latency_factor __read_mostly = 2; 83 module_param(latency_factor, uint, 0644); 84 85 /* 86 * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3. ··· 689 return 0; 690 } 691 692 /** 693 * acpi_idle_bm_check - checks if bus master activity was detected 694 */ ··· 803 } else if (cx->entry_method == ACPI_CSTATE_HALT) { 804 acpi_safe_halt(); 805 } else { 806 /* IO port based C-state */ 807 inb(cx->address); 808 /* Dummy wait op - must do something useless after P_LVL2 read 809 because chipsets cannot guarantee that STPCLK# signal 810 gets asserted in time to freeze execution properly. */ 811 + inl(acpi_gbl_FADT.xpm_timer_block.address); 812 } 813 start_critical_timings(); 814 } ··· 1172 { 1173 acpi_status status = 0; 1174 static int first_run; 1175 1176 if (boot_option_idle_override) 1177 return 0; ··· 1223 if (cpuidle_register_device(&pr->power.dev)) 1224 return -EIO; 1225 } 1226 return 0; 1227 } 1228 ··· 1243 1244 cpuidle_unregister_device(&pr->power.dev); 1245 pr->flags.power_setup_done = 0; 1246 1247 return 0; 1248 }
-83
drivers/acpi/processor_thermal.c
··· 30 #include <linux/module.h> 31 #include <linux/init.h> 32 #include <linux/cpufreq.h> 33 - #include <linux/proc_fs.h> 34 - #include <linux/seq_file.h> 35 #include <linux/sysdev.h> 36 37 #include <asm/uaccess.h> ··· 436 .get_cur_state = processor_get_cur_state, 437 .set_cur_state = processor_set_cur_state, 438 }; 439 - 440 - /* /proc interface */ 441 - #ifdef CONFIG_ACPI_PROCFS 442 - static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset) 443 - { 444 - struct acpi_processor *pr = seq->private; 445 - 446 - if (!pr) 447 - goto end; 448 - 449 - if (!pr->flags.limit) { 450 - seq_puts(seq, "<not supported>\n"); 451 - goto end; 452 - } 453 - 454 - seq_printf(seq, "active limit: P%d:T%d\n" 455 - "user limit: P%d:T%d\n" 456 - "thermal limit: P%d:T%d\n", 457 - pr->limit.state.px, pr->limit.state.tx, 458 - pr->limit.user.px, pr->limit.user.tx, 459 - pr->limit.thermal.px, pr->limit.thermal.tx); 460 - 461 - end: 462 - return 0; 463 - } 464 - 465 - static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file) 466 - { 467 - return single_open(file, acpi_processor_limit_seq_show, 468 - PDE(inode)->data); 469 - } 470 - 471 - static ssize_t acpi_processor_write_limit(struct file * file, 472 - const char __user * buffer, 473 - size_t count, loff_t * data) 474 - { 475 - int result = 0; 476 - struct seq_file *m = file->private_data; 477 - struct acpi_processor *pr = m->private; 478 - char limit_string[25] = { '\0' }; 479 - int px = 0; 480 - int tx = 0; 481 - 482 - 483 - if (!pr || (count > sizeof(limit_string) - 1)) { 484 - return -EINVAL; 485 - } 486 - 487 - if (copy_from_user(limit_string, buffer, count)) { 488 - return -EFAULT; 489 - } 490 - 491 - limit_string[count] = '\0'; 492 - 493 - if (sscanf(limit_string, "%d:%d", &px, &tx) != 2) { 494 - printk(KERN_ERR PREFIX "Invalid data format\n"); 495 - return -EINVAL; 496 - } 497 - 498 - if (pr->flags.throttling) { 499 - if ((tx < 0) || (tx > (pr->throttling.state_count - 1))) { 500 - printk(KERN_ERR PREFIX "Invalid tx\n"); 501 - return -EINVAL; 502 - } 503 - pr->limit.user.tx = tx; 504 - } 505 - 506 - result = acpi_processor_apply_limit(pr); 507 - 508 - return count; 509 - } 510 - 511 - const struct file_operations acpi_processor_limit_fops = { 512 - .owner = THIS_MODULE, 513 - .open = acpi_processor_limit_open_fs, 514 - .read = seq_read, 515 - .write = acpi_processor_write_limit, 516 - .llseek = seq_lseek, 517 - .release = single_release, 518 - }; 519 - #endif
··· 30 #include <linux/module.h> 31 #include <linux/init.h> 32 #include <linux/cpufreq.h> 33 #include <linux/sysdev.h> 34 35 #include <asm/uaccess.h> ··· 438 .get_cur_state = processor_get_cur_state, 439 .set_cur_state = processor_set_cur_state, 440 };
-2
drivers/acpi/processor_throttling.c
··· 1215 } 1216 1217 /* proc interface */ 1218 - #ifdef CONFIG_ACPI_PROCFS 1219 static int acpi_processor_throttling_seq_show(struct seq_file *seq, 1220 void *offset) 1221 { ··· 1322 .llseek = seq_lseek, 1323 .release = single_release, 1324 }; 1325 - #endif
··· 1215 } 1216 1217 /* proc interface */ 1218 static int acpi_processor_throttling_seq_show(struct seq_file *seq, 1219 void *offset) 1220 { ··· 1323 .llseek = seq_lseek, 1324 .release = single_release, 1325 };
+21 -39
drivers/acpi/sleep.c
··· 70 71 } 72 ACPI_FLUSH_CPU_CACHE(); 73 - acpi_enable_wakeup_device_prep(acpi_state); 74 #endif 75 printk(KERN_INFO PREFIX "Preparing to enter system sleep state S%d\n", 76 acpi_state); 77 acpi_enter_sleep_state_prep(acpi_state); 78 return 0; 79 } ··· 119 } 120 121 /** 122 * __acpi_pm_prepare - Prepare the platform to enter the target state. 123 * 124 * If necessary, set the firmware waking vector and do arch-specific ··· 137 static int __acpi_pm_prepare(void) 138 { 139 int error = acpi_sleep_prepare(acpi_target_sleep_state); 140 - 141 - suspend_nvs_save(); 142 - 143 if (error) 144 acpi_target_sleep_state = ACPI_STATE_S0; 145 return error; 146 } 147 ··· 150 static int acpi_pm_prepare(void) 151 { 152 int error = __acpi_pm_prepare(); 153 - 154 if (!error) 155 - acpi_pm_freeze(); 156 157 return error; 158 } ··· 166 { 167 u32 acpi_state = acpi_target_sleep_state; 168 169 - suspend_nvs_free(); 170 acpi_ec_unblock_transactions(); 171 172 if (acpi_state == ACPI_STATE_S0) ··· 173 174 printk(KERN_INFO PREFIX "Waking up from system sleep state S%d\n", 175 acpi_state); 176 - acpi_disable_wakeup_device(acpi_state); 177 acpi_leave_sleep_state(acpi_state); 178 179 /* reset firmware waking vector */ ··· 187 */ 188 static void acpi_pm_end(void) 189 { 190 /* 191 * This is necessary in case acpi_pm_finish() is not called during a 192 * failing transition to a sleep state. ··· 258 } 259 260 local_irq_save(flags); 261 - acpi_enable_wakeup_device(acpi_state); 262 switch (acpi_state) { 263 case ACPI_STATE_S1: 264 barrier(); ··· 303 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 304 } 305 306 - static void acpi_suspend_finish(void) 307 - { 308 - acpi_pm_finish(); 309 - } 310 - 311 static int acpi_suspend_state_valid(suspend_state_t pm_state) 312 { 313 u32 acpi_state; ··· 324 .begin = acpi_suspend_begin, 325 .prepare_late = acpi_pm_prepare, 326 .enter = acpi_suspend_enter, 327 - .wake = acpi_suspend_finish, 328 .end = acpi_pm_end, 329 }; 330 ··· 337 static int acpi_suspend_begin_old(suspend_state_t pm_state) 338 { 339 int error = acpi_suspend_begin(pm_state); 340 - 341 if (!error) 342 error = __acpi_pm_prepare(); 343 return error; 344 } 345 ··· 350 static struct platform_suspend_ops acpi_suspend_ops_old = { 351 .valid = acpi_suspend_state_valid, 352 .begin = acpi_suspend_begin_old, 353 - .prepare_late = acpi_pm_freeze, 354 .enter = acpi_suspend_enter, 355 - .wake = acpi_suspend_finish, 356 .end = acpi_pm_end, 357 .recover = acpi_pm_finish, 358 }; ··· 424 return error; 425 } 426 427 - static int acpi_hibernation_pre_snapshot(void) 428 - { 429 - int error = acpi_pm_prepare(); 430 - 431 - if (!error) 432 - suspend_nvs_save(); 433 - 434 - return error; 435 - } 436 - 437 static int acpi_hibernation_enter(void) 438 { 439 acpi_status status = AE_OK; ··· 432 ACPI_FLUSH_CPU_CACHE(); 433 434 local_irq_save(flags); 435 - acpi_enable_wakeup_device(ACPI_STATE_S4); 436 /* This shouldn't return. If it returns, we have a problem */ 437 status = acpi_enter_sleep_state(ACPI_STATE_S4); 438 /* Reprogram control registers and execute _BFS */ ··· 471 static struct platform_hibernation_ops acpi_hibernation_ops = { 472 .begin = acpi_hibernation_begin, 473 .end = acpi_pm_end, 474 - .pre_snapshot = acpi_hibernation_pre_snapshot, 475 .finish = acpi_pm_finish, 476 .prepare = acpi_pm_prepare, 477 .enter = acpi_hibernation_enter, ··· 507 return error; 508 } 509 510 - static int acpi_hibernation_pre_snapshot_old(void) 511 - { 512 - acpi_pm_freeze(); 513 - suspend_nvs_save(); 514 - return 0; 515 - } 516 - 517 /* 518 * The following callbacks are used if the pre-ACPI 2.0 suspend ordering has 519 * been requested. ··· 514 static struct platform_hibernation_ops acpi_hibernation_ops_old = { 515 .begin = acpi_hibernation_begin_old, 516 .end = acpi_pm_end, 517 - .pre_snapshot = acpi_hibernation_pre_snapshot_old, 518 .prepare = acpi_pm_freeze, 519 .finish = acpi_pm_finish, 520 .enter = acpi_hibernation_enter, ··· 669 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ 670 printk(KERN_DEBUG "%s called\n", __func__); 671 local_irq_disable(); 672 - acpi_enable_wakeup_device(ACPI_STATE_S5); 673 acpi_enter_sleep_state(ACPI_STATE_S5); 674 } 675
··· 70 71 } 72 ACPI_FLUSH_CPU_CACHE(); 73 #endif 74 printk(KERN_INFO PREFIX "Preparing to enter system sleep state S%d\n", 75 acpi_state); 76 + acpi_enable_wakeup_devices(acpi_state); 77 acpi_enter_sleep_state_prep(acpi_state); 78 return 0; 79 } ··· 119 } 120 121 /** 122 + * acpi_pre_suspend - Enable wakeup devices, "freeze" EC and save NVS. 123 + */ 124 + static int acpi_pm_pre_suspend(void) 125 + { 126 + acpi_pm_freeze(); 127 + suspend_nvs_save(); 128 + return 0; 129 + } 130 + 131 + /** 132 * __acpi_pm_prepare - Prepare the platform to enter the target state. 133 * 134 * If necessary, set the firmware waking vector and do arch-specific ··· 127 static int __acpi_pm_prepare(void) 128 { 129 int error = acpi_sleep_prepare(acpi_target_sleep_state); 130 if (error) 131 acpi_target_sleep_state = ACPI_STATE_S0; 132 + 133 return error; 134 } 135 ··· 142 static int acpi_pm_prepare(void) 143 { 144 int error = __acpi_pm_prepare(); 145 if (!error) 146 + acpi_pm_pre_suspend(); 147 148 return error; 149 } ··· 159 { 160 u32 acpi_state = acpi_target_sleep_state; 161 162 acpi_ec_unblock_transactions(); 163 164 if (acpi_state == ACPI_STATE_S0) ··· 167 168 printk(KERN_INFO PREFIX "Waking up from system sleep state S%d\n", 169 acpi_state); 170 + acpi_disable_wakeup_devices(acpi_state); 171 acpi_leave_sleep_state(acpi_state); 172 173 /* reset firmware waking vector */ ··· 181 */ 182 static void acpi_pm_end(void) 183 { 184 + suspend_nvs_free(); 185 /* 186 * This is necessary in case acpi_pm_finish() is not called during a 187 * failing transition to a sleep state. ··· 251 } 252 253 local_irq_save(flags); 254 switch (acpi_state) { 255 case ACPI_STATE_S1: 256 barrier(); ··· 297 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 298 } 299 300 static int acpi_suspend_state_valid(suspend_state_t pm_state) 301 { 302 u32 acpi_state; ··· 323 .begin = acpi_suspend_begin, 324 .prepare_late = acpi_pm_prepare, 325 .enter = acpi_suspend_enter, 326 + .wake = acpi_pm_finish, 327 .end = acpi_pm_end, 328 }; 329 ··· 336 static int acpi_suspend_begin_old(suspend_state_t pm_state) 337 { 338 int error = acpi_suspend_begin(pm_state); 339 if (!error) 340 error = __acpi_pm_prepare(); 341 + 342 return error; 343 } 344 ··· 349 static struct platform_suspend_ops acpi_suspend_ops_old = { 350 .valid = acpi_suspend_state_valid, 351 .begin = acpi_suspend_begin_old, 352 + .prepare_late = acpi_pm_pre_suspend, 353 .enter = acpi_suspend_enter, 354 + .wake = acpi_pm_finish, 355 .end = acpi_pm_end, 356 .recover = acpi_pm_finish, 357 }; ··· 423 return error; 424 } 425 426 static int acpi_hibernation_enter(void) 427 { 428 acpi_status status = AE_OK; ··· 441 ACPI_FLUSH_CPU_CACHE(); 442 443 local_irq_save(flags); 444 /* This shouldn't return. If it returns, we have a problem */ 445 status = acpi_enter_sleep_state(ACPI_STATE_S4); 446 /* Reprogram control registers and execute _BFS */ ··· 481 static struct platform_hibernation_ops acpi_hibernation_ops = { 482 .begin = acpi_hibernation_begin, 483 .end = acpi_pm_end, 484 + .pre_snapshot = acpi_pm_prepare, 485 .finish = acpi_pm_finish, 486 .prepare = acpi_pm_prepare, 487 .enter = acpi_hibernation_enter, ··· 517 return error; 518 } 519 520 /* 521 * The following callbacks are used if the pre-ACPI 2.0 suspend ordering has 522 * been requested. ··· 531 static struct platform_hibernation_ops acpi_hibernation_ops_old = { 532 .begin = acpi_hibernation_begin_old, 533 .end = acpi_pm_end, 534 + .pre_snapshot = acpi_pm_pre_suspend, 535 .prepare = acpi_pm_freeze, 536 .finish = acpi_pm_finish, 537 .enter = acpi_hibernation_enter, ··· 686 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ 687 printk(KERN_DEBUG "%s called\n", __func__); 688 local_irq_disable(); 689 acpi_enter_sleep_state(ACPI_STATE_S5); 690 } 691
+2 -3
drivers/acpi/sleep.h
··· 2 extern u8 sleep_states[]; 3 extern int acpi_suspend(u32 state); 4 5 - extern void acpi_enable_wakeup_device_prep(u8 sleep_state); 6 - extern void acpi_enable_wakeup_device(u8 sleep_state); 7 - extern void acpi_disable_wakeup_device(u8 sleep_state); 8 9 extern struct list_head acpi_wakeup_device_list; 10 extern struct mutex acpi_device_lock;
··· 2 extern u8 sleep_states[]; 3 extern int acpi_suspend(u32 state); 4 5 + extern void acpi_enable_wakeup_devices(u8 sleep_state); 6 + extern void acpi_disable_wakeup_devices(u8 sleep_state); 7 8 extern struct list_head acpi_wakeup_device_list; 9 extern struct mutex acpi_device_lock;
+258 -210
drivers/acpi/system.c drivers/acpi/sysfs.c
··· 1 /* 2 - * acpi_system.c - ACPI System Driver ($Revision: 63 $) 3 - * 4 - * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> 5 - * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 6 - * 7 - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8 - * 9 - * This program is free software; you can redistribute it and/or modify 10 - * it under the terms of the GNU General Public License as published by 11 - * the Free Software Foundation; either version 2 of the License, or (at 12 - * your option) any later version. 13 - * 14 - * This program is distributed in the hope that it will be useful, but 15 - * WITHOUT ANY WARRANTY; without even the implied warranty of 16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 - * General Public License for more details. 18 - * 19 - * You should have received a copy of the GNU General Public License along 20 - * with this program; if not, write to the Free Software Foundation, Inc., 21 - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 22 - * 23 - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 24 */ 25 26 - #include <linux/proc_fs.h> 27 - #include <linux/seq_file.h> 28 - #include <linux/slab.h> 29 #include <linux/init.h> 30 - #include <linux/string.h> 31 - #include <asm/uaccess.h> 32 - 33 #include <acpi/acpi_drivers.h> 34 35 #define PREFIX "ACPI: " 36 37 - #define _COMPONENT ACPI_SYSTEM_COMPONENT 38 - ACPI_MODULE_NAME("system"); 39 - 40 - #define ACPI_SYSTEM_CLASS "system" 41 - #define ACPI_SYSTEM_DEVICE_NAME "System" 42 - 43 - u32 acpi_irq_handled; 44 - u32 acpi_irq_not_handled; 45 - 46 /* 47 - * Make ACPICA version work as module param 48 */ 49 static int param_get_acpica_version(char *buffer, struct kernel_param *kp) 50 { 51 int result; ··· 224 225 module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444); 226 227 - /* -------------------------------------------------------------------------- 228 - FS Interface (/sys) 229 - -------------------------------------------------------------------------- */ 230 static LIST_HEAD(acpi_table_attr_list); 231 static struct kobject *tables_kobj; 232 static struct kobject *dynamic_tables_kobj; ··· 256 else 257 memcpy(name, "\0\0\0\0", 4); 258 259 - status = 260 - acpi_get_table(name, table_attr->instance, 261 - &table_header); 262 if (ACPI_FAILURE(status)) 263 return -ENODEV; 264 265 return memory_read_from_buffer(buf, count, &offset, 266 - table_header, table_header->length); 267 } 268 269 static void acpi_table_attr_init(struct acpi_table_attr *table_attr, ··· 273 sysfs_attr_init(&table_attr->attr.attr); 274 if (table_header->signature[0] != '\0') 275 memcpy(table_attr->name, table_header->signature, 276 - ACPI_NAME_SIZE); 277 else 278 memcpy(table_attr->name, "NULL", 4); 279 ··· 285 table_attr->instance++; 286 287 if (table_attr->instance > 1 || (table_attr->instance == 1 && 288 - !acpi_get_table 289 - (table_header->signature, 2, &header))) 290 sprintf(table_attr->name + ACPI_NAME_SIZE, "%d", 291 table_attr->instance); 292 ··· 306 switch (event) { 307 case ACPI_TABLE_EVENT_LOAD: 308 table_attr = 309 - kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL); 310 if (!table_attr) 311 return AE_NO_MEMORY; 312 313 acpi_table_attr_init(table_attr, table); 314 if (sysfs_create_bin_file(dynamic_tables_kobj, 315 - &table_attr->attr)) { 316 kfree(table_attr); 317 return AE_ERROR; 318 } else 319 - list_add_tail(&table_attr->node, 320 - &acpi_table_attr_list); 321 break; 322 case ACPI_TABLE_EVENT_UNLOAD: 323 /* ··· 331 return AE_OK; 332 } 333 334 - static int acpi_system_sysfs_init(void) 335 { 336 struct acpi_table_attr *table_attr; 337 struct acpi_table_header *table_header = NULL; ··· 380 } 381 382 /* 383 - * Detailed ACPI IRQ counters in /sys/firmware/acpi/interrupts/ 384 - * See Documentation/ABI/testing/sysfs-firmware-acpi 385 */ 386 387 #define COUNT_GPE 0 388 - #define COUNT_SCI 1 /* acpi_irq_handled */ 389 - #define COUNT_SCI_NOT 2 /* acpi_irq_not_handled */ 390 - #define COUNT_ERROR 3 /* other */ 391 #define NUM_COUNTERS_EXTRA 4 392 393 struct event_counter { ··· 407 static struct attribute_group interrupt_stats_attr_group = { 408 .name = "interrupts", 409 }; 410 static struct kobj_attribute *counter_attrs; 411 412 static void delete_gpe_attr_array(void) ··· 440 if (gpe_number < num_gpes) 441 all_counters[gpe_number].count++; 442 else 443 - all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_ERROR]. 444 - count++; 445 446 return; 447 } ··· 454 if (event_number < ACPI_NUM_FIXED_EVENTS) 455 all_counters[num_gpes + event_number].count++; 456 else 457 - all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_ERROR]. 458 - count++; 459 460 return; 461 } 462 463 - static int get_status(u32 index, acpi_event_status *status, acpi_handle *handle) 464 { 465 int result = 0; 466 ··· 472 result = acpi_get_gpe_device(index, handle); 473 if (result) { 474 ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND, 475 - "Invalid GPE 0x%x\n", index)); 476 goto end; 477 } 478 result = acpi_get_gpe_status(*handle, index, status); ··· 484 } 485 486 static ssize_t counter_show(struct kobject *kobj, 487 - struct kobj_attribute *attr, char *buf) 488 { 489 int index = attr - counter_attrs; 490 int size; ··· 493 int result = 0; 494 495 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI].count = 496 - acpi_irq_handled; 497 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI_NOT].count = 498 - acpi_irq_not_handled; 499 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE].count = 500 - acpi_gpe_count; 501 - 502 size = sprintf(buf, "%8d", all_counters[index].count); 503 504 /* "gpe_all" or "sci" */ ··· 509 goto end; 510 511 if (!(status & ACPI_EVENT_FLAG_HANDLE)) 512 - size += sprintf(buf + size, " invalid"); 513 else if (status & ACPI_EVENT_FLAG_ENABLED) 514 - size += sprintf(buf + size, " enabled"); 515 else if (status & ACPI_EVENT_FLAG_WAKE_ENABLED) 516 - size += sprintf(buf + size, " wake_enabled"); 517 else 518 - size += sprintf(buf + size, " disabled"); 519 520 end: 521 size += sprintf(buf + size, "\n"); ··· 528 * enable/disable/clear a gpe/fixed event in user space. 529 */ 530 static ssize_t counter_set(struct kobject *kobj, 531 - struct kobj_attribute *attr, const char *buf, size_t size) 532 { 533 int index = attr - counter_attrs; 534 acpi_event_status status; ··· 553 554 if (!(status & ACPI_EVENT_FLAG_HANDLE)) { 555 printk(KERN_WARNING PREFIX 556 - "Can not change Invalid GPE/Fixed Event status\n"); 557 return -EINVAL; 558 } 559 560 if (index < num_gpes) { 561 if (!strcmp(buf, "disable\n") && 562 - (status & ACPI_EVENT_FLAG_ENABLED)) 563 result = acpi_disable_gpe(handle, index); 564 else if (!strcmp(buf, "enable\n") && 565 - !(status & ACPI_EVENT_FLAG_ENABLED)) 566 result = acpi_enable_gpe(handle, index); 567 else if (!strcmp(buf, "clear\n") && 568 - (status & ACPI_EVENT_FLAG_SET)) 569 result = acpi_clear_gpe(handle, index); 570 else 571 all_counters[index].count = strtoul(buf, NULL, 0); 572 } else if (index < num_gpes + ACPI_NUM_FIXED_EVENTS) { 573 int event = index - num_gpes; 574 if (!strcmp(buf, "disable\n") && 575 - (status & ACPI_EVENT_FLAG_ENABLED)) 576 result = acpi_disable_event(event, ACPI_NOT_ISR); 577 else if (!strcmp(buf, "enable\n") && 578 - !(status & ACPI_EVENT_FLAG_ENABLED)) 579 result = acpi_enable_event(event, ACPI_NOT_ISR); 580 else if (!strcmp(buf, "clear\n") && 581 - (status & ACPI_EVENT_FLAG_SET)) 582 result = acpi_clear_event(event); 583 else 584 all_counters[index].count = strtoul(buf, NULL, 0); ··· 602 num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA; 603 604 all_attrs = kzalloc(sizeof(struct attribute *) * (num_counters + 1), 605 - GFP_KERNEL); 606 if (all_attrs == NULL) 607 return; 608 609 all_counters = kzalloc(sizeof(struct event_counter) * (num_counters), 610 - GFP_KERNEL); 611 if (all_counters == NULL) 612 goto fail; 613 614 counter_attrs = kzalloc(sizeof(struct kobj_attribute) * (num_counters), 615 - GFP_KERNEL); 616 if (counter_attrs == NULL) 617 goto fail; 618 ··· 675 return; 676 } 677 678 - /* -------------------------------------------------------------------------- 679 - FS Interface (/proc) 680 - -------------------------------------------------------------------------- */ 681 - #ifdef CONFIG_ACPI_PROCFS 682 - #define ACPI_SYSTEM_FILE_INFO "info" 683 - #define ACPI_SYSTEM_FILE_EVENT "event" 684 - #define ACPI_SYSTEM_FILE_DSDT "dsdt" 685 - #define ACPI_SYSTEM_FILE_FADT "fadt" 686 - 687 - static int acpi_system_read_info(struct seq_file *seq, void *offset) 688 - { 689 - 690 - seq_printf(seq, "version: %x\n", ACPI_CA_VERSION); 691 - return 0; 692 - } 693 - 694 - static int acpi_system_info_open_fs(struct inode *inode, struct file *file) 695 - { 696 - return single_open(file, acpi_system_read_info, PDE(inode)->data); 697 - } 698 - 699 - static const struct file_operations acpi_system_info_ops = { 700 - .owner = THIS_MODULE, 701 - .open = acpi_system_info_open_fs, 702 - .read = seq_read, 703 - .llseek = seq_lseek, 704 - .release = single_release, 705 - }; 706 - 707 - static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t, 708 - loff_t *); 709 - 710 - static const struct file_operations acpi_system_dsdt_ops = { 711 - .owner = THIS_MODULE, 712 - .read = acpi_system_read_dsdt, 713 - }; 714 - 715 - static ssize_t 716 - acpi_system_read_dsdt(struct file *file, 717 - char __user * buffer, size_t count, loff_t * ppos) 718 - { 719 - acpi_status status = AE_OK; 720 - struct acpi_table_header *dsdt = NULL; 721 - ssize_t res; 722 - 723 - status = acpi_get_table(ACPI_SIG_DSDT, 1, &dsdt); 724 - if (ACPI_FAILURE(status)) 725 - return -ENODEV; 726 - 727 - res = simple_read_from_buffer(buffer, count, ppos, dsdt, dsdt->length); 728 - 729 - return res; 730 - } 731 - 732 - static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t, 733 - loff_t *); 734 - 735 - static const struct file_operations acpi_system_fadt_ops = { 736 - .owner = THIS_MODULE, 737 - .read = acpi_system_read_fadt, 738 - }; 739 - 740 - static ssize_t 741 - acpi_system_read_fadt(struct file *file, 742 - char __user * buffer, size_t count, loff_t * ppos) 743 - { 744 - acpi_status status = AE_OK; 745 - struct acpi_table_header *fadt = NULL; 746 - ssize_t res; 747 - 748 - status = acpi_get_table(ACPI_SIG_FADT, 1, &fadt); 749 - if (ACPI_FAILURE(status)) 750 - return -ENODEV; 751 - 752 - res = simple_read_from_buffer(buffer, count, ppos, fadt, fadt->length); 753 - 754 - return res; 755 - } 756 - 757 - static int acpi_system_procfs_init(void) 758 - { 759 - struct proc_dir_entry *entry; 760 - int error = 0; 761 - 762 - /* 'info' [R] */ 763 - entry = proc_create(ACPI_SYSTEM_FILE_INFO, S_IRUGO, acpi_root_dir, 764 - &acpi_system_info_ops); 765 - if (!entry) 766 - goto Error; 767 - 768 - /* 'dsdt' [R] */ 769 - entry = proc_create(ACPI_SYSTEM_FILE_DSDT, S_IRUSR, acpi_root_dir, 770 - &acpi_system_dsdt_ops); 771 - if (!entry) 772 - goto Error; 773 - 774 - /* 'fadt' [R] */ 775 - entry = proc_create(ACPI_SYSTEM_FILE_FADT, S_IRUSR, acpi_root_dir, 776 - &acpi_system_fadt_ops); 777 - if (!entry) 778 - goto Error; 779 - 780 - Done: 781 - return error; 782 - 783 - Error: 784 - remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir); 785 - remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir); 786 - remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir); 787 - 788 - error = -EFAULT; 789 - goto Done; 790 - } 791 - #else 792 - static int acpi_system_procfs_init(void) 793 - { 794 - return 0; 795 - } 796 - #endif 797 - 798 - int __init acpi_system_init(void) 799 { 800 int result; 801 802 - result = acpi_system_procfs_init(); 803 - if (result) 804 - return result; 805 - 806 - result = acpi_system_sysfs_init(); 807 808 return result; 809 }
··· 1 /* 2 + * sysfs.c - ACPI sysfs interface to userspace. 3 */ 4 5 #include <linux/init.h> 6 + #include <linux/kernel.h> 7 + #include <linux/moduleparam.h> 8 #include <acpi/acpi_drivers.h> 9 + 10 + #define _COMPONENT ACPI_SYSTEM_COMPONENT 11 + ACPI_MODULE_NAME("sysfs"); 12 13 #define PREFIX "ACPI: " 14 15 + #ifdef CONFIG_ACPI_DEBUG 16 /* 17 + * ACPI debug sysfs I/F, including: 18 + * /sys/modules/acpi/parameters/debug_layer 19 + * /sys/modules/acpi/parameters/debug_level 20 + * /sys/modules/acpi/parameters/trace_method_name 21 + * /sys/modules/acpi/parameters/trace_state 22 + * /sys/modules/acpi/parameters/trace_debug_layer 23 + * /sys/modules/acpi/parameters/trace_debug_level 24 */ 25 + 26 + struct acpi_dlayer { 27 + const char *name; 28 + unsigned long value; 29 + }; 30 + struct acpi_dlevel { 31 + const char *name; 32 + unsigned long value; 33 + }; 34 + #define ACPI_DEBUG_INIT(v) { .name = #v, .value = v } 35 + 36 + static const struct acpi_dlayer acpi_debug_layers[] = { 37 + ACPI_DEBUG_INIT(ACPI_UTILITIES), 38 + ACPI_DEBUG_INIT(ACPI_HARDWARE), 39 + ACPI_DEBUG_INIT(ACPI_EVENTS), 40 + ACPI_DEBUG_INIT(ACPI_TABLES), 41 + ACPI_DEBUG_INIT(ACPI_NAMESPACE), 42 + ACPI_DEBUG_INIT(ACPI_PARSER), 43 + ACPI_DEBUG_INIT(ACPI_DISPATCHER), 44 + ACPI_DEBUG_INIT(ACPI_EXECUTER), 45 + ACPI_DEBUG_INIT(ACPI_RESOURCES), 46 + ACPI_DEBUG_INIT(ACPI_CA_DEBUGGER), 47 + ACPI_DEBUG_INIT(ACPI_OS_SERVICES), 48 + ACPI_DEBUG_INIT(ACPI_CA_DISASSEMBLER), 49 + ACPI_DEBUG_INIT(ACPI_COMPILER), 50 + ACPI_DEBUG_INIT(ACPI_TOOLS), 51 + 52 + ACPI_DEBUG_INIT(ACPI_BUS_COMPONENT), 53 + ACPI_DEBUG_INIT(ACPI_AC_COMPONENT), 54 + ACPI_DEBUG_INIT(ACPI_BATTERY_COMPONENT), 55 + ACPI_DEBUG_INIT(ACPI_BUTTON_COMPONENT), 56 + ACPI_DEBUG_INIT(ACPI_SBS_COMPONENT), 57 + ACPI_DEBUG_INIT(ACPI_FAN_COMPONENT), 58 + ACPI_DEBUG_INIT(ACPI_PCI_COMPONENT), 59 + ACPI_DEBUG_INIT(ACPI_POWER_COMPONENT), 60 + ACPI_DEBUG_INIT(ACPI_CONTAINER_COMPONENT), 61 + ACPI_DEBUG_INIT(ACPI_SYSTEM_COMPONENT), 62 + ACPI_DEBUG_INIT(ACPI_THERMAL_COMPONENT), 63 + ACPI_DEBUG_INIT(ACPI_MEMORY_DEVICE_COMPONENT), 64 + ACPI_DEBUG_INIT(ACPI_VIDEO_COMPONENT), 65 + ACPI_DEBUG_INIT(ACPI_PROCESSOR_COMPONENT), 66 + }; 67 + 68 + static const struct acpi_dlevel acpi_debug_levels[] = { 69 + ACPI_DEBUG_INIT(ACPI_LV_INIT), 70 + ACPI_DEBUG_INIT(ACPI_LV_DEBUG_OBJECT), 71 + ACPI_DEBUG_INIT(ACPI_LV_INFO), 72 + 73 + ACPI_DEBUG_INIT(ACPI_LV_INIT_NAMES), 74 + ACPI_DEBUG_INIT(ACPI_LV_PARSE), 75 + ACPI_DEBUG_INIT(ACPI_LV_LOAD), 76 + ACPI_DEBUG_INIT(ACPI_LV_DISPATCH), 77 + ACPI_DEBUG_INIT(ACPI_LV_EXEC), 78 + ACPI_DEBUG_INIT(ACPI_LV_NAMES), 79 + ACPI_DEBUG_INIT(ACPI_LV_OPREGION), 80 + ACPI_DEBUG_INIT(ACPI_LV_BFIELD), 81 + ACPI_DEBUG_INIT(ACPI_LV_TABLES), 82 + ACPI_DEBUG_INIT(ACPI_LV_VALUES), 83 + ACPI_DEBUG_INIT(ACPI_LV_OBJECTS), 84 + ACPI_DEBUG_INIT(ACPI_LV_RESOURCES), 85 + ACPI_DEBUG_INIT(ACPI_LV_USER_REQUESTS), 86 + ACPI_DEBUG_INIT(ACPI_LV_PACKAGE), 87 + 88 + ACPI_DEBUG_INIT(ACPI_LV_ALLOCATIONS), 89 + ACPI_DEBUG_INIT(ACPI_LV_FUNCTIONS), 90 + ACPI_DEBUG_INIT(ACPI_LV_OPTIMIZATIONS), 91 + 92 + ACPI_DEBUG_INIT(ACPI_LV_MUTEX), 93 + ACPI_DEBUG_INIT(ACPI_LV_THREADS), 94 + ACPI_DEBUG_INIT(ACPI_LV_IO), 95 + ACPI_DEBUG_INIT(ACPI_LV_INTERRUPTS), 96 + 97 + ACPI_DEBUG_INIT(ACPI_LV_AML_DISASSEMBLE), 98 + ACPI_DEBUG_INIT(ACPI_LV_VERBOSE_INFO), 99 + ACPI_DEBUG_INIT(ACPI_LV_FULL_TABLES), 100 + ACPI_DEBUG_INIT(ACPI_LV_EVENTS), 101 + }; 102 + 103 + static int param_get_debug_layer(char *buffer, struct kernel_param *kp) 104 + { 105 + int result = 0; 106 + int i; 107 + 108 + result = sprintf(buffer, "%-25s\tHex SET\n", "Description"); 109 + 110 + for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) { 111 + result += sprintf(buffer + result, "%-25s\t0x%08lX [%c]\n", 112 + acpi_debug_layers[i].name, 113 + acpi_debug_layers[i].value, 114 + (acpi_dbg_layer & acpi_debug_layers[i].value) 115 + ? '*' : ' '); 116 + } 117 + result += 118 + sprintf(buffer + result, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS", 119 + ACPI_ALL_DRIVERS, 120 + (acpi_dbg_layer & ACPI_ALL_DRIVERS) == 121 + ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer & ACPI_ALL_DRIVERS) 122 + == 0 ? ' ' : '-'); 123 + result += 124 + sprintf(buffer + result, 125 + "--\ndebug_layer = 0x%08X ( * = enabled)\n", 126 + acpi_dbg_layer); 127 + 128 + return result; 129 + } 130 + 131 + static int param_get_debug_level(char *buffer, struct kernel_param *kp) 132 + { 133 + int result = 0; 134 + int i; 135 + 136 + result = sprintf(buffer, "%-25s\tHex SET\n", "Description"); 137 + 138 + for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) { 139 + result += sprintf(buffer + result, "%-25s\t0x%08lX [%c]\n", 140 + acpi_debug_levels[i].name, 141 + acpi_debug_levels[i].value, 142 + (acpi_dbg_level & acpi_debug_levels[i].value) 143 + ? '*' : ' '); 144 + } 145 + result += 146 + sprintf(buffer + result, "--\ndebug_level = 0x%08X (* = enabled)\n", 147 + acpi_dbg_level); 148 + 149 + return result; 150 + } 151 + 152 + module_param_call(debug_layer, param_set_uint, param_get_debug_layer, 153 + &acpi_dbg_layer, 0644); 154 + module_param_call(debug_level, param_set_uint, param_get_debug_level, 155 + &acpi_dbg_level, 0644); 156 + 157 + static char trace_method_name[6]; 158 + module_param_string(trace_method_name, trace_method_name, 6, 0644); 159 + static unsigned int trace_debug_layer; 160 + module_param(trace_debug_layer, uint, 0644); 161 + static unsigned int trace_debug_level; 162 + module_param(trace_debug_level, uint, 0644); 163 + 164 + static int param_set_trace_state(const char *val, struct kernel_param *kp) 165 + { 166 + int result = 0; 167 + 168 + if (!strncmp(val, "enable", strlen("enable") - 1)) { 169 + result = acpi_debug_trace(trace_method_name, trace_debug_level, 170 + trace_debug_layer, 0); 171 + if (result) 172 + result = -EBUSY; 173 + goto exit; 174 + } 175 + 176 + if (!strncmp(val, "disable", strlen("disable") - 1)) { 177 + int name = 0; 178 + result = acpi_debug_trace((char *)&name, trace_debug_level, 179 + trace_debug_layer, 0); 180 + if (result) 181 + result = -EBUSY; 182 + goto exit; 183 + } 184 + 185 + if (!strncmp(val, "1", 1)) { 186 + result = acpi_debug_trace(trace_method_name, trace_debug_level, 187 + trace_debug_layer, 1); 188 + if (result) 189 + result = -EBUSY; 190 + goto exit; 191 + } 192 + 193 + result = -EINVAL; 194 + exit: 195 + return result; 196 + } 197 + 198 + static int param_get_trace_state(char *buffer, struct kernel_param *kp) 199 + { 200 + if (!acpi_gbl_trace_method_name) 201 + return sprintf(buffer, "disable"); 202 + else { 203 + if (acpi_gbl_trace_flags & 1) 204 + return sprintf(buffer, "1"); 205 + else 206 + return sprintf(buffer, "enable"); 207 + } 208 + return 0; 209 + } 210 + 211 + module_param_call(trace_state, param_set_trace_state, param_get_trace_state, 212 + NULL, 0644); 213 + #endif /* CONFIG_ACPI_DEBUG */ 214 + 215 + /* /sys/module/acpi/parameters/acpica_version */ 216 static int param_get_acpica_version(char *buffer, struct kernel_param *kp) 217 { 218 int result; ··· 57 58 module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444); 59 60 + /* 61 + * ACPI table sysfs I/F: 62 + * /sys/firmware/acpi/tables/ 63 + * /sys/firmware/acpi/tables/dynamic/ 64 + */ 65 + 66 static LIST_HEAD(acpi_table_attr_list); 67 static struct kobject *tables_kobj; 68 static struct kobject *dynamic_tables_kobj; ··· 86 else 87 memcpy(name, "\0\0\0\0", 4); 88 89 + status = acpi_get_table(name, table_attr->instance, &table_header); 90 if (ACPI_FAILURE(status)) 91 return -ENODEV; 92 93 return memory_read_from_buffer(buf, count, &offset, 94 + table_header, table_header->length); 95 } 96 97 static void acpi_table_attr_init(struct acpi_table_attr *table_attr, ··· 105 sysfs_attr_init(&table_attr->attr.attr); 106 if (table_header->signature[0] != '\0') 107 memcpy(table_attr->name, table_header->signature, 108 + ACPI_NAME_SIZE); 109 else 110 memcpy(table_attr->name, "NULL", 4); 111 ··· 117 table_attr->instance++; 118 119 if (table_attr->instance > 1 || (table_attr->instance == 1 && 120 + !acpi_get_table 121 + (table_header->signature, 2, &header))) 122 sprintf(table_attr->name + ACPI_NAME_SIZE, "%d", 123 table_attr->instance); 124 ··· 138 switch (event) { 139 case ACPI_TABLE_EVENT_LOAD: 140 table_attr = 141 + kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL); 142 if (!table_attr) 143 return AE_NO_MEMORY; 144 145 acpi_table_attr_init(table_attr, table); 146 if (sysfs_create_bin_file(dynamic_tables_kobj, 147 + &table_attr->attr)) { 148 kfree(table_attr); 149 return AE_ERROR; 150 } else 151 + list_add_tail(&table_attr->node, &acpi_table_attr_list); 152 break; 153 case ACPI_TABLE_EVENT_UNLOAD: 154 /* ··· 164 return AE_OK; 165 } 166 167 + static int acpi_tables_sysfs_init(void) 168 { 169 struct acpi_table_attr *table_attr; 170 struct acpi_table_header *table_header = NULL; ··· 213 } 214 215 /* 216 + * Detailed ACPI IRQ counters: 217 + * /sys/firmware/acpi/interrupts/ 218 */ 219 220 + u32 acpi_irq_handled; 221 + u32 acpi_irq_not_handled; 222 + 223 #define COUNT_GPE 0 224 + #define COUNT_SCI 1 /* acpi_irq_handled */ 225 + #define COUNT_SCI_NOT 2 /* acpi_irq_not_handled */ 226 + #define COUNT_ERROR 3 /* other */ 227 #define NUM_COUNTERS_EXTRA 4 228 229 struct event_counter { ··· 237 static struct attribute_group interrupt_stats_attr_group = { 238 .name = "interrupts", 239 }; 240 + 241 static struct kobj_attribute *counter_attrs; 242 243 static void delete_gpe_attr_array(void) ··· 269 if (gpe_number < num_gpes) 270 all_counters[gpe_number].count++; 271 else 272 + all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + 273 + COUNT_ERROR].count++; 274 275 return; 276 } ··· 283 if (event_number < ACPI_NUM_FIXED_EVENTS) 284 all_counters[num_gpes + event_number].count++; 285 else 286 + all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + 287 + COUNT_ERROR].count++; 288 289 return; 290 } 291 292 + static int get_status(u32 index, acpi_event_status *status, 293 + acpi_handle *handle) 294 { 295 int result = 0; 296 ··· 300 result = acpi_get_gpe_device(index, handle); 301 if (result) { 302 ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND, 303 + "Invalid GPE 0x%x\n", index)); 304 goto end; 305 } 306 result = acpi_get_gpe_status(*handle, index, status); ··· 312 } 313 314 static ssize_t counter_show(struct kobject *kobj, 315 + struct kobj_attribute *attr, char *buf) 316 { 317 int index = attr - counter_attrs; 318 int size; ··· 321 int result = 0; 322 323 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI].count = 324 + acpi_irq_handled; 325 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI_NOT].count = 326 + acpi_irq_not_handled; 327 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE].count = 328 + acpi_gpe_count; 329 size = sprintf(buf, "%8d", all_counters[index].count); 330 331 /* "gpe_all" or "sci" */ ··· 338 goto end; 339 340 if (!(status & ACPI_EVENT_FLAG_HANDLE)) 341 + size += sprintf(buf + size, " invalid"); 342 else if (status & ACPI_EVENT_FLAG_ENABLED) 343 + size += sprintf(buf + size, " enabled"); 344 else if (status & ACPI_EVENT_FLAG_WAKE_ENABLED) 345 + size += sprintf(buf + size, " wake_enabled"); 346 else 347 + size += sprintf(buf + size, " disabled"); 348 349 end: 350 size += sprintf(buf + size, "\n"); ··· 357 * enable/disable/clear a gpe/fixed event in user space. 358 */ 359 static ssize_t counter_set(struct kobject *kobj, 360 + struct kobj_attribute *attr, const char *buf, 361 + size_t size) 362 { 363 int index = attr - counter_attrs; 364 acpi_event_status status; ··· 381 382 if (!(status & ACPI_EVENT_FLAG_HANDLE)) { 383 printk(KERN_WARNING PREFIX 384 + "Can not change Invalid GPE/Fixed Event status\n"); 385 return -EINVAL; 386 } 387 388 if (index < num_gpes) { 389 if (!strcmp(buf, "disable\n") && 390 + (status & ACPI_EVENT_FLAG_ENABLED)) 391 result = acpi_disable_gpe(handle, index); 392 else if (!strcmp(buf, "enable\n") && 393 + !(status & ACPI_EVENT_FLAG_ENABLED)) 394 result = acpi_enable_gpe(handle, index); 395 else if (!strcmp(buf, "clear\n") && 396 + (status & ACPI_EVENT_FLAG_SET)) 397 result = acpi_clear_gpe(handle, index); 398 else 399 all_counters[index].count = strtoul(buf, NULL, 0); 400 } else if (index < num_gpes + ACPI_NUM_FIXED_EVENTS) { 401 int event = index - num_gpes; 402 if (!strcmp(buf, "disable\n") && 403 + (status & ACPI_EVENT_FLAG_ENABLED)) 404 result = acpi_disable_event(event, ACPI_NOT_ISR); 405 else if (!strcmp(buf, "enable\n") && 406 + !(status & ACPI_EVENT_FLAG_ENABLED)) 407 result = acpi_enable_event(event, ACPI_NOT_ISR); 408 else if (!strcmp(buf, "clear\n") && 409 + (status & ACPI_EVENT_FLAG_SET)) 410 result = acpi_clear_event(event); 411 else 412 all_counters[index].count = strtoul(buf, NULL, 0); ··· 430 num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA; 431 432 all_attrs = kzalloc(sizeof(struct attribute *) * (num_counters + 1), 433 + GFP_KERNEL); 434 if (all_attrs == NULL) 435 return; 436 437 all_counters = kzalloc(sizeof(struct event_counter) * (num_counters), 438 + GFP_KERNEL); 439 if (all_counters == NULL) 440 goto fail; 441 442 counter_attrs = kzalloc(sizeof(struct kobj_attribute) * (num_counters), 443 + GFP_KERNEL); 444 if (counter_attrs == NULL) 445 goto fail; 446 ··· 503 return; 504 } 505 506 + int __init acpi_sysfs_init(void) 507 { 508 int result; 509 510 + result = acpi_tables_sysfs_init(); 511 512 return result; 513 }
+53 -33
drivers/acpi/thermal.c
··· 37 #include <linux/init.h> 38 #include <linux/slab.h> 39 #include <linux/types.h> 40 #include <linux/proc_fs.h> 41 #include <linux/jiffies.h> 42 #include <linux/kmod.h> 43 - #include <linux/seq_file.h> 44 #include <linux/reboot.h> 45 #include <linux/device.h> 46 #include <asm/uaccess.h> ··· 106 static int acpi_thermal_remove(struct acpi_device *device, int type); 107 static int acpi_thermal_resume(struct acpi_device *device); 108 static void acpi_thermal_notify(struct acpi_device *device, u32 event); 109 - static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); 110 - static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); 111 - static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); 112 - static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file); 113 - static ssize_t acpi_thermal_write_cooling_mode(struct file *, 114 - const char __user *, size_t, 115 - loff_t *); 116 - static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file); 117 - static ssize_t acpi_thermal_write_polling(struct file *, const char __user *, 118 - size_t, loff_t *); 119 120 static const struct acpi_device_id thermal_device_ids[] = { 121 {ACPI_THERMAL_HID, 0}, ··· 195 struct mutex lock; 196 }; 197 198 static const struct file_operations acpi_thermal_state_fops = { 199 .owner = THIS_MODULE, 200 .open = acpi_thermal_state_open_fs, ··· 248 .llseek = seq_lseek, 249 .release = single_release, 250 }; 251 252 /* -------------------------------------------------------------------------- 253 Thermal Zone Management ··· 290 tz->polling_frequency = tmp; 291 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", 292 tz->polling_frequency)); 293 - 294 - return 0; 295 - } 296 - 297 - static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds) 298 - { 299 - 300 - if (!tz) 301 - return -EINVAL; 302 - 303 - tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */ 304 - 305 - tz->thermal_zone->polling_delay = seconds * 1000; 306 - 307 - if (tz->tz_enabled) 308 - thermal_zone_device_update(tz->thermal_zone); 309 - 310 - ACPI_DEBUG_PRINT((ACPI_DB_INFO, 311 - "Polling frequency set to %lu seconds\n", 312 - tz->polling_frequency/10)); 313 314 return 0; 315 } ··· 960 /* -------------------------------------------------------------------------- 961 FS Interface (/proc) 962 -------------------------------------------------------------------------- */ 963 - 964 static struct proc_dir_entry *acpi_thermal_dir; 965 966 static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) ··· 1174 PDE(inode)->data); 1175 } 1176 1177 static ssize_t 1178 acpi_thermal_write_polling(struct file *file, 1179 const char __user * buffer, ··· 1302 1303 return 0; 1304 } 1305 - 1306 /* -------------------------------------------------------------------------- 1307 Driver Interface 1308 -------------------------------------------------------------------------- */ ··· 1579 printk(KERN_NOTICE "ACPI: thermal control disabled\n"); 1580 return -ENODEV; 1581 } 1582 acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir); 1583 if (!acpi_thermal_dir) 1584 return -ENODEV; 1585 1586 result = acpi_bus_register_driver(&acpi_thermal_driver); 1587 if (result < 0) { 1588 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); 1589 return -ENODEV; 1590 } 1591 ··· 1602 1603 acpi_bus_unregister_driver(&acpi_thermal_driver); 1604 1605 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); 1606 1607 return; 1608 }
··· 37 #include <linux/init.h> 38 #include <linux/slab.h> 39 #include <linux/types.h> 40 + 41 + #ifdef CONFIG_ACPI_PROCFS 42 #include <linux/proc_fs.h> 43 + #include <linux/seq_file.h> 44 + #endif 45 + 46 #include <linux/jiffies.h> 47 #include <linux/kmod.h> 48 #include <linux/reboot.h> 49 #include <linux/device.h> 50 #include <asm/uaccess.h> ··· 102 static int acpi_thermal_remove(struct acpi_device *device, int type); 103 static int acpi_thermal_resume(struct acpi_device *device); 104 static void acpi_thermal_notify(struct acpi_device *device, u32 event); 105 106 static const struct acpi_device_id thermal_device_ids[] = { 107 {ACPI_THERMAL_HID, 0}, ··· 201 struct mutex lock; 202 }; 203 204 + #ifdef CONFIG_ACPI_PROCFS 205 + static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); 206 + static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); 207 + static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); 208 + static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file); 209 + static ssize_t acpi_thermal_write_cooling_mode(struct file *, 210 + const char __user *, size_t, 211 + loff_t *); 212 + static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file); 213 + static ssize_t acpi_thermal_write_polling(struct file *, const char __user *, 214 + size_t, loff_t *); 215 + 216 static const struct file_operations acpi_thermal_state_fops = { 217 .owner = THIS_MODULE, 218 .open = acpi_thermal_state_open_fs, ··· 242 .llseek = seq_lseek, 243 .release = single_release, 244 }; 245 + #endif /* CONFIG_ACPI_PROCFS*/ 246 247 /* -------------------------------------------------------------------------- 248 Thermal Zone Management ··· 283 tz->polling_frequency = tmp; 284 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", 285 tz->polling_frequency)); 286 287 return 0; 288 } ··· 973 /* -------------------------------------------------------------------------- 974 FS Interface (/proc) 975 -------------------------------------------------------------------------- */ 976 + #ifdef CONFIG_ACPI_PROCFS 977 static struct proc_dir_entry *acpi_thermal_dir; 978 979 static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) ··· 1187 PDE(inode)->data); 1188 } 1189 1190 + static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds) 1191 + { 1192 + if (!tz) 1193 + return -EINVAL; 1194 + 1195 + /* Convert value to deci-seconds */ 1196 + tz->polling_frequency = seconds * 10; 1197 + 1198 + tz->thermal_zone->polling_delay = seconds * 1000; 1199 + 1200 + if (tz->tz_enabled) 1201 + thermal_zone_device_update(tz->thermal_zone); 1202 + 1203 + ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1204 + "Polling frequency set to %lu seconds\n", 1205 + tz->polling_frequency/10)); 1206 + 1207 + return 0; 1208 + } 1209 + 1210 static ssize_t 1211 acpi_thermal_write_polling(struct file *file, 1212 const char __user * buffer, ··· 1295 1296 return 0; 1297 } 1298 + #else 1299 + static inline int acpi_thermal_add_fs(struct acpi_device *device) { return 0; } 1300 + static inline int acpi_thermal_remove_fs(struct acpi_device *device) 1301 + { 1302 + return 0; 1303 + } 1304 + #endif /* CONFIG_ACPI_PROCFS */ 1305 /* -------------------------------------------------------------------------- 1306 Driver Interface 1307 -------------------------------------------------------------------------- */ ··· 1566 printk(KERN_NOTICE "ACPI: thermal control disabled\n"); 1567 return -ENODEV; 1568 } 1569 + 1570 + #ifdef CONFIG_ACPI_PROCFS 1571 acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir); 1572 if (!acpi_thermal_dir) 1573 return -ENODEV; 1574 + #endif 1575 1576 result = acpi_bus_register_driver(&acpi_thermal_driver); 1577 if (result < 0) { 1578 + #ifdef CONFIG_ACPI_PROCFS 1579 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); 1580 + #endif 1581 return -ENODEV; 1582 } 1583 ··· 1584 1585 acpi_bus_unregister_driver(&acpi_thermal_driver); 1586 1587 + #ifdef CONFIG_ACPI_PROCFS 1588 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); 1589 + #endif 1590 1591 return; 1592 }
+86 -55
drivers/acpi/video.c
··· 152 struct acpi_video_bus_flags flags; 153 struct list_head video_device_list; 154 struct mutex device_list_lock; /* protects video_device_list */ 155 struct proc_dir_entry *dir; 156 struct input_dev *input; 157 char phys[32]; /* for input device */ 158 struct notifier_block pm_nb; ··· 210 struct output_device *output_dev; 211 }; 212 213 /* bus */ 214 static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file); 215 static const struct file_operations acpi_video_bus_info_fops = { ··· 310 .llseek = seq_lseek, 311 .release = single_release, 312 }; 313 314 static const char device_decode[][30] = { 315 "motherboard VGA device", ··· 452 -------------------------------------------------------------------------- */ 453 454 /* device */ 455 - 456 - static int 457 - acpi_video_device_query(struct acpi_video_device *device, unsigned long long *state) 458 - { 459 - int status; 460 - 461 - status = acpi_evaluate_integer(device->dev->handle, "_DGS", NULL, state); 462 - 463 - return status; 464 - } 465 466 static int 467 acpi_video_device_get_state(struct acpi_video_device *device, ··· 691 } 692 693 /* bus */ 694 - 695 - static int 696 - acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option) 697 - { 698 - int status; 699 - unsigned long long tmp; 700 - union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 701 - struct acpi_object_list args = { 1, &arg0 }; 702 - 703 - 704 - arg0.integer.value = option; 705 - 706 - status = acpi_evaluate_integer(video->device->handle, "_SPD", &args, &tmp); 707 - if (ACPI_SUCCESS(status)) 708 - status = tmp ? (-EINVAL) : (AE_OK); 709 - 710 - return status; 711 - } 712 - 713 - static int 714 - acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long long *id) 715 - { 716 - int status; 717 - 718 - status = acpi_evaluate_integer(video->device->handle, "_GPD", NULL, id); 719 - 720 - return status; 721 - } 722 - 723 - static int 724 - acpi_video_bus_POST_options(struct acpi_video_bus *video, 725 - unsigned long long *options) 726 - { 727 - int status; 728 - 729 - status = acpi_evaluate_integer(video->device->handle, "_VPO", NULL, options); 730 - *options &= 3; 731 - 732 - return status; 733 - } 734 735 /* 736 * Arg: ··· 1113 /* -------------------------------------------------------------------------- 1114 FS Interface (/proc) 1115 -------------------------------------------------------------------------- */ 1116 1117 static struct proc_dir_entry *acpi_video_dir; 1118 ··· 1151 { 1152 return single_open(file, acpi_video_device_info_seq_show, 1153 PDE(inode)->data); 1154 } 1155 1156 static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset) ··· 1459 return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data); 1460 } 1461 1462 static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset) 1463 { 1464 struct acpi_video_bus *video = seq->private; ··· 1508 { 1509 return single_open(file, acpi_video_bus_POST_info_seq_show, 1510 PDE(inode)->data); 1511 } 1512 1513 static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset) ··· 1560 static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file) 1561 { 1562 return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data); 1563 } 1564 1565 static ssize_t ··· 1731 1732 return 0; 1733 } 1734 1735 /* -------------------------------------------------------------------------- 1736 Driver Interface ··· 2167 status = acpi_video_bus_get_one_device(dev, video); 2168 if (ACPI_FAILURE(status)) { 2169 printk(KERN_WARNING PREFIX 2170 - "Cant attach device"); 2171 continue; 2172 } 2173 } ··· 2177 static int acpi_video_bus_put_one_device(struct acpi_video_device *device) 2178 { 2179 acpi_status status; 2180 - struct acpi_video_bus *video; 2181 - 2182 2183 if (!device || !device->video) 2184 return -ENOENT; 2185 - 2186 - video = device->video; 2187 2188 acpi_video_device_remove_fs(device->dev); 2189 2190 status = acpi_remove_notify_handler(device->dev->handle, 2191 ACPI_DEVICE_NOTIFY, 2192 acpi_video_device_notify); 2193 if (device->backlight) { 2194 sysfs_remove_link(&device->backlight->dev.kobj, "device"); 2195 backlight_device_unregister(device->backlight); ··· 2584 return 0; 2585 } 2586 2587 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); 2588 if (!acpi_video_dir) 2589 return -ENODEV; 2590 2591 result = acpi_bus_register_driver(&acpi_video_bus); 2592 if (result < 0) { ··· 2617 } 2618 acpi_bus_unregister_driver(&acpi_video_bus); 2619 2620 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir); 2621 2622 register_count = 0; 2623
··· 152 struct acpi_video_bus_flags flags; 153 struct list_head video_device_list; 154 struct mutex device_list_lock; /* protects video_device_list */ 155 + #ifdef CONFIG_ACPI_PROCFS 156 struct proc_dir_entry *dir; 157 + #endif 158 struct input_dev *input; 159 char phys[32]; /* for input device */ 160 struct notifier_block pm_nb; ··· 208 struct output_device *output_dev; 209 }; 210 211 + #ifdef CONFIG_ACPI_PROCFS 212 /* bus */ 213 static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file); 214 static const struct file_operations acpi_video_bus_info_fops = { ··· 307 .llseek = seq_lseek, 308 .release = single_release, 309 }; 310 + #endif /* CONFIG_ACPI_PROCFS */ 311 312 static const char device_decode[][30] = { 313 "motherboard VGA device", ··· 448 -------------------------------------------------------------------------- */ 449 450 /* device */ 451 452 static int 453 acpi_video_device_get_state(struct acpi_video_device *device, ··· 697 } 698 699 /* bus */ 700 701 /* 702 * Arg: ··· 1159 /* -------------------------------------------------------------------------- 1160 FS Interface (/proc) 1161 -------------------------------------------------------------------------- */ 1162 + #ifdef CONFIG_ACPI_PROCFS 1163 1164 static struct proc_dir_entry *acpi_video_dir; 1165 ··· 1196 { 1197 return single_open(file, acpi_video_device_info_seq_show, 1198 PDE(inode)->data); 1199 + } 1200 + 1201 + static int 1202 + acpi_video_device_query(struct acpi_video_device *device, 1203 + unsigned long long *state) 1204 + { 1205 + int status; 1206 + 1207 + status = acpi_evaluate_integer(device->dev->handle, "_DGS", 1208 + NULL, state); 1209 + 1210 + return status; 1211 } 1212 1213 static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset) ··· 1492 return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data); 1493 } 1494 1495 + static int 1496 + acpi_video_bus_POST_options(struct acpi_video_bus *video, 1497 + unsigned long long *options) 1498 + { 1499 + int status; 1500 + 1501 + status = acpi_evaluate_integer(video->device->handle, "_VPO", 1502 + NULL, options); 1503 + *options &= 3; 1504 + 1505 + return status; 1506 + } 1507 + 1508 static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset) 1509 { 1510 struct acpi_video_bus *video = seq->private; ··· 1528 { 1529 return single_open(file, acpi_video_bus_POST_info_seq_show, 1530 PDE(inode)->data); 1531 + } 1532 + 1533 + static int 1534 + acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long long *id) 1535 + { 1536 + int status; 1537 + 1538 + status = acpi_evaluate_integer(video->device->handle, "_GPD", NULL, id); 1539 + 1540 + return status; 1541 } 1542 1543 static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset) ··· 1570 static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file) 1571 { 1572 return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data); 1573 + } 1574 + 1575 + static int 1576 + acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option) 1577 + { 1578 + int status; 1579 + unsigned long long tmp; 1580 + union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 1581 + struct acpi_object_list args = { 1, &arg0 }; 1582 + 1583 + 1584 + arg0.integer.value = option; 1585 + 1586 + status = acpi_evaluate_integer(video->device->handle, "_SPD", 1587 + &args, &tmp); 1588 + if (ACPI_SUCCESS(status)) 1589 + status = tmp ? (-EINVAL) : (AE_OK); 1590 + 1591 + return status; 1592 } 1593 1594 static ssize_t ··· 1722 1723 return 0; 1724 } 1725 + #else 1726 + static inline int acpi_video_device_add_fs(struct acpi_device *device) 1727 + { 1728 + return 0; 1729 + } 1730 + static inline int acpi_video_device_remove_fs(struct acpi_device *device) 1731 + { 1732 + return 0; 1733 + } 1734 + static inline int acpi_video_bus_add_fs(struct acpi_device *device) 1735 + { 1736 + return 0; 1737 + } 1738 + static inline int acpi_video_bus_remove_fs(struct acpi_device *device) 1739 + { 1740 + return 0; 1741 + } 1742 + #endif /* CONFIG_ACPI_PROCFS */ 1743 1744 /* -------------------------------------------------------------------------- 1745 Driver Interface ··· 2140 status = acpi_video_bus_get_one_device(dev, video); 2141 if (ACPI_FAILURE(status)) { 2142 printk(KERN_WARNING PREFIX 2143 + "Cant attach device\n"); 2144 continue; 2145 } 2146 } ··· 2150 static int acpi_video_bus_put_one_device(struct acpi_video_device *device) 2151 { 2152 acpi_status status; 2153 2154 if (!device || !device->video) 2155 return -ENOENT; 2156 2157 acpi_video_device_remove_fs(device->dev); 2158 2159 status = acpi_remove_notify_handler(device->dev->handle, 2160 ACPI_DEVICE_NOTIFY, 2161 acpi_video_device_notify); 2162 + if (ACPI_FAILURE(status)) { 2163 + printk(KERN_WARNING PREFIX 2164 + "Cant remove video notify handler\n"); 2165 + } 2166 if (device->backlight) { 2167 sysfs_remove_link(&device->backlight->dev.kobj, "device"); 2168 backlight_device_unregister(device->backlight); ··· 2557 return 0; 2558 } 2559 2560 + #ifdef CONFIG_ACPI_PROCFS 2561 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); 2562 if (!acpi_video_dir) 2563 return -ENODEV; 2564 + #endif 2565 2566 result = acpi_bus_register_driver(&acpi_video_bus); 2567 if (result < 0) { ··· 2588 } 2589 acpi_bus_unregister_driver(&acpi_video_bus); 2590 2591 + #ifdef CONFIG_ACPI_PROCFS 2592 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir); 2593 + #endif 2594 2595 register_count = 0; 2596
+10 -38
drivers/acpi/wakeup.c
··· 21 ACPI_MODULE_NAME("wakeup_devices") 22 23 /** 24 - * acpi_enable_wakeup_device_prep - Prepare wake-up devices. 25 * @sleep_state: ACPI system sleep state. 26 * 27 - * Enable all wake-up devices' power, unless the requested system sleep state is 28 - * too deep. 29 */ 30 - void acpi_enable_wakeup_device_prep(u8 sleep_state) 31 { 32 struct list_head *node, *next; 33 34 - list_for_each_safe(node, next, &acpi_wakeup_device_list) { 35 - struct acpi_device *dev = container_of(node, 36 - struct acpi_device, 37 - wakeup_list); 38 - 39 - if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled 40 - || (sleep_state > (u32) dev->wakeup.sleep_state)) 41 - continue; 42 - 43 - acpi_enable_wakeup_device_power(dev, sleep_state); 44 - } 45 - } 46 - 47 - /** 48 - * acpi_enable_wakeup_device - Enable wake-up device GPEs. 49 - * @sleep_state: ACPI system sleep state. 50 - * 51 - * Enable all wake-up devices' GPEs, with the assumption that 52 - * acpi_disable_all_gpes() was executed before, so we don't need to disable any 53 - * GPEs here. 54 - */ 55 - void acpi_enable_wakeup_device(u8 sleep_state) 56 - { 57 - struct list_head *node, *next; 58 - 59 - /* 60 - * Caution: this routine must be invoked when interrupt is disabled 61 - * Refer ACPI2.0: P212 62 - */ 63 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 64 struct acpi_device *dev = 65 container_of(node, struct acpi_device, wakeup_list); ··· 41 || sleep_state > (u32) dev->wakeup.sleep_state) 42 continue; 43 44 /* The wake-up power should have been enabled already. */ 45 acpi_gpe_wakeup(dev->wakeup.gpe_device, dev->wakeup.gpe_number, 46 ACPI_GPE_ENABLE); ··· 51 } 52 53 /** 54 - * acpi_disable_wakeup_device - Disable devices' wakeup capability. 55 * @sleep_state: ACPI system sleep state. 56 - * 57 - * This function only affects devices with wakeup.state.enabled set, which means 58 - * that it reverses the changes made by acpi_enable_wakeup_device_prep(). 59 */ 60 - void acpi_disable_wakeup_device(u8 sleep_state) 61 { 62 struct list_head *node, *next; 63
··· 21 ACPI_MODULE_NAME("wakeup_devices") 22 23 /** 24 + * acpi_enable_wakeup_devices - Enable wake-up device GPEs. 25 * @sleep_state: ACPI system sleep state. 26 * 27 + * Enable wakeup device power of devices with the state.enable flag set and set 28 + * the wakeup enable mask bits in the GPE registers that correspond to wakeup 29 + * devices. 30 */ 31 + void acpi_enable_wakeup_devices(u8 sleep_state) 32 { 33 struct list_head *node, *next; 34 35 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 36 struct acpi_device *dev = 37 container_of(node, struct acpi_device, wakeup_list); ··· 69 || sleep_state > (u32) dev->wakeup.sleep_state) 70 continue; 71 72 + if (dev->wakeup.state.enabled) 73 + acpi_enable_wakeup_device_power(dev, sleep_state); 74 + 75 /* The wake-up power should have been enabled already. */ 76 acpi_gpe_wakeup(dev->wakeup.gpe_device, dev->wakeup.gpe_number, 77 ACPI_GPE_ENABLE); ··· 76 } 77 78 /** 79 + * acpi_disable_wakeup_devices - Disable devices' wakeup capability. 80 * @sleep_state: ACPI system sleep state. 81 */ 82 + void acpi_disable_wakeup_devices(u8 sleep_state) 83 { 84 struct list_head *node, *next; 85
-6
drivers/ata/libata-acpi.c
··· 145 struct ata_eh_info *ehi = &ap->link.eh_info; 146 int wait = 0; 147 unsigned long flags; 148 - acpi_handle handle; 149 - 150 - if (dev) 151 - handle = dev->acpi_handle; 152 - else 153 - handle = ap->acpi_handle; 154 155 spin_lock_irqsave(ap->lock, flags); 156 /*
··· 145 struct ata_eh_info *ehi = &ap->link.eh_info; 146 int wait = 0; 147 unsigned long flags; 148 149 spin_lock_irqsave(ap->lock, flags); 150 /*
+1 -1
include/acpi/acpixf.h
··· 66 extern u8 acpi_gbl_use_default_register_widths; 67 extern acpi_name acpi_gbl_trace_method_name; 68 extern u32 acpi_gbl_trace_flags; 69 - extern u8 acpi_gbl_enable_aml_debug_object; 70 extern u8 acpi_gbl_copy_dsdt_locally; 71 extern u8 acpi_gbl_truncate_io_addresses; 72
··· 66 extern u8 acpi_gbl_use_default_register_widths; 67 extern acpi_name acpi_gbl_trace_method_name; 68 extern u32 acpi_gbl_trace_flags; 69 + extern u32 acpi_gbl_enable_aml_debug_object; 70 extern u8 acpi_gbl_copy_dsdt_locally; 71 extern u8 acpi_gbl_truncate_io_addresses; 72
-1
include/acpi/processor.h
··· 338 339 /* in processor_thermal.c */ 340 int acpi_processor_get_limit_info(struct acpi_processor *pr); 341 - extern const struct file_operations acpi_processor_limit_fops; 342 extern struct thermal_cooling_device_ops processor_cooling_ops; 343 #ifdef CONFIG_CPU_FREQ 344 void acpi_thermal_cpufreq_init(void);
··· 338 339 /* in processor_thermal.c */ 340 int acpi_processor_get_limit_info(struct acpi_processor *pr); 341 extern struct thermal_cooling_device_ops processor_cooling_ops; 342 #ifdef CONFIG_CPU_FREQ 343 void acpi_thermal_cpufreq_init(void);
+4 -4
include/linux/cper.h
··· 39 * Severity difinition for error_severity in struct cper_record_header 40 * and section_severity in struct cper_section_descriptor 41 */ 42 - #define CPER_SER_RECOVERABLE 0x0 43 - #define CPER_SER_FATAL 0x1 44 - #define CPER_SER_CORRECTED 0x2 45 - #define CPER_SER_INFORMATIONAL 0x3 46 47 /* 48 * Validation bits difinition for validation_bits in struct
··· 39 * Severity difinition for error_severity in struct cper_record_header 40 * and section_severity in struct cper_section_descriptor 41 */ 42 + #define CPER_SEV_RECOVERABLE 0x0 43 + #define CPER_SEV_FATAL 0x1 44 + #define CPER_SEV_CORRECTED 0x2 45 + #define CPER_SEV_INFORMATIONAL 0x3 46 47 /* 48 * Validation bits difinition for validation_bits in struct