Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: (34 commits)
classmate-laptop: add support for Classmate PC ACPI devices
hp-wmi: Fix two memleaks
acer-wmi, msi-wmi: Remove needless DMI MODULE_ALIAS
dell-wmi: do not keep driver loaded on unsupported boxes
wmi: Free the allocated acpi objects through wmi_get_event_data
drivers/platform/x86/acerhdf.c: check BIOS information whether it begins with string of table
acerhdf: add new BIOS versions
acerhdf: limit modalias matching to supported
toshiba_acpi: convert to seq_file
asus_acpi: convert to seq_file
ACPI: do not select ACPI_DOCK from ATA_ACPI
sony-laptop: enumerate rfkill devices using SN06
sony-laptop: rfkill support for newer models
ACPI: fix OSC regression that caused aer and pciehp not to load
MAINTAINERS: add maintainer for msi-wmi driver
fujitu-laptop: fix tests of acpi_evaluate_integer() return value
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c: avoid cross-CPU interrupts by using smp_call_function_any()
ACPI: processor: remove _PDC object list from struct acpi_processor
ACPI: processor: change acpi_processor_set_pdc() interface
ACPI: processor: open code acpi_processor_cleanup_pdc
...

+1435 -667
+11
MAINTAINERS
··· 1472 1472 S: Supported 1473 1473 F: drivers/scsi/fnic/ 1474 1474 1475 + CMPC ACPI DRIVER 1476 + M: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com> 1477 + M: Daniel Oliveira Nascimento <don@syst.com.br> 1478 + S: Supported 1479 + F: drivers/platform/x86/classmate-laptop.c 1480 + 1475 1481 CODA FILE SYSTEM 1476 1482 M: Jan Harkes <jaharkes@cs.cmu.edu> 1477 1483 M: coda@cs.cmu.edu ··· 3651 3645 W: http://0pointer.de/lennart/tchibo.html 3652 3646 S: Maintained 3653 3647 F: drivers/platform/x86/msi-laptop.c 3648 + 3649 + MSI WMI SUPPORT 3650 + M: Anisse Astier <anisse@astier.eu> 3651 + S: Supported 3652 + F: drivers/platform/x86/msi-wmi.c 3654 3653 3655 3654 MULTIFUNCTION DEVICES (MFD) 3656 3655 M: Samuel Ortiz <sameo@linux.intel.com>
+6
arch/ia64/include/asm/acpi.h
··· 132 132 extern int __initdata nid_to_pxm_map[MAX_NUMNODES]; 133 133 #endif 134 134 135 + static inline bool arch_has_acpi_pdc(void) { return true; } 136 + static inline void arch_acpi_set_pdc_bits(u32 *buf) 137 + { 138 + buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP; 139 + } 140 + 135 141 #define acpi_unlazy_tlb(x) 136 142 137 143 #ifdef CONFIG_ACPI_NUMA
-4
arch/ia64/kernel/Makefile
··· 18 18 obj-$(CONFIG_IA64_HP_ZX1) += acpi-ext.o 19 19 obj-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += acpi-ext.o 20 20 21 - ifneq ($(CONFIG_ACPI_PROCESSOR),) 22 - obj-y += acpi-processor.o 23 - endif 24 - 25 21 obj-$(CONFIG_IA64_PALINFO) += palinfo.o 26 22 obj-$(CONFIG_IOSAPIC) += iosapic.o 27 23 obj-$(CONFIG_MODULES) += module.o
-85
arch/ia64/kernel/acpi-processor.c
··· 1 - /* 2 - * arch/ia64/kernel/acpi-processor.c 3 - * 4 - * Copyright (C) 2005 Intel Corporation 5 - * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> 6 - * - Added _PDC for platforms with Intel CPUs 7 - */ 8 - 9 - #include <linux/kernel.h> 10 - #include <linux/module.h> 11 - #include <linux/init.h> 12 - #include <linux/acpi.h> 13 - 14 - #include <acpi/processor.h> 15 - #include <asm/acpi.h> 16 - 17 - static void init_intel_pdc(struct acpi_processor *pr) 18 - { 19 - struct acpi_object_list *obj_list; 20 - union acpi_object *obj; 21 - u32 *buf; 22 - 23 - /* allocate and initialize pdc. It will be used later. */ 24 - obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL); 25 - if (!obj_list) { 26 - printk(KERN_ERR "Memory allocation error\n"); 27 - return; 28 - } 29 - 30 - obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL); 31 - if (!obj) { 32 - printk(KERN_ERR "Memory allocation error\n"); 33 - kfree(obj_list); 34 - return; 35 - } 36 - 37 - buf = kmalloc(12, GFP_KERNEL); 38 - if (!buf) { 39 - printk(KERN_ERR "Memory allocation error\n"); 40 - kfree(obj); 41 - kfree(obj_list); 42 - return; 43 - } 44 - 45 - buf[0] = ACPI_PDC_REVISION_ID; 46 - buf[1] = 1; 47 - buf[2] = ACPI_PDC_EST_CAPABILITY_SMP; 48 - /* 49 - * The default of PDC_SMP_T_SWCOORD bit is set for IA64 cpu so 50 - * that OSPM is capable of native ACPI throttling software 51 - * coordination using BIOS supplied _TSD info. 52 - */ 53 - buf[2] |= ACPI_PDC_SMP_T_SWCOORD; 54 - 55 - obj->type = ACPI_TYPE_BUFFER; 56 - obj->buffer.length = 12; 57 - obj->buffer.pointer = (u8 *) buf; 58 - obj_list->count = 1; 59 - obj_list->pointer = obj; 60 - pr->pdc = obj_list; 61 - 62 - return; 63 - } 64 - 65 - /* Initialize _PDC data based on the CPU vendor */ 66 - void arch_acpi_processor_init_pdc(struct acpi_processor *pr) 67 - { 68 - pr->pdc = NULL; 69 - init_intel_pdc(pr); 70 - return; 71 - } 72 - 73 - EXPORT_SYMBOL(arch_acpi_processor_init_pdc); 74 - 75 - void arch_acpi_processor_cleanup_pdc(struct acpi_processor *pr) 76 - { 77 - if (pr->pdc) { 78 - kfree(pr->pdc->pointer->buffer.pointer); 79 - kfree(pr->pdc->pointer); 80 - kfree(pr->pdc); 81 - pr->pdc = NULL; 82 - } 83 - } 84 - 85 - EXPORT_SYMBOL(arch_acpi_processor_cleanup_pdc);
+26
arch/x86/include/asm/acpi.h
··· 142 142 return max_cstate; 143 143 } 144 144 145 + static inline bool arch_has_acpi_pdc(void) 146 + { 147 + struct cpuinfo_x86 *c = &cpu_data(0); 148 + return (c->x86_vendor == X86_VENDOR_INTEL || 149 + c->x86_vendor == X86_VENDOR_CENTAUR); 150 + } 151 + 152 + static inline void arch_acpi_set_pdc_bits(u32 *buf) 153 + { 154 + struct cpuinfo_x86 *c = &cpu_data(0); 155 + 156 + buf[2] |= ACPI_PDC_C_CAPABILITY_SMP; 157 + 158 + if (cpu_has(c, X86_FEATURE_EST)) 159 + buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP; 160 + 161 + if (cpu_has(c, X86_FEATURE_ACPI)) 162 + buf[2] |= ACPI_PDC_T_FFH; 163 + 164 + /* 165 + * If mwait/monitor is unsupported, C2/C3_FFH will be disabled 166 + */ 167 + if (!cpu_has(c, X86_FEATURE_MWAIT)) 168 + buf[2] &= ~(ACPI_PDC_C_C2C3_FFH); 169 + } 170 + 145 171 #else /* !CONFIG_ACPI */ 146 172 147 173 #define acpi_lapic 0
+1 -1
arch/x86/kernel/acpi/Makefile
··· 4 4 obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup_rm.o wakeup_$(BITS).o 5 5 6 6 ifneq ($(CONFIG_ACPI_PROCESSOR),) 7 - obj-y += cstate.o processor.o 7 + obj-y += cstate.o 8 8 endif 9 9 10 10 $(obj)/wakeup_rm.o: $(obj)/realmode/wakeup.bin
-101
arch/x86/kernel/acpi/processor.c
··· 1 - /* 2 - * Copyright (C) 2005 Intel Corporation 3 - * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> 4 - * - Added _PDC for platforms with Intel CPUs 5 - */ 6 - 7 - #include <linux/kernel.h> 8 - #include <linux/module.h> 9 - #include <linux/init.h> 10 - #include <linux/acpi.h> 11 - 12 - #include <acpi/processor.h> 13 - #include <asm/acpi.h> 14 - 15 - static void init_intel_pdc(struct acpi_processor *pr, struct cpuinfo_x86 *c) 16 - { 17 - struct acpi_object_list *obj_list; 18 - union acpi_object *obj; 19 - u32 *buf; 20 - 21 - /* allocate and initialize pdc. It will be used later. */ 22 - obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL); 23 - if (!obj_list) { 24 - printk(KERN_ERR "Memory allocation error\n"); 25 - return; 26 - } 27 - 28 - obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL); 29 - if (!obj) { 30 - printk(KERN_ERR "Memory allocation error\n"); 31 - kfree(obj_list); 32 - return; 33 - } 34 - 35 - buf = kmalloc(12, GFP_KERNEL); 36 - if (!buf) { 37 - printk(KERN_ERR "Memory allocation error\n"); 38 - kfree(obj); 39 - kfree(obj_list); 40 - return; 41 - } 42 - 43 - buf[0] = ACPI_PDC_REVISION_ID; 44 - buf[1] = 1; 45 - buf[2] = ACPI_PDC_C_CAPABILITY_SMP; 46 - 47 - /* 48 - * The default of PDC_SMP_T_SWCOORD bit is set for intel x86 cpu so 49 - * that OSPM is capable of native ACPI throttling software 50 - * coordination using BIOS supplied _TSD info. 51 - */ 52 - buf[2] |= ACPI_PDC_SMP_T_SWCOORD; 53 - if (cpu_has(c, X86_FEATURE_EST)) 54 - buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP; 55 - 56 - if (cpu_has(c, X86_FEATURE_ACPI)) 57 - buf[2] |= ACPI_PDC_T_FFH; 58 - 59 - /* 60 - * If mwait/monitor is unsupported, C2/C3_FFH will be disabled 61 - */ 62 - if (!cpu_has(c, X86_FEATURE_MWAIT)) 63 - buf[2] &= ~(ACPI_PDC_C_C2C3_FFH); 64 - 65 - obj->type = ACPI_TYPE_BUFFER; 66 - obj->buffer.length = 12; 67 - obj->buffer.pointer = (u8 *) buf; 68 - obj_list->count = 1; 69 - obj_list->pointer = obj; 70 - pr->pdc = obj_list; 71 - 72 - return; 73 - } 74 - 75 - 76 - /* Initialize _PDC data based on the CPU vendor */ 77 - void arch_acpi_processor_init_pdc(struct acpi_processor *pr) 78 - { 79 - struct cpuinfo_x86 *c = &cpu_data(pr->id); 80 - 81 - pr->pdc = NULL; 82 - if (c->x86_vendor == X86_VENDOR_INTEL || 83 - c->x86_vendor == X86_VENDOR_CENTAUR) 84 - init_intel_pdc(pr, c); 85 - 86 - return; 87 - } 88 - 89 - EXPORT_SYMBOL(arch_acpi_processor_init_pdc); 90 - 91 - void arch_acpi_processor_cleanup_pdc(struct acpi_processor *pr) 92 - { 93 - if (pr->pdc) { 94 - kfree(pr->pdc->pointer->buffer.pointer); 95 - kfree(pr->pdc->pointer); 96 - kfree(pr->pdc); 97 - pr->pdc = NULL; 98 - } 99 - } 100 - 101 - EXPORT_SYMBOL(arch_acpi_processor_cleanup_pdc);
+3 -1
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
··· 190 190 191 191 static void drv_read(struct drv_cmd *cmd) 192 192 { 193 + int err; 193 194 cmd->val = 0; 194 195 195 - smp_call_function_single(cpumask_any(cmd->mask), do_drv_read, cmd, 1); 196 + err = smp_call_function_any(cmd->mask, do_drv_read, cmd, 1); 197 + WARN_ON_ONCE(err); /* smp_call_function_any() was buggy? */ 196 198 } 197 199 198 200 static void drv_write(struct drv_cmd *cmd)
+1
drivers/acpi/Makefile
··· 32 32 # 33 33 acpi-y += bus.o glue.o 34 34 acpi-y += scan.o 35 + acpi-y += processor_pdc.o 35 36 acpi-y += ec.o 36 37 acpi-$(CONFIG_ACPI_DOCK) += dock.o 37 38 acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o
+14
drivers/acpi/blacklist.c
··· 185 185 acpi_osi_setup("!Windows 2006"); 186 186 return 0; 187 187 } 188 + static int __init dmi_disable_osi_win7(const struct dmi_system_id *d) 189 + { 190 + printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); 191 + acpi_osi_setup("!Windows 2009"); 192 + return 0; 193 + } 188 194 189 195 static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { 190 196 { ··· 215 209 .matches = { 216 210 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), 217 211 DMI_MATCH(DMI_PRODUCT_NAME, "Sony VGN-SR290J"), 212 + }, 213 + }, 214 + { 215 + .callback = dmi_disable_osi_win7, 216 + .ident = "ASUS K50IJ", 217 + .matches = { 218 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), 219 + DMI_MATCH(DMI_PRODUCT_NAME, "K50IJ"), 218 220 }, 219 221 }, 220 222
+20 -8
drivers/acpi/bus.c
··· 397 397 union acpi_object *out_obj; 398 398 u8 uuid[16]; 399 399 u32 errors; 400 + struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; 400 401 401 402 if (!context) 402 403 return AE_ERROR; ··· 420 419 in_params[3].buffer.length = context->cap.length; 421 420 in_params[3].buffer.pointer = context->cap.pointer; 422 421 423 - status = acpi_evaluate_object(handle, "_OSC", &input, &context->ret); 422 + status = acpi_evaluate_object(handle, "_OSC", &input, &output); 424 423 if (ACPI_FAILURE(status)) 425 424 return status; 426 425 427 - /* return buffer should have the same length as cap buffer */ 428 - if (context->ret.length != context->cap.length) 426 + if (!output.length) 429 427 return AE_NULL_OBJECT; 430 428 431 - out_obj = context->ret.pointer; 432 - if (out_obj->type != ACPI_TYPE_BUFFER) { 429 + out_obj = output.pointer; 430 + if (out_obj->type != ACPI_TYPE_BUFFER 431 + || out_obj->buffer.length != context->cap.length) { 433 432 acpi_print_osc_error(handle, context, 434 433 "_OSC evaluation returned wrong type"); 435 434 status = AE_TYPE; ··· 458 457 goto out_kfree; 459 458 } 460 459 out_success: 461 - return AE_OK; 460 + context->ret.length = out_obj->buffer.length; 461 + context->ret.pointer = kmalloc(context->ret.length, GFP_KERNEL); 462 + if (!context->ret.pointer) { 463 + status = AE_NO_MEMORY; 464 + goto out_kfree; 465 + } 466 + memcpy(context->ret.pointer, out_obj->buffer.pointer, 467 + context->ret.length); 468 + status = AE_OK; 462 469 463 470 out_kfree: 464 - kfree(context->ret.pointer); 465 - context->ret.pointer = NULL; 471 + kfree(output.pointer); 472 + if (status != AE_OK) 473 + context->ret.pointer = NULL; 466 474 return status; 467 475 } 468 476 EXPORT_SYMBOL(acpi_run_osc); ··· 897 887 printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n"); 898 888 goto error1; 899 889 } 890 + 891 + acpi_early_processor_set_pdc(); 900 892 901 893 /* 902 894 * Maybe EC region is required at bus_scan/acpi_get_devices. So it
+8 -2
drivers/acpi/ec.c
··· 916 916 /* MSI EC needs special treatment, enable it */ 917 917 static int ec_flag_msi(const struct dmi_system_id *id) 918 918 { 919 + printk(KERN_DEBUG PREFIX "Detected MSI hardware, enabling workarounds.\n"); 919 920 EC_FLAGS_MSI = 1; 920 921 EC_FLAGS_VALIDATE_ECDT = 1; 921 922 return 0; ··· 929 928 DMI_MATCH(DMI_BOARD_NAME, "JFL92") }, NULL}, 930 929 { 931 930 ec_flag_msi, "MSI hardware", { 932 - DMI_MATCH(DMI_BIOS_VENDOR, "Micro-Star"), 933 - DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-Star") }, NULL}, 931 + DMI_MATCH(DMI_BIOS_VENDOR, "Micro-Star")}, NULL}, 932 + { 933 + ec_flag_msi, "MSI hardware", { 934 + DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star")}, NULL}, 935 + { 936 + ec_flag_msi, "MSI hardware", { 937 + DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-Star")}, NULL}, 934 938 { 935 939 ec_validate_ecdt, "ASUS hardware", { 936 940 DMI_MATCH(DMI_BIOS_VENDOR, "ASUS") }, NULL},
+1
drivers/acpi/internal.h
··· 43 43 extern int acpi_power_nocheck; 44 44 45 45 int acpi_wakeup_device_init(void); 46 + void acpi_early_processor_set_pdc(void); 46 47 47 48 /* -------------------------------------------------------------------------- 48 49 Embedded Controller
+1 -70
drivers/acpi/processor_core.c
··· 124 124 125 125 DEFINE_PER_CPU(struct acpi_processor *, processors); 126 126 struct acpi_processor_errata errata __read_mostly; 127 - static int set_no_mwait(const struct dmi_system_id *id) 128 - { 129 - printk(KERN_NOTICE PREFIX "%s detected - " 130 - "disabling mwait for CPU C-states\n", id->ident); 131 - idle_nomwait = 1; 132 - return 0; 133 - } 134 - 135 - static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = { 136 - { 137 - set_no_mwait, "IFL91 board", { 138 - DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"), 139 - DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"), 140 - DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"), 141 - DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL}, 142 - { 143 - set_no_mwait, "Extensa 5220", { 144 - DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"), 145 - DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 146 - DMI_MATCH(DMI_PRODUCT_VERSION, "0100"), 147 - DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL}, 148 - {}, 149 - }; 150 127 151 128 /* -------------------------------------------------------------------------- 152 129 Errata Handling ··· 251 274 } 252 275 253 276 return result; 254 - } 255 - 256 - /* -------------------------------------------------------------------------- 257 - Common ACPI processor functions 258 - -------------------------------------------------------------------------- */ 259 - 260 - /* 261 - * _PDC is required for a BIOS-OS handshake for most of the newer 262 - * ACPI processor features. 263 - */ 264 - static int acpi_processor_set_pdc(struct acpi_processor *pr) 265 - { 266 - struct acpi_object_list *pdc_in = pr->pdc; 267 - acpi_status status = AE_OK; 268 - 269 - 270 - if (!pdc_in) 271 - return status; 272 - if (idle_nomwait) { 273 - /* 274 - * If mwait is disabled for CPU C-states, the C2C3_FFH access 275 - * mode will be disabled in the parameter of _PDC object. 276 - * Of course C1_FFH access mode will also be disabled. 277 - */ 278 - union acpi_object *obj; 279 - u32 *buffer = NULL; 280 - 281 - obj = pdc_in->pointer; 282 - buffer = (u32 *)(obj->buffer.pointer); 283 - buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH); 284 - 285 - } 286 - status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL); 287 - 288 - if (ACPI_FAILURE(status)) 289 - ACPI_DEBUG_PRINT((ACPI_DB_INFO, 290 - "Could not evaluate _PDC, using legacy perf. control...\n")); 291 - 292 - return status; 293 277 } 294 278 295 279 /* -------------------------------------------------------------------------- ··· 763 825 } 764 826 765 827 /* _PDC call should be done before doing anything else (if reqd.). */ 766 - arch_acpi_processor_init_pdc(pr); 767 - acpi_processor_set_pdc(pr); 768 - arch_acpi_processor_cleanup_pdc(pr); 828 + acpi_processor_set_pdc(pr->handle); 769 829 770 830 #ifdef CONFIG_CPU_FREQ 771 831 acpi_processor_ppc_has_changed(pr, 0); ··· 1081 1145 if (!acpi_processor_dir) 1082 1146 return -ENOMEM; 1083 1147 #endif 1084 - /* 1085 - * Check whether the system is DMI table. If yes, OSPM 1086 - * should not use mwait for CPU-states. 1087 - */ 1088 - dmi_check_system(processor_idle_dmi_table); 1089 1148 result = cpuidle_register_driver(&acpi_idle_driver); 1090 1149 if (result < 0) 1091 1150 goto out_proc;
+165
drivers/acpi/processor_pdc.c
··· 1 + /* 2 + * Copyright (C) 2005 Intel Corporation 3 + * Copyright (C) 2009 Hewlett-Packard Development Company, L.P. 4 + * 5 + * Alex Chiang <achiang@hp.com> 6 + * - Unified x86/ia64 implementations 7 + * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> 8 + * - Added _PDC for platforms with Intel CPUs 9 + */ 10 + #include <linux/dmi.h> 11 + 12 + #include <acpi/acpi_drivers.h> 13 + #include <acpi/processor.h> 14 + 15 + #include "internal.h" 16 + 17 + #define PREFIX "ACPI: " 18 + #define _COMPONENT ACPI_PROCESSOR_COMPONENT 19 + ACPI_MODULE_NAME("processor_pdc"); 20 + 21 + static int set_no_mwait(const struct dmi_system_id *id) 22 + { 23 + printk(KERN_NOTICE PREFIX "%s detected - " 24 + "disabling mwait for CPU C-states\n", id->ident); 25 + idle_nomwait = 1; 26 + return 0; 27 + } 28 + 29 + static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = { 30 + { 31 + set_no_mwait, "IFL91 board", { 32 + DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"), 33 + DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"), 34 + DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"), 35 + DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL}, 36 + { 37 + set_no_mwait, "Extensa 5220", { 38 + DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"), 39 + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 40 + DMI_MATCH(DMI_PRODUCT_VERSION, "0100"), 41 + DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL}, 42 + {}, 43 + }; 44 + 45 + static void acpi_set_pdc_bits(u32 *buf) 46 + { 47 + buf[0] = ACPI_PDC_REVISION_ID; 48 + buf[1] = 1; 49 + 50 + /* Enable coordination with firmware's _TSD info */ 51 + buf[2] = ACPI_PDC_SMP_T_SWCOORD; 52 + 53 + /* Twiddle arch-specific bits needed for _PDC */ 54 + arch_acpi_set_pdc_bits(buf); 55 + } 56 + 57 + static struct acpi_object_list *acpi_processor_alloc_pdc(void) 58 + { 59 + struct acpi_object_list *obj_list; 60 + union acpi_object *obj; 61 + u32 *buf; 62 + 63 + /* allocate and initialize pdc. It will be used later. */ 64 + obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL); 65 + if (!obj_list) { 66 + printk(KERN_ERR "Memory allocation error\n"); 67 + return NULL; 68 + } 69 + 70 + obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL); 71 + if (!obj) { 72 + printk(KERN_ERR "Memory allocation error\n"); 73 + kfree(obj_list); 74 + return NULL; 75 + } 76 + 77 + buf = kmalloc(12, GFP_KERNEL); 78 + if (!buf) { 79 + printk(KERN_ERR "Memory allocation error\n"); 80 + kfree(obj); 81 + kfree(obj_list); 82 + return NULL; 83 + } 84 + 85 + acpi_set_pdc_bits(buf); 86 + 87 + obj->type = ACPI_TYPE_BUFFER; 88 + obj->buffer.length = 12; 89 + obj->buffer.pointer = (u8 *) buf; 90 + obj_list->count = 1; 91 + obj_list->pointer = obj; 92 + 93 + return obj_list; 94 + } 95 + 96 + /* 97 + * _PDC is required for a BIOS-OS handshake for most of the newer 98 + * ACPI processor features. 99 + */ 100 + static int 101 + acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) 102 + { 103 + acpi_status status = AE_OK; 104 + 105 + if (idle_nomwait) { 106 + /* 107 + * If mwait is disabled for CPU C-states, the C2C3_FFH access 108 + * mode will be disabled in the parameter of _PDC object. 109 + * Of course C1_FFH access mode will also be disabled. 110 + */ 111 + union acpi_object *obj; 112 + u32 *buffer = NULL; 113 + 114 + obj = pdc_in->pointer; 115 + buffer = (u32 *)(obj->buffer.pointer); 116 + buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH); 117 + 118 + } 119 + status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL); 120 + 121 + if (ACPI_FAILURE(status)) 122 + ACPI_DEBUG_PRINT((ACPI_DB_INFO, 123 + "Could not evaluate _PDC, using legacy perf. control.\n")); 124 + 125 + return status; 126 + } 127 + 128 + void acpi_processor_set_pdc(acpi_handle handle) 129 + { 130 + struct acpi_object_list *obj_list; 131 + 132 + if (arch_has_acpi_pdc() == false) 133 + return; 134 + 135 + obj_list = acpi_processor_alloc_pdc(); 136 + if (!obj_list) 137 + return; 138 + 139 + acpi_processor_eval_pdc(handle, obj_list); 140 + 141 + kfree(obj_list->pointer->buffer.pointer); 142 + kfree(obj_list->pointer); 143 + kfree(obj_list); 144 + } 145 + EXPORT_SYMBOL_GPL(acpi_processor_set_pdc); 146 + 147 + static acpi_status 148 + early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv) 149 + { 150 + acpi_processor_set_pdc(handle); 151 + return AE_OK; 152 + } 153 + 154 + void acpi_early_processor_set_pdc(void) 155 + { 156 + /* 157 + * Check whether the system is DMI table. If yes, OSPM 158 + * should not use mwait for CPU-states. 159 + */ 160 + dmi_check_system(processor_idle_dmi_table); 161 + 162 + acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, 163 + ACPI_UINT32_MAX, 164 + early_init_pdc, NULL, NULL, NULL); 165 + }
-1
drivers/ata/Kconfig
··· 40 40 config ATA_ACPI 41 41 bool "ATA ACPI Support" 42 42 depends on ACPI && PCI 43 - select ACPI_DOCK 44 43 default y 45 44 help 46 45 This option adds support for ATA-related ACPI objects.
+12
drivers/platform/x86/Kconfig
··· 464 464 465 465 If you have a modern Toshiba laptop with a Bluetooth and an 466 466 RFKill switch (such as the Portege R500), say Y. 467 + 468 + config ACPI_CMPC 469 + tristate "CMPC Laptop Extras" 470 + depends on X86 && ACPI 471 + select INPUT 472 + select BACKLIGHT_CLASS_DEVICE 473 + default n 474 + help 475 + Support for Intel Classmate PC ACPI devices, including some 476 + keys as input device, backlight device, tablet and accelerometer 477 + devices. 478 + 467 479 endif # X86_PLATFORM_DEVICES
+1
drivers/platform/x86/Makefile
··· 5 5 obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o 6 6 obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o 7 7 obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o 8 + obj-$(CONFIG_ACPI_CMPC) += classmate-laptop.o 8 9 obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o 9 10 obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o 10 11 obj-$(CONFIG_DELL_WMI) += dell-wmi.o
-3
drivers/platform/x86/acer-wmi.c
··· 96 96 MODULE_ALIAS("wmi:67C3371D-95A3-4C37-BB61-DD47B491DAAB"); 97 97 MODULE_ALIAS("wmi:6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3"); 98 98 99 - /* Temporary workaround until the WMI sysfs interface goes in */ 100 - MODULE_ALIAS("dmi:*:*Acer*:*:"); 101 - 102 99 /* 103 100 * Interface capability flags 104 101 */
+46 -22
drivers/platform/x86/acerhdf.c
··· 52 52 */ 53 53 #undef START_IN_KERNEL_MODE 54 54 55 - #define DRV_VER "0.5.20" 55 + #define DRV_VER "0.5.22" 56 56 57 57 /* 58 58 * According to the Atom N270 datasheet, ··· 156 156 {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x20, 0x00} }, 157 157 /* Acer 1410 */ 158 158 {"Acer", "Aspire 1410", "v0.3120", 0x55, 0x58, {0x9e, 0x9e, 0x00} }, 159 - /* special BIOS / other */ 159 + {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x9e, 0x00} }, 160 + /* Acer 1810xx */ 161 + {"Acer", "Aspire 1810TZ", "v0.3120", 0x55, 0x58, {0x9e, 0x9e, 0x00} }, 162 + {"Acer", "Aspire 1810T", "v0.3120", 0x55, 0x58, {0x9e, 0x9e, 0x00} }, 163 + {"Acer", "Aspire 1810T", "v1.3303", 0x55, 0x58, {0x9e, 0x9e, 0x00} }, 164 + {"Acer", "Aspire 1810TZ", "v1.3303", 0x55, 0x58, {0x9e, 0x9e, 0x00} }, 165 + /* Gateway */ 160 166 {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x21, 0x00} }, 161 167 {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x20, 0x00} }, 162 - {"Gateway ", "LT31 ", "v1.3103 ", 0x55, 0x58, 163 - {0x10, 0x0f, 0x00} }, 164 - {"Gateway ", "LT31 ", "v1.3201 ", 0x55, 0x58, 165 - {0x10, 0x0f, 0x00} }, 166 - {"Gateway ", "LT31 ", "v1.3302 ", 0x55, 0x58, 167 - {0x10, 0x0f, 0x00} }, 168 + {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x10, 0x0f, 0x00} }, 169 + {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x10, 0x0f, 0x00} }, 170 + {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x10, 0x0f, 0x00} }, 171 + /* Packard Bell */ 168 172 {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x21, 0x00} }, 169 173 {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x20, 0x00} }, 170 174 {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x21, 0x00} }, 171 175 {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x20, 0x00} }, 176 + {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x9e, 0x00} }, 177 + {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x9e, 0x00} }, 172 178 /* pewpew-terminator */ 173 179 {"", "", "", 0, 0, {0, 0, 0} } 174 180 }; ··· 492 486 .remove = acerhdf_remove, 493 487 }; 494 488 489 + /* checks if str begins with start */ 490 + static int str_starts_with(const char *str, const char *start) 491 + { 492 + unsigned long str_len = 0, start_len = 0; 493 + 494 + str_len = strlen(str); 495 + start_len = strlen(start); 496 + 497 + if (str_len >= start_len && 498 + !strncmp(str, start, start_len)) 499 + return 1; 500 + 501 + return 0; 502 + } 495 503 496 504 /* check hardware */ 497 505 static int acerhdf_check_hardware(void) 498 506 { 499 507 char const *vendor, *version, *product; 500 - int i; 501 - unsigned long prod_len = 0; 508 + const struct bios_settings_t *bt = NULL; 502 509 503 510 /* get BIOS data */ 504 511 vendor = dmi_get_system_info(DMI_SYS_VENDOR); ··· 533 514 kernelmode = 0; 534 515 } 535 516 536 - prod_len = strlen(product); 537 - 538 517 if (verbose) 539 518 pr_info("BIOS info: %s %s, product: %s\n", 540 519 vendor, version, product); 541 520 542 521 /* search BIOS version and vendor in BIOS settings table */ 543 - for (i = 0; bios_tbl[i].version[0]; i++) { 544 - if (strlen(bios_tbl[i].product) >= prod_len && 545 - !strncmp(bios_tbl[i].product, product, 546 - strlen(bios_tbl[i].product)) && 547 - !strcmp(bios_tbl[i].vendor, vendor) && 548 - !strcmp(bios_tbl[i].version, version)) { 549 - bios_cfg = &bios_tbl[i]; 522 + for (bt = bios_tbl; bt->vendor[0]; bt++) { 523 + /* 524 + * check if actual hardware BIOS vendor, product and version 525 + * IDs start with the strings of BIOS table entry 526 + */ 527 + if (str_starts_with(vendor, bt->vendor) && 528 + str_starts_with(product, bt->product) && 529 + str_starts_with(version, bt->version)) { 530 + bios_cfg = bt; 550 531 break; 551 532 } 552 533 } ··· 659 640 MODULE_LICENSE("GPL"); 660 641 MODULE_AUTHOR("Peter Feuerer"); 661 642 MODULE_DESCRIPTION("Aspire One temperature and fan driver"); 662 - MODULE_ALIAS("dmi:*:*Acer*:*:"); 663 - MODULE_ALIAS("dmi:*:*Gateway*:*:"); 664 - MODULE_ALIAS("dmi:*:*Packard Bell*:*:"); 643 + MODULE_ALIAS("dmi:*:*Acer*:pnAOA*:"); 644 + MODULE_ALIAS("dmi:*:*Acer*:pnAspire 1410*:"); 645 + MODULE_ALIAS("dmi:*:*Acer*:pnAspire 1810*:"); 646 + MODULE_ALIAS("dmi:*:*Gateway*:pnAOA*:"); 647 + MODULE_ALIAS("dmi:*:*Gateway*:pnLT31*:"); 648 + MODULE_ALIAS("dmi:*:*Packard Bell*:pnAOA*:"); 649 + MODULE_ALIAS("dmi:*:*Packard Bell*:pnDOA*:"); 650 + MODULE_ALIAS("dmi:*:*Packard Bell*:pnDOTMU*:"); 665 651 666 652 module_init(acerhdf_init); 667 653 module_exit(acerhdf_exit);
+194 -127
drivers/platform/x86/asus_acpi.c
··· 35 35 #include <linux/init.h> 36 36 #include <linux/types.h> 37 37 #include <linux/proc_fs.h> 38 + #include <linux/seq_file.h> 38 39 #include <linux/backlight.h> 39 40 #include <acpi/acpi_drivers.h> 40 41 #include <acpi/acpi_bus.h> ··· 514 513 return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER); 515 514 } 516 515 517 - /* 518 - * We write our info in page, we begin at offset off and cannot write more 519 - * than count bytes. We set eof to 1 if we handle those 2 values. We return the 520 - * number of bytes written in page 521 - */ 522 - static int 523 - proc_read_info(char *page, char **start, off_t off, int count, int *eof, 524 - void *data) 516 + static int asus_info_proc_show(struct seq_file *m, void *v) 525 517 { 526 - int len = 0; 527 518 int temp; 528 - char buf[16]; /* enough for all info */ 529 - /* 530 - * We use the easy way, we don't care of off and count, 531 - * so we don't set eof to 1 532 - */ 533 519 534 - len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n"); 535 - len += sprintf(page + len, "Model reference : %s\n", 536 - hotk->methods->name); 520 + seq_printf(m, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n"); 521 + seq_printf(m, "Model reference : %s\n", hotk->methods->name); 537 522 /* 538 523 * The SFUN method probably allows the original driver to get the list 539 524 * of features supported by a given model. For now, 0x0100 or 0x0800 ··· 527 540 * The significance of others is yet to be found. 528 541 */ 529 542 if (read_acpi_int(hotk->handle, "SFUN", &temp)) 530 - len += 531 - sprintf(page + len, "SFUN value : 0x%04x\n", temp); 543 + seq_printf(m, "SFUN value : 0x%04x\n", temp); 532 544 /* 533 545 * Another value for userspace: the ASYM method returns 0x02 for 534 546 * battery low and 0x04 for battery critical, its readings tend to be ··· 536 550 * silently ignored. 537 551 */ 538 552 if (read_acpi_int(hotk->handle, "ASYM", &temp)) 539 - len += 540 - sprintf(page + len, "ASYM value : 0x%04x\n", temp); 553 + seq_printf(m, "ASYM value : 0x%04x\n", temp); 541 554 if (asus_info) { 542 - snprintf(buf, 16, "%d", asus_info->length); 543 - len += sprintf(page + len, "DSDT length : %s\n", buf); 544 - snprintf(buf, 16, "%d", asus_info->checksum); 545 - len += sprintf(page + len, "DSDT checksum : %s\n", buf); 546 - snprintf(buf, 16, "%d", asus_info->revision); 547 - len += sprintf(page + len, "DSDT revision : %s\n", buf); 548 - snprintf(buf, 7, "%s", asus_info->oem_id); 549 - len += sprintf(page + len, "OEM id : %s\n", buf); 550 - snprintf(buf, 9, "%s", asus_info->oem_table_id); 551 - len += sprintf(page + len, "OEM table id : %s\n", buf); 552 - snprintf(buf, 16, "%x", asus_info->oem_revision); 553 - len += sprintf(page + len, "OEM revision : 0x%s\n", buf); 554 - snprintf(buf, 5, "%s", asus_info->asl_compiler_id); 555 - len += sprintf(page + len, "ASL comp vendor id : %s\n", buf); 556 - snprintf(buf, 16, "%x", asus_info->asl_compiler_revision); 557 - len += sprintf(page + len, "ASL comp revision : 0x%s\n", buf); 555 + seq_printf(m, "DSDT length : %d\n", asus_info->length); 556 + seq_printf(m, "DSDT checksum : %d\n", asus_info->checksum); 557 + seq_printf(m, "DSDT revision : %d\n", asus_info->revision); 558 + seq_printf(m, "OEM id : %.*s\n", ACPI_OEM_ID_SIZE, asus_info->oem_id); 559 + seq_printf(m, "OEM table id : %.*s\n", ACPI_OEM_TABLE_ID_SIZE, asus_info->oem_table_id); 560 + seq_printf(m, "OEM revision : 0x%x\n", asus_info->oem_revision); 561 + seq_printf(m, "ASL comp vendor id : %.*s\n", ACPI_NAME_SIZE, asus_info->asl_compiler_id); 562 + seq_printf(m, "ASL comp revision : 0x%x\n", asus_info->asl_compiler_revision); 558 563 } 559 564 560 - return len; 565 + return 0; 561 566 } 567 + 568 + static int asus_info_proc_open(struct inode *inode, struct file *file) 569 + { 570 + return single_open(file, asus_info_proc_show, NULL); 571 + } 572 + 573 + static const struct file_operations asus_info_proc_fops = { 574 + .owner = THIS_MODULE, 575 + .open = asus_info_proc_open, 576 + .read = seq_read, 577 + .llseek = seq_lseek, 578 + .release = single_release, 579 + }; 562 580 563 581 /* 564 582 * /proc handlers ··· 629 639 /* 630 640 * Proc handlers for MLED 631 641 */ 632 - static int 633 - proc_read_mled(char *page, char **start, off_t off, int count, int *eof, 634 - void *data) 642 + static int mled_proc_show(struct seq_file *m, void *v) 635 643 { 636 - return sprintf(page, "%d\n", 637 - read_led(hotk->methods->mled_status, MLED_ON)); 644 + seq_printf(m, "%d\n", read_led(hotk->methods->mled_status, MLED_ON)); 645 + return 0; 638 646 } 639 647 640 - static int 641 - proc_write_mled(struct file *file, const char __user *buffer, 642 - unsigned long count, void *data) 648 + static int mled_proc_open(struct inode *inode, struct file *file) 649 + { 650 + return single_open(file, mled_proc_show, NULL); 651 + } 652 + 653 + static ssize_t mled_proc_write(struct file *file, const char __user *buffer, 654 + size_t count, loff_t *pos) 643 655 { 644 656 return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1); 645 657 } 646 658 659 + static const struct file_operations mled_proc_fops = { 660 + .owner = THIS_MODULE, 661 + .open = mled_proc_open, 662 + .read = seq_read, 663 + .llseek = seq_lseek, 664 + .release = single_release, 665 + .write = mled_proc_write, 666 + }; 667 + 647 668 /* 648 669 * Proc handlers for LED display 649 670 */ 650 - static int 651 - proc_read_ledd(char *page, char **start, off_t off, int count, int *eof, 652 - void *data) 671 + static int ledd_proc_show(struct seq_file *m, void *v) 653 672 { 654 - return sprintf(page, "0x%08x\n", hotk->ledd_status); 673 + seq_printf(m, "0x%08x\n", hotk->ledd_status); 674 + return 0; 655 675 } 656 676 657 - static int 658 - proc_write_ledd(struct file *file, const char __user *buffer, 659 - unsigned long count, void *data) 677 + static int ledd_proc_open(struct inode *inode, struct file *file) 678 + { 679 + return single_open(file, ledd_proc_show, NULL); 680 + } 681 + 682 + static ssize_t ledd_proc_write(struct file *file, const char __user *buffer, 683 + size_t count, loff_t *pos) 660 684 { 661 685 int rv, value; 662 686 ··· 686 682 return rv; 687 683 } 688 684 685 + static const struct file_operations ledd_proc_fops = { 686 + .owner = THIS_MODULE, 687 + .open = ledd_proc_open, 688 + .read = seq_read, 689 + .llseek = seq_lseek, 690 + .release = single_release, 691 + .write = ledd_proc_write, 692 + }; 693 + 689 694 /* 690 695 * Proc handlers for WLED 691 696 */ 692 - static int 693 - proc_read_wled(char *page, char **start, off_t off, int count, int *eof, 694 - void *data) 697 + static int wled_proc_show(struct seq_file *m, void *v) 695 698 { 696 - return sprintf(page, "%d\n", 697 - read_led(hotk->methods->wled_status, WLED_ON)); 699 + seq_printf(m, "%d\n", read_led(hotk->methods->wled_status, WLED_ON)); 700 + return 0; 698 701 } 699 702 700 - static int 701 - proc_write_wled(struct file *file, const char __user *buffer, 702 - unsigned long count, void *data) 703 + static int wled_proc_open(struct inode *inode, struct file *file) 704 + { 705 + return single_open(file, wled_proc_show, NULL); 706 + } 707 + 708 + static ssize_t wled_proc_write(struct file *file, const char __user *buffer, 709 + size_t count, loff_t *pos) 703 710 { 704 711 return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0); 705 712 } 706 713 714 + static const struct file_operations wled_proc_fops = { 715 + .owner = THIS_MODULE, 716 + .open = wled_proc_open, 717 + .read = seq_read, 718 + .llseek = seq_lseek, 719 + .release = single_release, 720 + .write = wled_proc_write, 721 + }; 722 + 707 723 /* 708 724 * Proc handlers for Bluetooth 709 725 */ 710 - static int 711 - proc_read_bluetooth(char *page, char **start, off_t off, int count, int *eof, 712 - void *data) 726 + static int bluetooth_proc_show(struct seq_file *m, void *v) 713 727 { 714 - return sprintf(page, "%d\n", read_led(hotk->methods->bt_status, BT_ON)); 728 + seq_printf(m, "%d\n", read_led(hotk->methods->bt_status, BT_ON)); 729 + return 0; 715 730 } 716 731 717 - static int 718 - proc_write_bluetooth(struct file *file, const char __user *buffer, 719 - unsigned long count, void *data) 732 + static int bluetooth_proc_open(struct inode *inode, struct file *file) 733 + { 734 + return single_open(file, bluetooth_proc_show, NULL); 735 + } 736 + 737 + static ssize_t bluetooth_proc_write(struct file *file, 738 + const char __user *buffer, size_t count, loff_t *pos) 720 739 { 721 740 /* Note: mt_bt_switch controls both internal Bluetooth adapter's 722 741 presence and its LED */ 723 742 return write_led(buffer, count, hotk->methods->mt_bt_switch, BT_ON, 0); 724 743 } 725 744 745 + static const struct file_operations bluetooth_proc_fops = { 746 + .owner = THIS_MODULE, 747 + .open = bluetooth_proc_open, 748 + .read = seq_read, 749 + .llseek = seq_lseek, 750 + .release = single_release, 751 + .write = bluetooth_proc_write, 752 + }; 753 + 726 754 /* 727 755 * Proc handlers for TLED 728 756 */ 729 - static int 730 - proc_read_tled(char *page, char **start, off_t off, int count, int *eof, 731 - void *data) 757 + static int tled_proc_show(struct seq_file *m, void *v) 732 758 { 733 - return sprintf(page, "%d\n", 734 - read_led(hotk->methods->tled_status, TLED_ON)); 759 + seq_printf(m, "%d\n", read_led(hotk->methods->tled_status, TLED_ON)); 760 + return 0; 735 761 } 736 762 737 - static int 738 - proc_write_tled(struct file *file, const char __user *buffer, 739 - unsigned long count, void *data) 763 + static int tled_proc_open(struct inode *inode, struct file *file) 764 + { 765 + return single_open(file, tled_proc_show, NULL); 766 + } 767 + 768 + static ssize_t tled_proc_write(struct file *file, const char __user *buffer, 769 + size_t count, loff_t *pos) 740 770 { 741 771 return write_led(buffer, count, hotk->methods->mt_tled, TLED_ON, 0); 742 772 } 773 + 774 + static const struct file_operations tled_proc_fops = { 775 + .owner = THIS_MODULE, 776 + .open = tled_proc_open, 777 + .read = seq_read, 778 + .llseek = seq_lseek, 779 + .release = single_release, 780 + .write = tled_proc_write, 781 + }; 743 782 744 783 static int get_lcd_state(void) 745 784 { ··· 876 829 877 830 } 878 831 879 - static int 880 - proc_read_lcd(char *page, char **start, off_t off, int count, int *eof, 881 - void *data) 832 + static int lcd_proc_show(struct seq_file *m, void *v) 882 833 { 883 - return sprintf(page, "%d\n", get_lcd_state()); 834 + seq_printf(m, "%d\n", get_lcd_state()); 835 + return 0; 884 836 } 885 837 886 - static int 887 - proc_write_lcd(struct file *file, const char __user *buffer, 888 - unsigned long count, void *data) 838 + static int lcd_proc_open(struct inode *inode, struct file *file) 839 + { 840 + return single_open(file, lcd_proc_show, NULL); 841 + } 842 + 843 + static ssize_t lcd_proc_write(struct file *file, const char __user *buffer, 844 + size_t count, loff_t *pos) 889 845 { 890 846 int rv, value; 891 847 ··· 897 847 set_lcd_state(value); 898 848 return rv; 899 849 } 850 + 851 + static const struct file_operations lcd_proc_fops = { 852 + .owner = THIS_MODULE, 853 + .open = lcd_proc_open, 854 + .read = seq_read, 855 + .llseek = seq_lseek, 856 + .release = single_release, 857 + .write = lcd_proc_write, 858 + }; 900 859 901 860 static int read_brightness(struct backlight_device *bd) 902 861 { ··· 966 907 return set_brightness(bd->props.brightness); 967 908 } 968 909 969 - static int 970 - proc_read_brn(char *page, char **start, off_t off, int count, int *eof, 971 - void *data) 910 + static int brn_proc_show(struct seq_file *m, void *v) 972 911 { 973 - return sprintf(page, "%d\n", read_brightness(NULL)); 912 + seq_printf(m, "%d\n", read_brightness(NULL)); 913 + return 0; 974 914 } 975 915 976 - static int 977 - proc_write_brn(struct file *file, const char __user *buffer, 978 - unsigned long count, void *data) 916 + static int brn_proc_open(struct inode *inode, struct file *file) 917 + { 918 + return single_open(file, brn_proc_show, NULL); 919 + } 920 + 921 + static ssize_t brn_proc_write(struct file *file, const char __user *buffer, 922 + size_t count, loff_t *pos) 979 923 { 980 924 int rv, value; 981 925 ··· 990 928 } 991 929 return rv; 992 930 } 931 + 932 + static const struct file_operations brn_proc_fops = { 933 + .owner = THIS_MODULE, 934 + .open = brn_proc_open, 935 + .read = seq_read, 936 + .llseek = seq_lseek, 937 + .release = single_release, 938 + .write = brn_proc_write, 939 + }; 993 940 994 941 static void set_display(int value) 995 942 { ··· 1013 942 * Now, *this* one could be more user-friendly, but so far, no-one has 1014 943 * complained. The significance of bits is the same as in proc_write_disp() 1015 944 */ 1016 - static int 1017 - proc_read_disp(char *page, char **start, off_t off, int count, int *eof, 1018 - void *data) 945 + static int disp_proc_show(struct seq_file *m, void *v) 1019 946 { 1020 947 int value = 0; 1021 948 ··· 1021 952 printk(KERN_WARNING 1022 953 "Asus ACPI: Error reading display status\n"); 1023 954 value &= 0x07; /* needed for some models, shouldn't hurt others */ 1024 - return sprintf(page, "%d\n", value); 955 + seq_printf(m, "%d\n", value); 956 + return 0; 957 + } 958 + 959 + static int disp_proc_open(struct inode *inode, struct file *file) 960 + { 961 + return single_open(file, disp_proc_show, NULL); 1025 962 } 1026 963 1027 964 /* ··· 1036 961 * (bitwise) of these will suffice. I never actually tested 3 displays hooked 1037 962 * up simultaneously, so be warned. See the acpi4asus README for more info. 1038 963 */ 1039 - static int 1040 - proc_write_disp(struct file *file, const char __user *buffer, 1041 - unsigned long count, void *data) 964 + static ssize_t disp_proc_write(struct file *file, const char __user *buffer, 965 + size_t count, loff_t *pos) 1042 966 { 1043 967 int rv, value; 1044 968 ··· 1047 973 return rv; 1048 974 } 1049 975 1050 - typedef int (proc_readfunc) (char *page, char **start, off_t off, int count, 1051 - int *eof, void *data); 1052 - typedef int (proc_writefunc) (struct file *file, const char __user *buffer, 1053 - unsigned long count, void *data); 976 + static const struct file_operations disp_proc_fops = { 977 + .owner = THIS_MODULE, 978 + .open = disp_proc_open, 979 + .read = seq_read, 980 + .llseek = seq_lseek, 981 + .release = single_release, 982 + .write = disp_proc_write, 983 + }; 1054 984 1055 985 static int 1056 - asus_proc_add(char *name, proc_writefunc *writefunc, 1057 - proc_readfunc *readfunc, mode_t mode, 986 + asus_proc_add(char *name, const struct file_operations *proc_fops, mode_t mode, 1058 987 struct acpi_device *device) 1059 988 { 1060 - struct proc_dir_entry *proc = 1061 - create_proc_entry(name, mode, acpi_device_dir(device)); 989 + struct proc_dir_entry *proc; 990 + 991 + proc = proc_create_data(name, mode, acpi_device_dir(device), 992 + proc_fops, acpi_driver_data(device)); 1062 993 if (!proc) { 1063 994 printk(KERN_WARNING " Unable to create %s fs entry\n", name); 1064 995 return -1; 1065 996 } 1066 - proc->write_proc = writefunc; 1067 - proc->read_proc = readfunc; 1068 - proc->data = acpi_driver_data(device); 1069 997 proc->uid = asus_uid; 1070 998 proc->gid = asus_gid; 1071 999 return 0; ··· 1096 1020 if (!acpi_device_dir(device)) 1097 1021 return -ENODEV; 1098 1022 1099 - proc = create_proc_entry(PROC_INFO, mode, acpi_device_dir(device)); 1023 + proc = proc_create(PROC_INFO, mode, acpi_device_dir(device), 1024 + &asus_info_proc_fops); 1100 1025 if (proc) { 1101 - proc->read_proc = proc_read_info; 1102 - proc->data = acpi_driver_data(device); 1103 1026 proc->uid = asus_uid; 1104 1027 proc->gid = asus_gid; 1105 1028 } else { ··· 1107 1032 } 1108 1033 1109 1034 if (hotk->methods->mt_wled) { 1110 - asus_proc_add(PROC_WLED, &proc_write_wled, &proc_read_wled, 1111 - mode, device); 1035 + asus_proc_add(PROC_WLED, &wled_proc_fops, mode, device); 1112 1036 } 1113 1037 1114 1038 if (hotk->methods->mt_ledd) { 1115 - asus_proc_add(PROC_LEDD, &proc_write_ledd, &proc_read_ledd, 1116 - mode, device); 1039 + asus_proc_add(PROC_LEDD, &ledd_proc_fops, mode, device); 1117 1040 } 1118 1041 1119 1042 if (hotk->methods->mt_mled) { 1120 - asus_proc_add(PROC_MLED, &proc_write_mled, &proc_read_mled, 1121 - mode, device); 1043 + asus_proc_add(PROC_MLED, &mled_proc_fops, mode, device); 1122 1044 } 1123 1045 1124 1046 if (hotk->methods->mt_tled) { 1125 - asus_proc_add(PROC_TLED, &proc_write_tled, &proc_read_tled, 1126 - mode, device); 1047 + asus_proc_add(PROC_TLED, &tled_proc_fops, mode, device); 1127 1048 } 1128 1049 1129 1050 if (hotk->methods->mt_bt_switch) { 1130 - asus_proc_add(PROC_BT, &proc_write_bluetooth, 1131 - &proc_read_bluetooth, mode, device); 1051 + asus_proc_add(PROC_BT, &bluetooth_proc_fops, mode, device); 1132 1052 } 1133 1053 1134 1054 /* ··· 1131 1061 * accessible from the keyboard 1132 1062 */ 1133 1063 if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) { 1134 - asus_proc_add(PROC_LCD, &proc_write_lcd, &proc_read_lcd, mode, 1135 - device); 1064 + asus_proc_add(PROC_LCD, &lcd_proc_fops, mode, device); 1136 1065 } 1137 1066 1138 1067 if ((hotk->methods->brightness_up && hotk->methods->brightness_down) || 1139 1068 (hotk->methods->brightness_get && hotk->methods->brightness_set)) { 1140 - asus_proc_add(PROC_BRN, &proc_write_brn, &proc_read_brn, mode, 1141 - device); 1069 + asus_proc_add(PROC_BRN, &brn_proc_fops, mode, device); 1142 1070 } 1143 1071 1144 1072 if (hotk->methods->display_set) { 1145 - asus_proc_add(PROC_DISP, &proc_write_disp, &proc_read_disp, 1146 - mode, device); 1073 + asus_proc_add(PROC_DISP, &disp_proc_fops, mode, device); 1147 1074 } 1148 1075 1149 1076 return 0;
+609
drivers/platform/x86/classmate-laptop.c
··· 1 + /* 2 + * Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com> 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License as published by 6 + * the Free Software Foundation; either version 2 of the License, or 7 + * (at your option) any later version. 8 + * 9 + * This program is distributed in the hope that it will be useful, 10 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 + * GNU General Public License for more details. 13 + * 14 + * You should have received a copy of the GNU General Public License along 15 + * with this program; if not, write to the Free Software Foundation, Inc., 16 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 + */ 18 + 19 + 20 + #include <linux/init.h> 21 + #include <linux/module.h> 22 + #include <linux/workqueue.h> 23 + #include <acpi/acpi_drivers.h> 24 + #include <linux/backlight.h> 25 + #include <linux/input.h> 26 + 27 + MODULE_LICENSE("GPL"); 28 + 29 + 30 + struct cmpc_accel { 31 + int sensitivity; 32 + }; 33 + 34 + #define CMPC_ACCEL_SENSITIVITY_DEFAULT 5 35 + 36 + 37 + /* 38 + * Generic input device code. 39 + */ 40 + 41 + typedef void (*input_device_init)(struct input_dev *dev); 42 + 43 + static int cmpc_add_acpi_notify_device(struct acpi_device *acpi, char *name, 44 + input_device_init idev_init) 45 + { 46 + struct input_dev *inputdev; 47 + int error; 48 + 49 + inputdev = input_allocate_device(); 50 + if (!inputdev) 51 + return -ENOMEM; 52 + inputdev->name = name; 53 + inputdev->dev.parent = &acpi->dev; 54 + idev_init(inputdev); 55 + error = input_register_device(inputdev); 56 + if (error) { 57 + input_free_device(inputdev); 58 + return error; 59 + } 60 + dev_set_drvdata(&acpi->dev, inputdev); 61 + return 0; 62 + } 63 + 64 + static int cmpc_remove_acpi_notify_device(struct acpi_device *acpi) 65 + { 66 + struct input_dev *inputdev = dev_get_drvdata(&acpi->dev); 67 + input_unregister_device(inputdev); 68 + return 0; 69 + } 70 + 71 + /* 72 + * Accelerometer code. 73 + */ 74 + static acpi_status cmpc_start_accel(acpi_handle handle) 75 + { 76 + union acpi_object param[2]; 77 + struct acpi_object_list input; 78 + acpi_status status; 79 + 80 + param[0].type = ACPI_TYPE_INTEGER; 81 + param[0].integer.value = 0x3; 82 + param[1].type = ACPI_TYPE_INTEGER; 83 + input.count = 2; 84 + input.pointer = param; 85 + status = acpi_evaluate_object(handle, "ACMD", &input, NULL); 86 + return status; 87 + } 88 + 89 + static acpi_status cmpc_stop_accel(acpi_handle handle) 90 + { 91 + union acpi_object param[2]; 92 + struct acpi_object_list input; 93 + acpi_status status; 94 + 95 + param[0].type = ACPI_TYPE_INTEGER; 96 + param[0].integer.value = 0x4; 97 + param[1].type = ACPI_TYPE_INTEGER; 98 + input.count = 2; 99 + input.pointer = param; 100 + status = acpi_evaluate_object(handle, "ACMD", &input, NULL); 101 + return status; 102 + } 103 + 104 + static acpi_status cmpc_accel_set_sensitivity(acpi_handle handle, int val) 105 + { 106 + union acpi_object param[2]; 107 + struct acpi_object_list input; 108 + 109 + param[0].type = ACPI_TYPE_INTEGER; 110 + param[0].integer.value = 0x02; 111 + param[1].type = ACPI_TYPE_INTEGER; 112 + param[1].integer.value = val; 113 + input.count = 2; 114 + input.pointer = param; 115 + return acpi_evaluate_object(handle, "ACMD", &input, NULL); 116 + } 117 + 118 + static acpi_status cmpc_get_accel(acpi_handle handle, 119 + unsigned char *x, 120 + unsigned char *y, 121 + unsigned char *z) 122 + { 123 + union acpi_object param[2]; 124 + struct acpi_object_list input; 125 + struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, 0 }; 126 + unsigned char *locs; 127 + acpi_status status; 128 + 129 + param[0].type = ACPI_TYPE_INTEGER; 130 + param[0].integer.value = 0x01; 131 + param[1].type = ACPI_TYPE_INTEGER; 132 + input.count = 2; 133 + input.pointer = param; 134 + status = acpi_evaluate_object(handle, "ACMD", &input, &output); 135 + if (ACPI_SUCCESS(status)) { 136 + union acpi_object *obj; 137 + obj = output.pointer; 138 + locs = obj->buffer.pointer; 139 + *x = locs[0]; 140 + *y = locs[1]; 141 + *z = locs[2]; 142 + kfree(output.pointer); 143 + } 144 + return status; 145 + } 146 + 147 + static void cmpc_accel_handler(struct acpi_device *dev, u32 event) 148 + { 149 + if (event == 0x81) { 150 + unsigned char x, y, z; 151 + acpi_status status; 152 + 153 + status = cmpc_get_accel(dev->handle, &x, &y, &z); 154 + if (ACPI_SUCCESS(status)) { 155 + struct input_dev *inputdev = dev_get_drvdata(&dev->dev); 156 + 157 + input_report_abs(inputdev, ABS_X, x); 158 + input_report_abs(inputdev, ABS_Y, y); 159 + input_report_abs(inputdev, ABS_Z, z); 160 + input_sync(inputdev); 161 + } 162 + } 163 + } 164 + 165 + static ssize_t cmpc_accel_sensitivity_show(struct device *dev, 166 + struct device_attribute *attr, 167 + char *buf) 168 + { 169 + struct acpi_device *acpi; 170 + struct input_dev *inputdev; 171 + struct cmpc_accel *accel; 172 + 173 + acpi = to_acpi_device(dev); 174 + inputdev = dev_get_drvdata(&acpi->dev); 175 + accel = dev_get_drvdata(&inputdev->dev); 176 + 177 + return sprintf(buf, "%d\n", accel->sensitivity); 178 + } 179 + 180 + static ssize_t cmpc_accel_sensitivity_store(struct device *dev, 181 + struct device_attribute *attr, 182 + const char *buf, size_t count) 183 + { 184 + struct acpi_device *acpi; 185 + struct input_dev *inputdev; 186 + struct cmpc_accel *accel; 187 + unsigned long sensitivity; 188 + int r; 189 + 190 + acpi = to_acpi_device(dev); 191 + inputdev = dev_get_drvdata(&acpi->dev); 192 + accel = dev_get_drvdata(&inputdev->dev); 193 + 194 + r = strict_strtoul(buf, 0, &sensitivity); 195 + if (r) 196 + return r; 197 + 198 + accel->sensitivity = sensitivity; 199 + cmpc_accel_set_sensitivity(acpi->handle, sensitivity); 200 + 201 + return strnlen(buf, count); 202 + } 203 + 204 + struct device_attribute cmpc_accel_sensitivity_attr = { 205 + .attr = { .name = "sensitivity", .mode = 0660 }, 206 + .show = cmpc_accel_sensitivity_show, 207 + .store = cmpc_accel_sensitivity_store 208 + }; 209 + 210 + static int cmpc_accel_open(struct input_dev *input) 211 + { 212 + struct acpi_device *acpi; 213 + 214 + acpi = to_acpi_device(input->dev.parent); 215 + if (ACPI_SUCCESS(cmpc_start_accel(acpi->handle))) 216 + return 0; 217 + return -EIO; 218 + } 219 + 220 + static void cmpc_accel_close(struct input_dev *input) 221 + { 222 + struct acpi_device *acpi; 223 + 224 + acpi = to_acpi_device(input->dev.parent); 225 + cmpc_stop_accel(acpi->handle); 226 + } 227 + 228 + static void cmpc_accel_idev_init(struct input_dev *inputdev) 229 + { 230 + set_bit(EV_ABS, inputdev->evbit); 231 + input_set_abs_params(inputdev, ABS_X, 0, 255, 8, 0); 232 + input_set_abs_params(inputdev, ABS_Y, 0, 255, 8, 0); 233 + input_set_abs_params(inputdev, ABS_Z, 0, 255, 8, 0); 234 + inputdev->open = cmpc_accel_open; 235 + inputdev->close = cmpc_accel_close; 236 + } 237 + 238 + static int cmpc_accel_add(struct acpi_device *acpi) 239 + { 240 + int error; 241 + struct input_dev *inputdev; 242 + struct cmpc_accel *accel; 243 + 244 + accel = kmalloc(sizeof(*accel), GFP_KERNEL); 245 + if (!accel) 246 + return -ENOMEM; 247 + 248 + accel->sensitivity = CMPC_ACCEL_SENSITIVITY_DEFAULT; 249 + cmpc_accel_set_sensitivity(acpi->handle, accel->sensitivity); 250 + 251 + error = device_create_file(&acpi->dev, &cmpc_accel_sensitivity_attr); 252 + if (error) 253 + goto failed_file; 254 + 255 + error = cmpc_add_acpi_notify_device(acpi, "cmpc_accel", 256 + cmpc_accel_idev_init); 257 + if (error) 258 + goto failed_input; 259 + 260 + inputdev = dev_get_drvdata(&acpi->dev); 261 + dev_set_drvdata(&inputdev->dev, accel); 262 + 263 + return 0; 264 + 265 + failed_input: 266 + device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr); 267 + failed_file: 268 + kfree(accel); 269 + return error; 270 + } 271 + 272 + static int cmpc_accel_remove(struct acpi_device *acpi, int type) 273 + { 274 + struct input_dev *inputdev; 275 + struct cmpc_accel *accel; 276 + 277 + inputdev = dev_get_drvdata(&acpi->dev); 278 + accel = dev_get_drvdata(&inputdev->dev); 279 + 280 + device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr); 281 + return cmpc_remove_acpi_notify_device(acpi); 282 + } 283 + 284 + static const struct acpi_device_id cmpc_accel_device_ids[] = { 285 + {"ACCE0000", 0}, 286 + {"", 0} 287 + }; 288 + MODULE_DEVICE_TABLE(acpi, cmpc_accel_device_ids); 289 + 290 + static struct acpi_driver cmpc_accel_acpi_driver = { 291 + .owner = THIS_MODULE, 292 + .name = "cmpc_accel", 293 + .class = "cmpc_accel", 294 + .ids = cmpc_accel_device_ids, 295 + .ops = { 296 + .add = cmpc_accel_add, 297 + .remove = cmpc_accel_remove, 298 + .notify = cmpc_accel_handler, 299 + } 300 + }; 301 + 302 + 303 + /* 304 + * Tablet mode code. 305 + */ 306 + static acpi_status cmpc_get_tablet(acpi_handle handle, 307 + unsigned long long *value) 308 + { 309 + union acpi_object param; 310 + struct acpi_object_list input; 311 + unsigned long long output; 312 + acpi_status status; 313 + 314 + param.type = ACPI_TYPE_INTEGER; 315 + param.integer.value = 0x01; 316 + input.count = 1; 317 + input.pointer = &param; 318 + status = acpi_evaluate_integer(handle, "TCMD", &input, &output); 319 + if (ACPI_SUCCESS(status)) 320 + *value = output; 321 + return status; 322 + } 323 + 324 + static void cmpc_tablet_handler(struct acpi_device *dev, u32 event) 325 + { 326 + unsigned long long val = 0; 327 + struct input_dev *inputdev = dev_get_drvdata(&dev->dev); 328 + 329 + if (event == 0x81) { 330 + if (ACPI_SUCCESS(cmpc_get_tablet(dev->handle, &val))) 331 + input_report_switch(inputdev, SW_TABLET_MODE, !val); 332 + } 333 + } 334 + 335 + static void cmpc_tablet_idev_init(struct input_dev *inputdev) 336 + { 337 + unsigned long long val = 0; 338 + struct acpi_device *acpi; 339 + 340 + set_bit(EV_SW, inputdev->evbit); 341 + set_bit(SW_TABLET_MODE, inputdev->swbit); 342 + 343 + acpi = to_acpi_device(inputdev->dev.parent); 344 + if (ACPI_SUCCESS(cmpc_get_tablet(acpi->handle, &val))) 345 + input_report_switch(inputdev, SW_TABLET_MODE, !val); 346 + } 347 + 348 + static int cmpc_tablet_add(struct acpi_device *acpi) 349 + { 350 + return cmpc_add_acpi_notify_device(acpi, "cmpc_tablet", 351 + cmpc_tablet_idev_init); 352 + } 353 + 354 + static int cmpc_tablet_remove(struct acpi_device *acpi, int type) 355 + { 356 + return cmpc_remove_acpi_notify_device(acpi); 357 + } 358 + 359 + static int cmpc_tablet_resume(struct acpi_device *acpi) 360 + { 361 + struct input_dev *inputdev = dev_get_drvdata(&acpi->dev); 362 + unsigned long long val = 0; 363 + if (ACPI_SUCCESS(cmpc_get_tablet(acpi->handle, &val))) 364 + input_report_switch(inputdev, SW_TABLET_MODE, !val); 365 + return 0; 366 + } 367 + 368 + static const struct acpi_device_id cmpc_tablet_device_ids[] = { 369 + {"TBLT0000", 0}, 370 + {"", 0} 371 + }; 372 + MODULE_DEVICE_TABLE(acpi, cmpc_tablet_device_ids); 373 + 374 + static struct acpi_driver cmpc_tablet_acpi_driver = { 375 + .owner = THIS_MODULE, 376 + .name = "cmpc_tablet", 377 + .class = "cmpc_tablet", 378 + .ids = cmpc_tablet_device_ids, 379 + .ops = { 380 + .add = cmpc_tablet_add, 381 + .remove = cmpc_tablet_remove, 382 + .resume = cmpc_tablet_resume, 383 + .notify = cmpc_tablet_handler, 384 + } 385 + }; 386 + 387 + 388 + /* 389 + * Backlight code. 390 + */ 391 + 392 + static acpi_status cmpc_get_brightness(acpi_handle handle, 393 + unsigned long long *value) 394 + { 395 + union acpi_object param; 396 + struct acpi_object_list input; 397 + unsigned long long output; 398 + acpi_status status; 399 + 400 + param.type = ACPI_TYPE_INTEGER; 401 + param.integer.value = 0xC0; 402 + input.count = 1; 403 + input.pointer = &param; 404 + status = acpi_evaluate_integer(handle, "GRDI", &input, &output); 405 + if (ACPI_SUCCESS(status)) 406 + *value = output; 407 + return status; 408 + } 409 + 410 + static acpi_status cmpc_set_brightness(acpi_handle handle, 411 + unsigned long long value) 412 + { 413 + union acpi_object param[2]; 414 + struct acpi_object_list input; 415 + acpi_status status; 416 + unsigned long long output; 417 + 418 + param[0].type = ACPI_TYPE_INTEGER; 419 + param[0].integer.value = 0xC0; 420 + param[1].type = ACPI_TYPE_INTEGER; 421 + param[1].integer.value = value; 422 + input.count = 2; 423 + input.pointer = param; 424 + status = acpi_evaluate_integer(handle, "GWRI", &input, &output); 425 + return status; 426 + } 427 + 428 + static int cmpc_bl_get_brightness(struct backlight_device *bd) 429 + { 430 + acpi_status status; 431 + acpi_handle handle; 432 + unsigned long long brightness; 433 + 434 + handle = bl_get_data(bd); 435 + status = cmpc_get_brightness(handle, &brightness); 436 + if (ACPI_SUCCESS(status)) 437 + return brightness; 438 + else 439 + return -1; 440 + } 441 + 442 + static int cmpc_bl_update_status(struct backlight_device *bd) 443 + { 444 + acpi_status status; 445 + acpi_handle handle; 446 + 447 + handle = bl_get_data(bd); 448 + status = cmpc_set_brightness(handle, bd->props.brightness); 449 + if (ACPI_SUCCESS(status)) 450 + return 0; 451 + else 452 + return -1; 453 + } 454 + 455 + static struct backlight_ops cmpc_bl_ops = { 456 + .get_brightness = cmpc_bl_get_brightness, 457 + .update_status = cmpc_bl_update_status 458 + }; 459 + 460 + static int cmpc_bl_add(struct acpi_device *acpi) 461 + { 462 + struct backlight_device *bd; 463 + 464 + bd = backlight_device_register("cmpc_bl", &acpi->dev, 465 + acpi->handle, &cmpc_bl_ops); 466 + bd->props.max_brightness = 7; 467 + dev_set_drvdata(&acpi->dev, bd); 468 + return 0; 469 + } 470 + 471 + static int cmpc_bl_remove(struct acpi_device *acpi, int type) 472 + { 473 + struct backlight_device *bd; 474 + 475 + bd = dev_get_drvdata(&acpi->dev); 476 + backlight_device_unregister(bd); 477 + return 0; 478 + } 479 + 480 + static const struct acpi_device_id cmpc_device_ids[] = { 481 + {"IPML200", 0}, 482 + {"", 0} 483 + }; 484 + MODULE_DEVICE_TABLE(acpi, cmpc_device_ids); 485 + 486 + static struct acpi_driver cmpc_bl_acpi_driver = { 487 + .owner = THIS_MODULE, 488 + .name = "cmpc", 489 + .class = "cmpc", 490 + .ids = cmpc_device_ids, 491 + .ops = { 492 + .add = cmpc_bl_add, 493 + .remove = cmpc_bl_remove 494 + } 495 + }; 496 + 497 + 498 + /* 499 + * Extra keys code. 500 + */ 501 + static int cmpc_keys_codes[] = { 502 + KEY_UNKNOWN, 503 + KEY_WLAN, 504 + KEY_SWITCHVIDEOMODE, 505 + KEY_BRIGHTNESSDOWN, 506 + KEY_BRIGHTNESSUP, 507 + KEY_VENDOR, 508 + KEY_MAX 509 + }; 510 + 511 + static void cmpc_keys_handler(struct acpi_device *dev, u32 event) 512 + { 513 + struct input_dev *inputdev; 514 + int code = KEY_MAX; 515 + 516 + if ((event & 0x0F) < ARRAY_SIZE(cmpc_keys_codes)) 517 + code = cmpc_keys_codes[event & 0x0F]; 518 + inputdev = dev_get_drvdata(&dev->dev);; 519 + input_report_key(inputdev, code, !(event & 0x10)); 520 + } 521 + 522 + static void cmpc_keys_idev_init(struct input_dev *inputdev) 523 + { 524 + int i; 525 + 526 + set_bit(EV_KEY, inputdev->evbit); 527 + for (i = 0; cmpc_keys_codes[i] != KEY_MAX; i++) 528 + set_bit(cmpc_keys_codes[i], inputdev->keybit); 529 + } 530 + 531 + static int cmpc_keys_add(struct acpi_device *acpi) 532 + { 533 + return cmpc_add_acpi_notify_device(acpi, "cmpc_keys", 534 + cmpc_keys_idev_init); 535 + } 536 + 537 + static int cmpc_keys_remove(struct acpi_device *acpi, int type) 538 + { 539 + return cmpc_remove_acpi_notify_device(acpi); 540 + } 541 + 542 + static const struct acpi_device_id cmpc_keys_device_ids[] = { 543 + {"FnBT0000", 0}, 544 + {"", 0} 545 + }; 546 + MODULE_DEVICE_TABLE(acpi, cmpc_keys_device_ids); 547 + 548 + static struct acpi_driver cmpc_keys_acpi_driver = { 549 + .owner = THIS_MODULE, 550 + .name = "cmpc_keys", 551 + .class = "cmpc_keys", 552 + .ids = cmpc_keys_device_ids, 553 + .ops = { 554 + .add = cmpc_keys_add, 555 + .remove = cmpc_keys_remove, 556 + .notify = cmpc_keys_handler, 557 + } 558 + }; 559 + 560 + 561 + /* 562 + * General init/exit code. 563 + */ 564 + 565 + static int cmpc_init(void) 566 + { 567 + int r; 568 + 569 + r = acpi_bus_register_driver(&cmpc_keys_acpi_driver); 570 + if (r) 571 + goto failed_keys; 572 + 573 + r = acpi_bus_register_driver(&cmpc_bl_acpi_driver); 574 + if (r) 575 + goto failed_bl; 576 + 577 + r = acpi_bus_register_driver(&cmpc_tablet_acpi_driver); 578 + if (r) 579 + goto failed_tablet; 580 + 581 + r = acpi_bus_register_driver(&cmpc_accel_acpi_driver); 582 + if (r) 583 + goto failed_accel; 584 + 585 + return r; 586 + 587 + failed_accel: 588 + acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver); 589 + 590 + failed_tablet: 591 + acpi_bus_unregister_driver(&cmpc_bl_acpi_driver); 592 + 593 + failed_bl: 594 + acpi_bus_unregister_driver(&cmpc_keys_acpi_driver); 595 + 596 + failed_keys: 597 + return r; 598 + } 599 + 600 + static void cmpc_exit(void) 601 + { 602 + acpi_bus_unregister_driver(&cmpc_accel_acpi_driver); 603 + acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver); 604 + acpi_bus_unregister_driver(&cmpc_bl_acpi_driver); 605 + acpi_bus_unregister_driver(&cmpc_keys_acpi_driver); 606 + } 607 + 608 + module_init(cmpc_init); 609 + module_exit(cmpc_exit);
+22 -24
drivers/platform/x86/dell-wmi.c
··· 238 238 input_sync(dell_wmi_input_dev); 239 239 } 240 240 } 241 + kfree(obj); 241 242 } 242 243 243 244 ··· 325 324 int err; 326 325 327 326 if (wmi_has_guid(DELL_EVENT_GUID)) { 328 - 329 - dmi_walk(find_hk_type, NULL); 330 - 331 - err = dell_wmi_input_setup(); 332 - 333 - if (err) 334 - return err; 335 - 336 - err = wmi_install_notify_handler(DELL_EVENT_GUID, 337 - dell_wmi_notify, NULL); 338 - if (err) { 339 - input_unregister_device(dell_wmi_input_dev); 340 - printk(KERN_ERR "dell-wmi: Unable to register" 341 - " notify handler - %d\n", err); 342 - return err; 343 - } 344 - 345 - acpi_video = acpi_video_backlight_support(); 346 - 347 - } else 348 327 printk(KERN_WARNING "dell-wmi: No known WMI GUID found\n"); 328 + return -ENODEV; 329 + } 330 + 331 + dmi_walk(find_hk_type, NULL); 332 + acpi_video = acpi_video_backlight_support(); 333 + 334 + err = dell_wmi_input_setup(); 335 + if (err) 336 + return err; 337 + 338 + err = wmi_install_notify_handler(DELL_EVENT_GUID, 339 + dell_wmi_notify, NULL); 340 + if (err) { 341 + input_unregister_device(dell_wmi_input_dev); 342 + printk(KERN_ERR 343 + "dell-wmi: Unable to register notify handler - %d\n", 344 + err); 345 + return err; 346 + } 349 347 350 348 return 0; 351 349 } 352 350 353 351 static void __exit dell_wmi_exit(void) 354 352 { 355 - if (wmi_has_guid(DELL_EVENT_GUID)) { 356 - wmi_remove_notify_handler(DELL_EVENT_GUID); 357 - input_unregister_device(dell_wmi_input_dev); 358 - } 353 + wmi_remove_notify_handler(DELL_EVENT_GUID); 354 + input_unregister_device(dell_wmi_input_dev); 359 355 } 360 356 361 357 module_init(dell_wmi_init);
+4 -4
drivers/platform/x86/fujitsu-laptop.c
··· 376 376 377 377 status = 378 378 acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state); 379 - if (status < 0) 380 - return status; 379 + if (ACPI_FAILURE(status)) 380 + return 0; 381 381 382 382 fujitsu->brightness_level = state & 0x0fffffff; 383 383 ··· 398 398 399 399 status = 400 400 acpi_evaluate_integer(fujitsu->acpi_handle, "RBLL", NULL, &state); 401 - if (status < 0) 402 - return status; 401 + if (ACPI_FAILURE(status)) 402 + return -1; 403 403 404 404 fujitsu->max_brightness = state; 405 405
+10 -1
drivers/platform/x86/hp-wmi.c
··· 134 134 135 135 obj = output.pointer; 136 136 137 - if (!obj || obj->type != ACPI_TYPE_BUFFER) 137 + if (!obj) 138 138 return -EINVAL; 139 + else if (obj->type != ACPI_TYPE_BUFFER) { 140 + kfree(obj); 141 + return -EINVAL; 142 + } 139 143 140 144 bios_return = *((struct bios_return *)obj->buffer.pointer); 145 + kfree(obj); 141 146 if (bios_return.return_code > 0) 142 147 return bios_return.return_code * -1; 143 148 else ··· 345 340 346 341 if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) { 347 342 printk(KERN_INFO "HP WMI: Unknown response received\n"); 343 + kfree(obj); 348 344 return; 349 345 } 350 346 351 347 eventcode = *((u8 *) obj->buffer.pointer); 348 + kfree(obj); 352 349 if (eventcode == 0x4) 353 350 eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0, 354 351 0); ··· 388 381 } else 389 382 printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n", 390 383 eventcode); 384 + 385 + kfree(obj); 391 386 } 392 387 393 388 static int __init hp_wmi_input_setup(void)
-10
drivers/platform/x86/msi-wmi.c
··· 34 34 MODULE_ALIAS("wmi:551A1F84-FBDD-4125-91DB-3EA8F44F1D45"); 35 35 MODULE_ALIAS("wmi:B6F3EEF2-3D2F-49DC-9DE3-85BCE18C62F2"); 36 36 37 - /* Temporary workaround until the WMI sysfs interface goes in 38 - { "svn", DMI_SYS_VENDOR }, 39 - { "pn", DMI_PRODUCT_NAME }, 40 - { "pvr", DMI_PRODUCT_VERSION }, 41 - { "rvn", DMI_BOARD_VENDOR }, 42 - { "rn", DMI_BOARD_NAME }, 43 - */ 44 - 45 - MODULE_ALIAS("dmi:*:svnMICRO-STARINTERNATIONAL*:pnMS-6638:*"); 46 - 47 37 #define DRV_NAME "msi-wmi" 48 38 #define DRV_PFX DRV_NAME ": " 49 39
+71 -23
drivers/platform/x86/sony-laptop.c
··· 131 131 N_SONY_RFKILL, 132 132 }; 133 133 134 + static int sony_rfkill_handle; 134 135 static struct rfkill *sony_rfkill_devices[N_SONY_RFKILL]; 135 136 static int sony_rfkill_address[N_SONY_RFKILL] = {0x300, 0x500, 0x700, 0x900}; 136 137 static void sony_nc_rfkill_update(void); ··· 233 232 56, /* 69 SONYPI_EVENT_VOLUME_INC_PRESSED */ 234 233 57, /* 70 SONYPI_EVENT_VOLUME_DEC_PRESSED */ 235 234 -1, /* 71 SONYPI_EVENT_BRIGHTNESS_PRESSED */ 235 + 58, /* 72 SONYPI_EVENT_MEDIA_PRESSED */ 236 236 }; 237 237 238 238 static int sony_laptop_input_keycode_map[] = { ··· 295 293 KEY_F15, /* 55 SONYPI_EVENT_SETTINGKEY_PRESSED */ 296 294 KEY_VOLUMEUP, /* 56 SONYPI_EVENT_VOLUME_INC_PRESSED */ 297 295 KEY_VOLUMEDOWN, /* 57 SONYPI_EVENT_VOLUME_DEC_PRESSED */ 296 + KEY_MEDIA, /* 58 SONYPI_EVENT_MEDIA_PRESSED */ 298 297 }; 299 298 300 299 /* release buttons after a short delay if pressed */ ··· 893 890 { 0x0C, SONYPI_EVENT_FNKEY_RELEASED }, 894 891 { 0x9f, SONYPI_EVENT_CD_EJECT_PRESSED }, 895 892 { 0x1f, SONYPI_EVENT_ANYBUTTON_RELEASED }, 893 + { 0xa1, SONYPI_EVENT_MEDIA_PRESSED }, 894 + { 0x21, SONYPI_EVENT_ANYBUTTON_RELEASED }, 896 895 { 0, 0 }, 897 896 }; 898 897 ··· 966 961 else 967 962 sony_laptop_report_input_event(ev); 968 963 } 969 - } else if (sony_find_snc_handle(0x124) == ev) { 964 + } else if (sony_find_snc_handle(sony_rfkill_handle) == ev) { 970 965 sony_nc_rfkill_update(); 971 966 return; 972 967 } ··· 1072 1067 if (!blocked) 1073 1068 argument |= 0xff0000; 1074 1069 1075 - return sony_call_snc_handle(0x124, argument, &result); 1070 + return sony_call_snc_handle(sony_rfkill_handle, argument, &result); 1076 1071 } 1077 1072 1078 1073 static const struct rfkill_ops sony_rfkill_ops = { ··· 1115 1110 if (!rfk) 1116 1111 return -ENOMEM; 1117 1112 1118 - sony_call_snc_handle(0x124, 0x200, &result); 1113 + sony_call_snc_handle(sony_rfkill_handle, 0x200, &result); 1119 1114 hwblock = !(result & 0x1); 1120 1115 rfkill_set_hw_state(rfk, hwblock); 1121 1116 ··· 1134 1129 int result; 1135 1130 bool hwblock; 1136 1131 1137 - sony_call_snc_handle(0x124, 0x200, &result); 1132 + sony_call_snc_handle(sony_rfkill_handle, 0x200, &result); 1138 1133 hwblock = !(result & 0x1); 1139 1134 1140 1135 for (i = 0; i < N_SONY_RFKILL; i++) { ··· 1150 1145 continue; 1151 1146 } 1152 1147 1153 - sony_call_snc_handle(0x124, argument, &result); 1148 + sony_call_snc_handle(sony_rfkill_handle, argument, &result); 1154 1149 rfkill_set_states(sony_rfkill_devices[i], 1155 1150 !(result & 0xf), false); 1156 1151 } 1157 1152 } 1158 1153 1159 - static int sony_nc_rfkill_setup(struct acpi_device *device) 1154 + static void sony_nc_rfkill_setup(struct acpi_device *device) 1160 1155 { 1161 - int result, ret; 1156 + int offset; 1157 + u8 dev_code, i; 1158 + acpi_status status; 1159 + struct acpi_object_list params; 1160 + union acpi_object in_obj; 1161 + union acpi_object *device_enum; 1162 + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 1162 1163 1163 - if (sony_find_snc_handle(0x124) == -1) 1164 - return -1; 1164 + offset = sony_find_snc_handle(0x124); 1165 + if (offset == -1) { 1166 + offset = sony_find_snc_handle(0x135); 1167 + if (offset == -1) 1168 + return; 1169 + else 1170 + sony_rfkill_handle = 0x135; 1171 + } else 1172 + sony_rfkill_handle = 0x124; 1173 + dprintk("Found rkfill handle: 0x%.4x\n", sony_rfkill_handle); 1165 1174 1166 - ret = sony_call_snc_handle(0x124, 0xb00, &result); 1167 - if (ret) { 1168 - printk(KERN_INFO DRV_PFX 1169 - "Unable to enumerate rfkill devices: %x\n", ret); 1170 - return ret; 1175 + /* need to read the whole buffer returned by the acpi call to SN06 1176 + * here otherwise we may miss some features 1177 + */ 1178 + params.count = 1; 1179 + params.pointer = &in_obj; 1180 + in_obj.type = ACPI_TYPE_INTEGER; 1181 + in_obj.integer.value = offset; 1182 + status = acpi_evaluate_object(sony_nc_acpi_handle, "SN06", &params, 1183 + &buffer); 1184 + if (ACPI_FAILURE(status)) { 1185 + dprintk("Radio device enumeration failed\n"); 1186 + return; 1171 1187 } 1172 1188 1173 - if (result & 0x1) 1174 - sony_nc_setup_rfkill(device, SONY_WIFI); 1175 - if (result & 0x2) 1176 - sony_nc_setup_rfkill(device, SONY_BLUETOOTH); 1177 - if (result & 0x1c) 1178 - sony_nc_setup_rfkill(device, SONY_WWAN); 1179 - if (result & 0x20) 1180 - sony_nc_setup_rfkill(device, SONY_WIMAX); 1189 + device_enum = (union acpi_object *) buffer.pointer; 1190 + if (!device_enum || device_enum->type != ACPI_TYPE_BUFFER) { 1191 + printk(KERN_ERR "Invalid SN06 return object 0x%.2x\n", 1192 + device_enum->type); 1193 + goto out_no_enum; 1194 + } 1181 1195 1182 - return 0; 1196 + /* the buffer is filled with magic numbers describing the devices 1197 + * available, 0xff terminates the enumeration 1198 + */ 1199 + while ((dev_code = *(device_enum->buffer.pointer + i)) != 0xff && 1200 + i < device_enum->buffer.length) { 1201 + i++; 1202 + dprintk("Radio devices, looking at 0x%.2x\n", dev_code); 1203 + 1204 + if (dev_code == 0 && !sony_rfkill_devices[SONY_WIFI]) 1205 + sony_nc_setup_rfkill(device, SONY_WIFI); 1206 + 1207 + if (dev_code == 0x10 && !sony_rfkill_devices[SONY_BLUETOOTH]) 1208 + sony_nc_setup_rfkill(device, SONY_BLUETOOTH); 1209 + 1210 + if ((0xf0 & dev_code) == 0x20 && 1211 + !sony_rfkill_devices[SONY_WWAN]) 1212 + sony_nc_setup_rfkill(device, SONY_WWAN); 1213 + 1214 + if (dev_code == 0x30 && !sony_rfkill_devices[SONY_WIMAX]) 1215 + sony_nc_setup_rfkill(device, SONY_WIMAX); 1216 + } 1217 + 1218 + out_no_enum: 1219 + kfree(buffer.pointer); 1220 + return; 1183 1221 } 1184 1222 1185 1223 static int sony_nc_add(struct acpi_device *device)
+55 -60
drivers/platform/x86/tc1100-wmi.c
··· 47 47 MODULE_LICENSE("GPL"); 48 48 MODULE_ALIAS("wmi:C364AC71-36DB-495A-8494-B439D472A505"); 49 49 50 - static int tc1100_probe(struct platform_device *device); 51 - static int tc1100_remove(struct platform_device *device); 52 - static int tc1100_suspend(struct platform_device *device, pm_message_t state); 53 - static int tc1100_resume(struct platform_device *device); 54 - 55 - static struct platform_driver tc1100_driver = { 56 - .driver = { 57 - .name = "tc1100-wmi", 58 - .owner = THIS_MODULE, 59 - }, 60 - .probe = tc1100_probe, 61 - .remove = tc1100_remove, 62 - .suspend = tc1100_suspend, 63 - .resume = tc1100_resume, 64 - }; 65 - 66 50 static struct platform_device *tc1100_device; 67 51 68 52 struct tc1100_data { ··· 167 183 show_set_bool(wireless, TC1100_INSTANCE_WIRELESS); 168 184 show_set_bool(jogdial, TC1100_INSTANCE_JOGDIAL); 169 185 170 - static void remove_fs(void) 171 - { 172 - device_remove_file(&tc1100_device->dev, &dev_attr_wireless); 173 - device_remove_file(&tc1100_device->dev, &dev_attr_jogdial); 174 - } 186 + static struct attribute *tc1100_attributes[] = { 187 + &dev_attr_wireless.attr, 188 + &dev_attr_jogdial.attr, 189 + NULL 190 + }; 175 191 176 - static int add_fs(void) 177 - { 178 - int ret; 179 - 180 - ret = device_create_file(&tc1100_device->dev, &dev_attr_wireless); 181 - if (ret) 182 - goto add_sysfs_error; 183 - 184 - ret = device_create_file(&tc1100_device->dev, &dev_attr_jogdial); 185 - if (ret) 186 - goto add_sysfs_error; 187 - 188 - return ret; 189 - 190 - add_sysfs_error: 191 - remove_fs(); 192 - return ret; 193 - } 192 + static struct attribute_group tc1100_attribute_group = { 193 + .attrs = tc1100_attributes, 194 + }; 194 195 195 196 /* -------------------------------------------------------------------------- 196 197 Driver Model 197 198 -------------------------------------------------------------------------- */ 198 199 199 - static int tc1100_probe(struct platform_device *device) 200 + static int __init tc1100_probe(struct platform_device *device) 200 201 { 201 - int result = 0; 202 - 203 - result = add_fs(); 204 - return result; 202 + return sysfs_create_group(&device->dev.kobj, &tc1100_attribute_group); 205 203 } 206 204 207 205 208 - static int tc1100_remove(struct platform_device *device) 206 + static int __devexit tc1100_remove(struct platform_device *device) 209 207 { 210 - remove_fs(); 208 + sysfs_remove_group(&device->dev.kobj, &tc1100_attribute_group); 209 + 211 210 return 0; 212 211 } 213 212 214 - static int tc1100_suspend(struct platform_device *dev, pm_message_t state) 213 + #ifdef CONFIG_PM 214 + static int tc1100_suspend(struct device *dev) 215 215 { 216 216 int ret; 217 217 ··· 207 239 if (ret) 208 240 return ret; 209 241 210 - return ret; 242 + return 0; 211 243 } 212 244 213 - static int tc1100_resume(struct platform_device *dev) 245 + static int tc1100_resume(struct device *dev) 214 246 { 215 247 int ret; 216 248 ··· 222 254 if (ret) 223 255 return ret; 224 256 225 - return ret; 257 + return 0; 226 258 } 259 + 260 + static const struct dev_pm_ops tc1100_pm_ops = { 261 + .suspend = tc1100_suspend, 262 + .resume = tc1100_resume, 263 + .freeze = tc1100_suspend, 264 + .restore = tc1100_resume, 265 + }; 266 + #endif 267 + 268 + static struct platform_driver tc1100_driver = { 269 + .driver = { 270 + .name = "tc1100-wmi", 271 + .owner = THIS_MODULE, 272 + #ifdef CONFIG_PM 273 + .pm = &tc1100_pm_ops, 274 + #endif 275 + }, 276 + .remove = __devexit_p(tc1100_remove), 277 + }; 227 278 228 279 static int __init tc1100_init(void) 229 280 { 230 - int result = 0; 281 + int error; 231 282 232 283 if (!wmi_has_guid(GUID)) 233 284 return -ENODEV; 234 285 235 - result = platform_driver_register(&tc1100_driver); 236 - if (result) 237 - return result; 238 - 239 286 tc1100_device = platform_device_alloc("tc1100-wmi", -1); 240 - platform_device_add(tc1100_device); 287 + if (!tc1100_device) 288 + return -ENOMEM; 289 + 290 + error = platform_device_add(tc1100_device); 291 + if (error) 292 + goto err_device_put; 293 + 294 + error = platform_driver_probe(&tc1100_driver, tc1100_probe); 295 + if (error) 296 + goto err_device_del; 241 297 242 298 printk(TC1100_INFO "HP Compaq TC1100 Tablet WMI Extras loaded\n"); 299 + return 0; 243 300 244 - return result; 301 + err_device_del: 302 + platform_device_del(tc1100_device); 303 + err_device_put: 304 + platform_device_put(tc1100_device); 305 + return error; 245 306 } 246 307 247 308 static void __exit tc1100_exit(void) 248 309 { 249 - platform_device_del(tc1100_device); 310 + platform_device_unregister(tc1100_device); 250 311 platform_driver_unregister(&tc1100_driver); 251 - 252 - printk(TC1100_INFO "HP Compaq TC1100 Tablet WMI Extras unloaded\n"); 253 312 } 254 313 255 314 module_init(tc1100_init);
+148 -113
drivers/platform/x86/toshiba_acpi.c
··· 42 42 #include <linux/init.h> 43 43 #include <linux/types.h> 44 44 #include <linux/proc_fs.h> 45 + #include <linux/seq_file.h> 45 46 #include <linux/backlight.h> 46 47 #include <linux/platform_device.h> 47 48 #include <linux/rfkill.h> ··· 358 357 static int last_key_event; 359 358 static int key_event_valid; 360 359 361 - typedef struct _ProcItem { 362 - const char *name; 363 - char *(*read_func) (char *); 364 - unsigned long (*write_func) (const char *, unsigned long); 365 - } ProcItem; 366 - 367 - /* proc file handlers 368 - */ 369 - 370 - static int 371 - dispatch_read(char *page, char **start, off_t off, int count, int *eof, 372 - ProcItem * item) 373 - { 374 - char *p = page; 375 - int len; 376 - 377 - if (off == 0) 378 - p = item->read_func(p); 379 - 380 - /* ISSUE: I don't understand this code */ 381 - len = (p - page); 382 - if (len <= off + count) 383 - *eof = 1; 384 - *start = page + off; 385 - len -= off; 386 - if (len > count) 387 - len = count; 388 - if (len < 0) 389 - len = 0; 390 - return len; 391 - } 392 - 393 - static int 394 - dispatch_write(struct file *file, const char __user * buffer, 395 - unsigned long count, ProcItem * item) 396 - { 397 - int result; 398 - char *tmp_buffer; 399 - 400 - /* Arg buffer points to userspace memory, which can't be accessed 401 - * directly. Since we're making a copy, zero-terminate the 402 - * destination so that sscanf can be used on it safely. 403 - */ 404 - tmp_buffer = kmalloc(count + 1, GFP_KERNEL); 405 - if (!tmp_buffer) 406 - return -ENOMEM; 407 - 408 - if (copy_from_user(tmp_buffer, buffer, count)) { 409 - result = -EFAULT; 410 - } else { 411 - tmp_buffer[count] = 0; 412 - result = item->write_func(tmp_buffer, count); 413 - } 414 - kfree(tmp_buffer); 415 - return result; 416 - } 417 - 418 360 static int get_lcd(struct backlight_device *bd) 419 361 { 420 362 u32 hci_result; ··· 370 426 return -EFAULT; 371 427 } 372 428 373 - static char *read_lcd(char *p) 429 + static int lcd_proc_show(struct seq_file *m, void *v) 374 430 { 375 431 int value = get_lcd(NULL); 376 432 377 433 if (value >= 0) { 378 - p += sprintf(p, "brightness: %d\n", value); 379 - p += sprintf(p, "brightness_levels: %d\n", 434 + seq_printf(m, "brightness: %d\n", value); 435 + seq_printf(m, "brightness_levels: %d\n", 380 436 HCI_LCD_BRIGHTNESS_LEVELS); 381 437 } else { 382 438 printk(MY_ERR "Error reading LCD brightness\n"); 383 439 } 384 440 385 - return p; 441 + return 0; 442 + } 443 + 444 + static int lcd_proc_open(struct inode *inode, struct file *file) 445 + { 446 + return single_open(file, lcd_proc_show, NULL); 386 447 } 387 448 388 449 static int set_lcd(int value) ··· 407 458 return set_lcd(bd->props.brightness); 408 459 } 409 460 410 - static unsigned long write_lcd(const char *buffer, unsigned long count) 461 + static ssize_t lcd_proc_write(struct file *file, const char __user *buf, 462 + size_t count, loff_t *pos) 411 463 { 464 + char cmd[42]; 465 + size_t len; 412 466 int value; 413 467 int ret; 414 468 415 - if (sscanf(buffer, " brightness : %i", &value) == 1 && 469 + len = min(count, sizeof(cmd) - 1); 470 + if (copy_from_user(cmd, buf, len)) 471 + return -EFAULT; 472 + cmd[len] = '\0'; 473 + 474 + if (sscanf(cmd, " brightness : %i", &value) == 1 && 416 475 value >= 0 && value < HCI_LCD_BRIGHTNESS_LEVELS) { 417 476 ret = set_lcd(value); 418 477 if (ret == 0) ··· 431 474 return ret; 432 475 } 433 476 434 - static char *read_video(char *p) 477 + static const struct file_operations lcd_proc_fops = { 478 + .owner = THIS_MODULE, 479 + .open = lcd_proc_open, 480 + .read = seq_read, 481 + .llseek = seq_lseek, 482 + .release = single_release, 483 + .write = lcd_proc_write, 484 + }; 485 + 486 + static int video_proc_show(struct seq_file *m, void *v) 435 487 { 436 488 u32 hci_result; 437 489 u32 value; ··· 450 484 int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0; 451 485 int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0; 452 486 int is_tv = (value & HCI_VIDEO_OUT_TV) ? 1 : 0; 453 - p += sprintf(p, "lcd_out: %d\n", is_lcd); 454 - p += sprintf(p, "crt_out: %d\n", is_crt); 455 - p += sprintf(p, "tv_out: %d\n", is_tv); 487 + seq_printf(m, "lcd_out: %d\n", is_lcd); 488 + seq_printf(m, "crt_out: %d\n", is_crt); 489 + seq_printf(m, "tv_out: %d\n", is_tv); 456 490 } else { 457 491 printk(MY_ERR "Error reading video out status\n"); 458 492 } 459 493 460 - return p; 494 + return 0; 461 495 } 462 496 463 - static unsigned long write_video(const char *buffer, unsigned long count) 497 + static int video_proc_open(struct inode *inode, struct file *file) 464 498 { 499 + return single_open(file, video_proc_show, NULL); 500 + } 501 + 502 + static ssize_t video_proc_write(struct file *file, const char __user *buf, 503 + size_t count, loff_t *pos) 504 + { 505 + char *cmd, *buffer; 465 506 int value; 466 507 int remain = count; 467 508 int lcd_out = -1; ··· 476 503 int tv_out = -1; 477 504 u32 hci_result; 478 505 u32 video_out; 506 + 507 + cmd = kmalloc(count + 1, GFP_KERNEL); 508 + if (!cmd) 509 + return -ENOMEM; 510 + if (copy_from_user(cmd, buf, count)) { 511 + kfree(cmd); 512 + return -EFAULT; 513 + } 514 + cmd[count] = '\0'; 515 + 516 + buffer = cmd; 479 517 480 518 /* scan expression. Multiple expressions may be delimited with ; 481 519 * ··· 506 522 } 507 523 while (remain && *(buffer - 1) != ';'); 508 524 } 525 + 526 + kfree(cmd); 509 527 510 528 hci_read1(HCI_VIDEO_OUT, &video_out, &hci_result); 511 529 if (hci_result == HCI_SUCCESS) { ··· 529 543 return count; 530 544 } 531 545 532 - static char *read_fan(char *p) 546 + static const struct file_operations video_proc_fops = { 547 + .owner = THIS_MODULE, 548 + .open = video_proc_open, 549 + .read = seq_read, 550 + .llseek = seq_lseek, 551 + .release = single_release, 552 + .write = video_proc_write, 553 + }; 554 + 555 + static int fan_proc_show(struct seq_file *m, void *v) 533 556 { 534 557 u32 hci_result; 535 558 u32 value; 536 559 537 560 hci_read1(HCI_FAN, &value, &hci_result); 538 561 if (hci_result == HCI_SUCCESS) { 539 - p += sprintf(p, "running: %d\n", (value > 0)); 540 - p += sprintf(p, "force_on: %d\n", force_fan); 562 + seq_printf(m, "running: %d\n", (value > 0)); 563 + seq_printf(m, "force_on: %d\n", force_fan); 541 564 } else { 542 565 printk(MY_ERR "Error reading fan status\n"); 543 566 } 544 567 545 - return p; 568 + return 0; 546 569 } 547 570 548 - static unsigned long write_fan(const char *buffer, unsigned long count) 571 + static int fan_proc_open(struct inode *inode, struct file *file) 549 572 { 573 + return single_open(file, fan_proc_show, NULL); 574 + } 575 + 576 + static ssize_t fan_proc_write(struct file *file, const char __user *buf, 577 + size_t count, loff_t *pos) 578 + { 579 + char cmd[42]; 580 + size_t len; 550 581 int value; 551 582 u32 hci_result; 552 583 553 - if (sscanf(buffer, " force_on : %i", &value) == 1 && 584 + len = min(count, sizeof(cmd) - 1); 585 + if (copy_from_user(cmd, buf, len)) 586 + return -EFAULT; 587 + cmd[len] = '\0'; 588 + 589 + if (sscanf(cmd, " force_on : %i", &value) == 1 && 554 590 value >= 0 && value <= 1) { 555 591 hci_write1(HCI_FAN, value, &hci_result); 556 592 if (hci_result != HCI_SUCCESS) ··· 586 578 return count; 587 579 } 588 580 589 - static char *read_keys(char *p) 581 + static const struct file_operations fan_proc_fops = { 582 + .owner = THIS_MODULE, 583 + .open = fan_proc_open, 584 + .read = seq_read, 585 + .llseek = seq_lseek, 586 + .release = single_release, 587 + .write = fan_proc_write, 588 + }; 589 + 590 + static int keys_proc_show(struct seq_file *m, void *v) 590 591 { 591 592 u32 hci_result; 592 593 u32 value; ··· 619 602 } 620 603 } 621 604 622 - p += sprintf(p, "hotkey_ready: %d\n", key_event_valid); 623 - p += sprintf(p, "hotkey: 0x%04x\n", last_key_event); 624 - 625 - end: 626 - return p; 605 + seq_printf(m, "hotkey_ready: %d\n", key_event_valid); 606 + seq_printf(m, "hotkey: 0x%04x\n", last_key_event); 607 + end: 608 + return 0; 627 609 } 628 610 629 - static unsigned long write_keys(const char *buffer, unsigned long count) 611 + static int keys_proc_open(struct inode *inode, struct file *file) 630 612 { 613 + return single_open(file, keys_proc_show, NULL); 614 + } 615 + 616 + static ssize_t keys_proc_write(struct file *file, const char __user *buf, 617 + size_t count, loff_t *pos) 618 + { 619 + char cmd[42]; 620 + size_t len; 631 621 int value; 632 622 633 - if (sscanf(buffer, " hotkey_ready : %i", &value) == 1 && value == 0) { 623 + len = min(count, sizeof(cmd) - 1); 624 + if (copy_from_user(cmd, buf, len)) 625 + return -EFAULT; 626 + cmd[len] = '\0'; 627 + 628 + if (sscanf(cmd, " hotkey_ready : %i", &value) == 1 && value == 0) { 634 629 key_event_valid = 0; 635 630 } else { 636 631 return -EINVAL; ··· 651 622 return count; 652 623 } 653 624 654 - static char *read_version(char *p) 625 + static const struct file_operations keys_proc_fops = { 626 + .owner = THIS_MODULE, 627 + .open = keys_proc_open, 628 + .read = seq_read, 629 + .llseek = seq_lseek, 630 + .release = single_release, 631 + .write = keys_proc_write, 632 + }; 633 + 634 + static int version_proc_show(struct seq_file *m, void *v) 655 635 { 656 - p += sprintf(p, "driver: %s\n", TOSHIBA_ACPI_VERSION); 657 - p += sprintf(p, "proc_interface: %d\n", 658 - PROC_INTERFACE_VERSION); 659 - return p; 636 + seq_printf(m, "driver: %s\n", TOSHIBA_ACPI_VERSION); 637 + seq_printf(m, "proc_interface: %d\n", PROC_INTERFACE_VERSION); 638 + return 0; 660 639 } 640 + 641 + static int version_proc_open(struct inode *inode, struct file *file) 642 + { 643 + return single_open(file, version_proc_show, PDE(inode)->data); 644 + } 645 + 646 + static const struct file_operations version_proc_fops = { 647 + .owner = THIS_MODULE, 648 + .open = version_proc_open, 649 + .read = seq_read, 650 + .llseek = seq_lseek, 651 + .release = single_release, 652 + }; 661 653 662 654 /* proc and module init 663 655 */ 664 656 665 657 #define PROC_TOSHIBA "toshiba" 666 658 667 - static ProcItem proc_items[] = { 668 - {"lcd", read_lcd, write_lcd}, 669 - {"video", read_video, write_video}, 670 - {"fan", read_fan, write_fan}, 671 - {"keys", read_keys, write_keys}, 672 - {"version", read_version, NULL}, 673 - {NULL} 674 - }; 675 - 676 659 static acpi_status __init add_device(void) 677 660 { 678 - struct proc_dir_entry *proc; 679 - ProcItem *item; 680 - 681 - for (item = proc_items; item->name; ++item) { 682 - proc = create_proc_read_entry(item->name, 683 - S_IFREG | S_IRUGO | S_IWUSR, 684 - toshiba_proc_dir, 685 - (read_proc_t *) dispatch_read, 686 - item); 687 - if (proc && item->write_func) 688 - proc->write_proc = (write_proc_t *) dispatch_write; 689 - } 661 + proc_create("lcd", S_IRUGO | S_IWUSR, toshiba_proc_dir, &lcd_proc_fops); 662 + proc_create("video", S_IRUGO | S_IWUSR, toshiba_proc_dir, &video_proc_fops); 663 + proc_create("fan", S_IRUGO | S_IWUSR, toshiba_proc_dir, &fan_proc_fops); 664 + proc_create("keys", S_IRUGO | S_IWUSR, toshiba_proc_dir, &keys_proc_fops); 665 + proc_create("version", S_IRUGO, toshiba_proc_dir, &version_proc_fops); 690 666 691 667 return AE_OK; 692 668 } 693 669 694 670 static acpi_status remove_device(void) 695 671 { 696 - ProcItem *item; 697 - 698 - for (item = proc_items; item->name; ++item) 699 - remove_proc_entry(item->name, toshiba_proc_dir); 672 + remove_proc_entry("lcd", toshiba_proc_dir); 673 + remove_proc_entry("video", toshiba_proc_dir); 674 + remove_proc_entry("fan", toshiba_proc_dir); 675 + remove_proc_entry("keys", toshiba_proc_dir); 676 + remove_proc_entry("version", toshiba_proc_dir); 700 677 return AE_OK; 701 678 } 702 679
+2 -2
drivers/platform/x86/wmi.c
··· 540 540 /** 541 541 * wmi_get_event_data - Get WMI data associated with an event 542 542 * 543 - * @event - Event to find 544 - * &out - Buffer to hold event data 543 + * @event: Event to find 544 + * @out: Buffer to hold event data. out->pointer should be freed with kfree() 545 545 * 546 546 * Returns extra data associated with an event in WMI. 547 547 */
+3 -5
include/acpi/processor.h
··· 224 224 struct acpi_processor_throttling throttling; 225 225 struct acpi_processor_limit limit; 226 226 struct thermal_cooling_device *cdev; 227 - /* the _PDC objects for this processor, if any */ 228 - struct acpi_object_list *pdc; 229 227 }; 230 228 231 229 struct acpi_processor_errata { ··· 254 256 /* for communication between multiple parts of the processor kernel module */ 255 257 DECLARE_PER_CPU(struct acpi_processor *, processors); 256 258 extern struct acpi_processor_errata errata; 257 - 258 - void arch_acpi_processor_init_pdc(struct acpi_processor *pr); 259 - void arch_acpi_processor_cleanup_pdc(struct acpi_processor *pr); 260 259 261 260 #ifdef ARCH_HAS_POWER_INIT 262 261 void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags, ··· 319 324 } 320 325 321 326 #endif /* CONFIG_CPU_FREQ */ 327 + 328 + /* in processor_pdc.c */ 329 + void acpi_processor_set_pdc(acpi_handle handle); 322 330 323 331 /* in processor_throttling.c */ 324 332 int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
+1
include/linux/sonypi.h
··· 111 111 #define SONYPI_EVENT_VOLUME_INC_PRESSED 69 112 112 #define SONYPI_EVENT_VOLUME_DEC_PRESSED 70 113 113 #define SONYPI_EVENT_BRIGHTNESS_PRESSED 71 114 + #define SONYPI_EVENT_MEDIA_PRESSED 72 114 115 115 116 /* get/set brightness */ 116 117 #define SONYPI_IOCGBRT _IOR('v', 0, __u8)