aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/ec.c6
-rw-r--r--drivers/acpi/executer/exregion.c5
-rw-r--r--drivers/acpi/fan.c30
-rw-r--r--drivers/acpi/processor_core.c39
-rw-r--r--drivers/acpi/processor_idle.c10
-rw-r--r--drivers/acpi/utils.c18
-rw-r--r--drivers/acpi/video.c3
-rw-r--r--drivers/base/power/main.c2
-rw-r--r--drivers/misc/Kconfig17
-rw-r--r--drivers/misc/acer-wmi.c9
-rw-r--r--drivers/misc/intel_menlow.c11
-rw-r--r--drivers/misc/thinkpad_acpi.c123
-rw-r--r--drivers/pci/pci-acpi.c2
-rw-r--r--drivers/thermal/thermal.c39
14 files changed, 230 insertions, 84 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 7222a18a0319..caf873c14bfb 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -943,7 +943,11 @@ int __init acpi_ec_ecdt_probe(void)
943 boot_ec->command_addr = ecdt_ptr->control.address; 943 boot_ec->command_addr = ecdt_ptr->control.address;
944 boot_ec->data_addr = ecdt_ptr->data.address; 944 boot_ec->data_addr = ecdt_ptr->data.address;
945 boot_ec->gpe = ecdt_ptr->gpe; 945 boot_ec->gpe = ecdt_ptr->gpe;
946 boot_ec->handle = ACPI_ROOT_OBJECT; 946 if (ACPI_FAILURE(acpi_get_handle(NULL, ecdt_ptr->id,
947 &boot_ec->handle))) {
948 pr_info("Failed to locate handle for boot EC\n");
949 boot_ec->handle = ACPI_ROOT_OBJECT;
950 }
947 } else { 951 } else {
948 /* This workaround is needed only on some broken machines, 952 /* This workaround is needed only on some broken machines,
949 * which require early EC, but fail to provide ECDT */ 953 * which require early EC, but fail to provide ECDT */
diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c
index 2e9ce94798c7..3f51b7e84a17 100644
--- a/drivers/acpi/executer/exregion.c
+++ b/drivers/acpi/executer/exregion.c
@@ -338,6 +338,7 @@ acpi_ex_pci_config_space_handler(u32 function,
338 acpi_status status = AE_OK; 338 acpi_status status = AE_OK;
339 struct acpi_pci_id *pci_id; 339 struct acpi_pci_id *pci_id;
340 u16 pci_register; 340 u16 pci_register;
341 u32 value32;
341 342
342 ACPI_FUNCTION_TRACE(ex_pci_config_space_handler); 343 ACPI_FUNCTION_TRACE(ex_pci_config_space_handler);
343 344
@@ -364,9 +365,9 @@ acpi_ex_pci_config_space_handler(u32 function,
364 switch (function) { 365 switch (function) {
365 case ACPI_READ: 366 case ACPI_READ:
366 367
367 *value = 0;
368 status = acpi_os_read_pci_configuration(pci_id, pci_register, 368 status = acpi_os_read_pci_configuration(pci_id, pci_register,
369 value, bit_width); 369 &value32, bit_width);
370 *value = value32;
370 break; 371 break;
371 372
372 case ACPI_WRITE: 373 case ACPI_WRITE:
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 48cb705b274a..c8e3cba423ef 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -256,22 +256,28 @@ static int acpi_fan_add(struct acpi_device *device)
256 256
257 cdev = thermal_cooling_device_register("Fan", device, 257 cdev = thermal_cooling_device_register("Fan", device,
258 &fan_cooling_ops); 258 &fan_cooling_ops);
259 if (cdev) 259 if (IS_ERR(cdev)) {
260 result = PTR_ERR(cdev);
261 goto end;
262 }
263 if (cdev) {
260 printk(KERN_INFO PREFIX 264 printk(KERN_INFO PREFIX
261 "%s is registered as cooling_device%d\n", 265 "%s is registered as cooling_device%d\n",
262 device->dev.bus_id, cdev->id); 266 device->dev.bus_id, cdev->id);
263 else
264 goto end;
265 acpi_driver_data(device) = cdev;
266 result = sysfs_create_link(&device->dev.kobj, &cdev->device.kobj,
267 "thermal_cooling");
268 if (result)
269 return result;
270 267
271 result = sysfs_create_link(&cdev->device.kobj, &device->dev.kobj, 268 acpi_driver_data(device) = cdev;
272 "device"); 269 result = sysfs_create_link(&device->dev.kobj,
273 if (result) 270 &cdev->device.kobj,
274 return result; 271 "thermal_cooling");
272 if (result)
273 return result;
274
275 result = sysfs_create_link(&cdev->device.kobj,
276 &device->dev.kobj,
277 "device");
278 if (result)
279 return result;
280 }
275 281
276 result = acpi_fan_add_fs(device); 282 result = acpi_fan_add_fs(device);
277 if (result) 283 if (result)
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 75ccf5d18bf4..a3cc8a98255c 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -670,21 +670,26 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
670 670
671 pr->cdev = thermal_cooling_device_register("Processor", device, 671 pr->cdev = thermal_cooling_device_register("Processor", device,
672 &processor_cooling_ops); 672 &processor_cooling_ops);
673 if (pr->cdev) 673 if (IS_ERR(pr->cdev)) {
674 result = PTR_ERR(pr->cdev);
675 goto end;
676 }
677 if (pr->cdev) {
674 printk(KERN_INFO PREFIX 678 printk(KERN_INFO PREFIX
675 "%s is registered as cooling_device%d\n", 679 "%s is registered as cooling_device%d\n",
676 device->dev.bus_id, pr->cdev->id); 680 device->dev.bus_id, pr->cdev->id);
677 else
678 goto end;
679 681
680 result = sysfs_create_link(&device->dev.kobj, &pr->cdev->device.kobj, 682 result = sysfs_create_link(&device->dev.kobj,
681 "thermal_cooling"); 683 &pr->cdev->device.kobj,
682 if (result) 684 "thermal_cooling");
683 return result; 685 if (result)
684 result = sysfs_create_link(&pr->cdev->device.kobj, &device->dev.kobj, 686 return result;
685 "device"); 687 result = sysfs_create_link(&pr->cdev->device.kobj,
686 if (result) 688 &device->dev.kobj,
687 return result; 689 "device");
690 if (result)
691 return result;
692 }
688 693
689 if (pr->flags.throttling) { 694 if (pr->flags.throttling) {
690 printk(KERN_INFO PREFIX "%s [%s] (supports", 695 printk(KERN_INFO PREFIX "%s [%s] (supports",
@@ -809,10 +814,12 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
809 814
810 acpi_processor_remove_fs(device); 815 acpi_processor_remove_fs(device);
811 816
812 sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); 817 if (pr->cdev) {
813 sysfs_remove_link(&pr->cdev->device.kobj, "device"); 818 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
814 thermal_cooling_device_unregister(pr->cdev); 819 sysfs_remove_link(&pr->cdev->device.kobj, "device");
815 pr->cdev = NULL; 820 thermal_cooling_device_unregister(pr->cdev);
821 pr->cdev = NULL;
822 }
816 823
817 processors[pr->id] = NULL; 824 processors[pr->id] = NULL;
818 825
@@ -826,8 +833,6 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
826 * Acpi processor hotplug support * 833 * Acpi processor hotplug support *
827 ****************************************************************************/ 834 ****************************************************************************/
828 835
829static int is_processor_present(acpi_handle handle);
830
831static int is_processor_present(acpi_handle handle) 836static int is_processor_present(acpi_handle handle)
832{ 837{
833 acpi_status status; 838 acpi_status status;
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 980e1c33e6c5..6f3b217699e9 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -364,7 +364,7 @@ int acpi_processor_resume(struct acpi_device * device)
364 return 0; 364 return 0;
365} 365}
366 366
367#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) 367#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
368static int tsc_halts_in_c(int state) 368static int tsc_halts_in_c(int state)
369{ 369{
370 switch (boot_cpu_data.x86_vendor) { 370 switch (boot_cpu_data.x86_vendor) {
@@ -544,7 +544,7 @@ static void acpi_processor_idle(void)
544 /* Get end time (ticks) */ 544 /* Get end time (ticks) */
545 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); 545 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
546 546
547#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) 547#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
548 /* TSC halts in C2, so notify users */ 548 /* TSC halts in C2, so notify users */
549 if (tsc_halts_in_c(ACPI_STATE_C2)) 549 if (tsc_halts_in_c(ACPI_STATE_C2))
550 mark_tsc_unstable("possible TSC halt in C2"); 550 mark_tsc_unstable("possible TSC halt in C2");
@@ -609,7 +609,7 @@ static void acpi_processor_idle(void)
609 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0); 609 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0);
610 } 610 }
611 611
612#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) 612#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
613 /* TSC halts in C3, so notify users */ 613 /* TSC halts in C3, so notify users */
614 if (tsc_halts_in_c(ACPI_STATE_C3)) 614 if (tsc_halts_in_c(ACPI_STATE_C3))
615 mark_tsc_unstable("TSC halts in C3"); 615 mark_tsc_unstable("TSC halts in C3");
@@ -1500,7 +1500,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
1500 acpi_idle_do_entry(cx); 1500 acpi_idle_do_entry(cx);
1501 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); 1501 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
1502 1502
1503#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) 1503#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
1504 /* TSC could halt in idle, so notify users */ 1504 /* TSC could halt in idle, so notify users */
1505 if (tsc_halts_in_c(cx->type)) 1505 if (tsc_halts_in_c(cx->type))
1506 mark_tsc_unstable("TSC halts in idle");; 1506 mark_tsc_unstable("TSC halts in idle");;
@@ -1614,7 +1614,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1614 spin_unlock(&c3_lock); 1614 spin_unlock(&c3_lock);
1615 } 1615 }
1616 1616
1617#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86_TSC) 1617#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
1618 /* TSC could halt in idle, so notify users */ 1618 /* TSC could halt in idle, so notify users */
1619 if (tsc_halts_in_c(ACPI_STATE_C3)) 1619 if (tsc_halts_in_c(ACPI_STATE_C3))
1620 mark_tsc_unstable("TSC halts in idle"); 1620 mark_tsc_unstable("TSC halts in idle");
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 34f157571080..eba55b7d6c95 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -36,16 +36,20 @@ ACPI_MODULE_NAME("utils");
36/* -------------------------------------------------------------------------- 36/* --------------------------------------------------------------------------
37 Object Evaluation Helpers 37 Object Evaluation Helpers
38 -------------------------------------------------------------------------- */ 38 -------------------------------------------------------------------------- */
39static void
40acpi_util_eval_error(acpi_handle h, acpi_string p, acpi_status s)
41{
39#ifdef ACPI_DEBUG_OUTPUT 42#ifdef ACPI_DEBUG_OUTPUT
40#define acpi_util_eval_error(h,p,s) {\ 43 char prefix[80] = {'\0'};
41 char prefix[80] = {'\0'};\ 44 struct acpi_buffer buffer = {sizeof(prefix), prefix};
42 struct acpi_buffer buffer = {sizeof(prefix), prefix};\ 45 acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);
43 acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\ 46 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n",
44 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n",\ 47 (char *) prefix, p, acpi_format_exception(s)));
45 (char *) prefix, p, acpi_format_exception(s))); }
46#else 48#else
47#define acpi_util_eval_error(h,p,s) 49 return;
48#endif 50#endif
51}
52
49acpi_status 53acpi_status
50acpi_extract_package(union acpi_object *package, 54acpi_extract_package(union acpi_object *package,
51 struct acpi_buffer *format, struct acpi_buffer *buffer) 55 struct acpi_buffer *format, struct acpi_buffer *buffer)
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 7f714fa2a454..12cce69b5441 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -731,6 +731,9 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
731 731
732 device->cdev = thermal_cooling_device_register("LCD", 732 device->cdev = thermal_cooling_device_register("LCD",
733 device->dev, &video_cooling_ops); 733 device->dev, &video_cooling_ops);
734 if (IS_ERR(device->cdev))
735 return;
736
734 if (device->cdev) { 737 if (device->cdev) {
735 printk(KERN_INFO PREFIX 738 printk(KERN_INFO PREFIX
736 "%s is registered as cooling_device%d\n", 739 "%s is registered as cooling_device%d\n",
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index cea5ed3919cd..ee9d1c8db0d6 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -415,7 +415,7 @@ EXPORT_SYMBOL_GPL(device_power_down);
415 * @dev: Device. 415 * @dev: Device.
416 * @state: Power state device is entering. 416 * @state: Power state device is entering.
417 */ 417 */
418int suspend_device(struct device *dev, pm_message_t state) 418static int suspend_device(struct device *dev, pm_message_t state)
419{ 419{
420 int error = 0; 420 int error = 0;
421 421
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 1abc95ca9dfa..982e27b86d10 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -258,6 +258,23 @@ config THINKPAD_ACPI_BAY
258 258
259 If you are not sure, say Y here. 259 If you are not sure, say Y here.
260 260
261config THINKPAD_ACPI_VIDEO
262 bool "Video output control support"
263 depends on THINKPAD_ACPI
264 default y
265 ---help---
266 Allows the thinkpad_acpi driver to provide an interface to control
267 the various video output ports.
268
269 This feature often won't work well, depending on ThinkPad model,
270 display state, video output devices in use, whether there is a X
271 server running, phase of the moon, and the current mood of
272 Schroedinger's cat. If you can use X.org's RandR to control
273 your ThinkPad's video output ports instead of this feature,
274 don't think twice: do it and say N here to save some memory.
275
276 If you are not sure, say Y here.
277
261config THINKPAD_ACPI_HOTKEY_POLL 278config THINKPAD_ACPI_HOTKEY_POLL
262 bool "Suport NVRAM polling for hot keys" 279 bool "Suport NVRAM polling for hot keys"
263 depends on THINKPAD_ACPI 280 depends on THINKPAD_ACPI
diff --git a/drivers/misc/acer-wmi.c b/drivers/misc/acer-wmi.c
index d7aea93081f2..74d12b4a3abd 100644
--- a/drivers/misc/acer-wmi.c
+++ b/drivers/misc/acer-wmi.c
@@ -273,6 +273,15 @@ static struct dmi_system_id acer_quirks[] = {
273 }, 273 },
274 { 274 {
275 .callback = dmi_matched, 275 .callback = dmi_matched,
276 .ident = "Acer TravelMate 4200",
277 .matches = {
278 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
279 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4200"),
280 },
281 .driver_data = &quirk_acer_travelmate_2490,
282 },
283 {
284 .callback = dmi_matched,
276 .ident = "Medion MD 98300", 285 .ident = "Medion MD 98300",
277 .matches = { 286 .matches = {
278 DMI_MATCH(DMI_SYS_VENDOR, "MEDION"), 287 DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
diff --git a/drivers/misc/intel_menlow.c b/drivers/misc/intel_menlow.c
index f70984ab1e1b..de16e88eb8d3 100644
--- a/drivers/misc/intel_menlow.c
+++ b/drivers/misc/intel_menlow.c
@@ -170,10 +170,13 @@ static int intel_menlow_memory_add(struct acpi_device *device)
170 170
171 cdev = thermal_cooling_device_register("Memory controller", device, 171 cdev = thermal_cooling_device_register("Memory controller", device,
172 &memory_cooling_ops); 172 &memory_cooling_ops);
173 acpi_driver_data(device) = cdev; 173 if (IS_ERR(cdev)) {
174 if (!cdev) 174 result = PTR_ERR(cdev);
175 result = -ENODEV; 175 goto end;
176 else { 176 }
177
178 if (cdev) {
179 acpi_driver_data(device) = cdev;
177 result = sysfs_create_link(&device->dev.kobj, 180 result = sysfs_create_link(&device->dev.kobj,
178 &cdev->device.kobj, "thermal_cooling"); 181 &cdev->device.kobj, "thermal_cooling");
179 if (result) 182 if (result)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index e2c7edd206a6..bb269d0c677e 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -221,6 +221,7 @@ static struct {
221 u32 hotkey:1; 221 u32 hotkey:1;
222 u32 hotkey_mask:1; 222 u32 hotkey_mask:1;
223 u32 hotkey_wlsw:1; 223 u32 hotkey_wlsw:1;
224 u32 hotkey_tablet:1;
224 u32 light:1; 225 u32 light:1;
225 u32 light_status:1; 226 u32 light_status:1;
226 u32 bright_16levels:1; 227 u32 bright_16levels:1;
@@ -301,6 +302,13 @@ TPACPI_HANDLE(hkey, ec, "\\_SB.HKEY", /* 600e/x, 770e, 770x */
301 "HKEY", /* all others */ 302 "HKEY", /* all others */
302 ); /* 570 */ 303 ); /* 570 */
303 304
305TPACPI_HANDLE(vid, root, "\\_SB.PCI.AGP.VGA", /* 570 */
306 "\\_SB.PCI0.AGP0.VID0", /* 600e/x, 770x */
307 "\\_SB.PCI0.VID0", /* 770e */
308 "\\_SB.PCI0.VID", /* A21e, G4x, R50e, X30, X40 */
309 "\\_SB.PCI0.AGP.VID", /* all others */
310 ); /* R30, R31 */
311
304 312
305/************************************************************************* 313/*************************************************************************
306 * ACPI helpers 314 * ACPI helpers
@@ -1053,6 +1061,9 @@ static struct attribute_set *hotkey_dev_attributes;
1053#define HOTKEY_CONFIG_CRITICAL_END 1061#define HOTKEY_CONFIG_CRITICAL_END
1054#endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */ 1062#endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */
1055 1063
1064/* HKEY.MHKG() return bits */
1065#define TP_HOTKEY_TABLET_MASK (1 << 3)
1066
1056static int hotkey_get_wlsw(int *status) 1067static int hotkey_get_wlsw(int *status)
1057{ 1068{
1058 if (!acpi_evalf(hkey_handle, status, "WLSW", "d")) 1069 if (!acpi_evalf(hkey_handle, status, "WLSW", "d"))
@@ -1060,6 +1071,16 @@ static int hotkey_get_wlsw(int *status)
1060 return 0; 1071 return 0;
1061} 1072}
1062 1073
1074static int hotkey_get_tablet_mode(int *status)
1075{
1076 int s;
1077
1078 if (!acpi_evalf(hkey_handle, &s, "MHKG", "d"))
1079 return -EIO;
1080
1081 return ((s & TP_HOTKEY_TABLET_MASK) != 0);
1082}
1083
1063/* 1084/*
1064 * Call with hotkey_mutex held 1085 * Call with hotkey_mutex held
1065 */ 1086 */
@@ -1154,15 +1175,31 @@ static void tpacpi_input_send_radiosw(void)
1154{ 1175{
1155 int wlsw; 1176 int wlsw;
1156 1177
1157 mutex_lock(&tpacpi_inputdev_send_mutex);
1158
1159 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) { 1178 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) {
1179 mutex_lock(&tpacpi_inputdev_send_mutex);
1180
1160 input_report_switch(tpacpi_inputdev, 1181 input_report_switch(tpacpi_inputdev,
1161 SW_RADIO, !!wlsw); 1182 SW_RADIO, !!wlsw);
1162 input_sync(tpacpi_inputdev); 1183 input_sync(tpacpi_inputdev);
1184
1185 mutex_unlock(&tpacpi_inputdev_send_mutex);
1163 } 1186 }
1187}
1188
1189static void tpacpi_input_send_tabletsw(void)
1190{
1191 int state;
1192
1193 if (tp_features.hotkey_tablet &&
1194 !hotkey_get_tablet_mode(&state)) {
1195 mutex_lock(&tpacpi_inputdev_send_mutex);
1164 1196
1165 mutex_unlock(&tpacpi_inputdev_send_mutex); 1197 input_report_switch(tpacpi_inputdev,
1198 SW_TABLET_MODE, !!state);
1199 input_sync(tpacpi_inputdev);
1200
1201 mutex_unlock(&tpacpi_inputdev_send_mutex);
1202 }
1166} 1203}
1167 1204
1168static void tpacpi_input_send_key(unsigned int scancode) 1205static void tpacpi_input_send_key(unsigned int scancode)
@@ -1417,6 +1454,14 @@ static void hotkey_poll_setup_safe(int may_warn)
1417 mutex_unlock(&hotkey_mutex); 1454 mutex_unlock(&hotkey_mutex);
1418} 1455}
1419 1456
1457#else /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */
1458
1459static void hotkey_poll_setup_safe(int __unused)
1460{
1461}
1462
1463#endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */
1464
1420static int hotkey_inputdev_open(struct input_dev *dev) 1465static int hotkey_inputdev_open(struct input_dev *dev)
1421{ 1466{
1422 switch (tpacpi_lifecycle) { 1467 switch (tpacpi_lifecycle) {
@@ -1444,7 +1489,6 @@ static void hotkey_inputdev_close(struct input_dev *dev)
1444 if (tpacpi_lifecycle == TPACPI_LIFE_RUNNING) 1489 if (tpacpi_lifecycle == TPACPI_LIFE_RUNNING)
1445 hotkey_poll_setup_safe(0); 1490 hotkey_poll_setup_safe(0);
1446} 1491}
1447#endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */
1448 1492
1449/* sysfs hotkey enable ------------------------------------------------- */ 1493/* sysfs hotkey enable ------------------------------------------------- */
1450static ssize_t hotkey_enable_show(struct device *dev, 1494static ssize_t hotkey_enable_show(struct device *dev,
@@ -1666,6 +1710,29 @@ static void hotkey_radio_sw_notify_change(void)
1666 "hotkey_radio_sw"); 1710 "hotkey_radio_sw");
1667} 1711}
1668 1712
1713/* sysfs hotkey tablet mode (pollable) --------------------------------- */
1714static ssize_t hotkey_tablet_mode_show(struct device *dev,
1715 struct device_attribute *attr,
1716 char *buf)
1717{
1718 int res, s;
1719 res = hotkey_get_tablet_mode(&s);
1720 if (res < 0)
1721 return res;
1722
1723 return snprintf(buf, PAGE_SIZE, "%d\n", !!s);
1724}
1725
1726static struct device_attribute dev_attr_hotkey_tablet_mode =
1727 __ATTR(hotkey_tablet_mode, S_IRUGO, hotkey_tablet_mode_show, NULL);
1728
1729static void hotkey_tablet_mode_notify_change(void)
1730{
1731 if (tp_features.hotkey_tablet)
1732 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL,
1733 "hotkey_tablet_mode");
1734}
1735
1669/* sysfs hotkey report_mode -------------------------------------------- */ 1736/* sysfs hotkey report_mode -------------------------------------------- */
1670static ssize_t hotkey_report_mode_show(struct device *dev, 1737static ssize_t hotkey_report_mode_show(struct device *dev,
1671 struct device_attribute *attr, 1738 struct device_attribute *attr,
@@ -1878,7 +1945,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
1878 str_supported(tp_features.hotkey)); 1945 str_supported(tp_features.hotkey));
1879 1946
1880 if (tp_features.hotkey) { 1947 if (tp_features.hotkey) {
1881 hotkey_dev_attributes = create_attr_set(12, NULL); 1948 hotkey_dev_attributes = create_attr_set(13, NULL);
1882 if (!hotkey_dev_attributes) 1949 if (!hotkey_dev_attributes)
1883 return -ENOMEM; 1950 return -ENOMEM;
1884 res = add_many_to_attr_set(hotkey_dev_attributes, 1951 res = add_many_to_attr_set(hotkey_dev_attributes,
@@ -1957,6 +2024,18 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
1957 &dev_attr_hotkey_radio_sw.attr); 2024 &dev_attr_hotkey_radio_sw.attr);
1958 } 2025 }
1959 2026
2027 /* For X41t, X60t, X61t Tablets... */
2028 if (!res && acpi_evalf(hkey_handle, &status, "MHKG", "qd")) {
2029 tp_features.hotkey_tablet = 1;
2030 printk(TPACPI_INFO
2031 "possible tablet mode switch found; "
2032 "ThinkPad in %s mode\n",
2033 (status & TP_HOTKEY_TABLET_MASK)?
2034 "tablet" : "laptop");
2035 res = add_to_attr_set(hotkey_dev_attributes,
2036 &dev_attr_hotkey_tablet_mode.attr);
2037 }
2038
1960 if (!res) 2039 if (!res)
1961 res = register_attr_set_with_sysfs( 2040 res = register_attr_set_with_sysfs(
1962 hotkey_dev_attributes, 2041 hotkey_dev_attributes,
@@ -2006,6 +2085,10 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
2006 set_bit(EV_SW, tpacpi_inputdev->evbit); 2085 set_bit(EV_SW, tpacpi_inputdev->evbit);
2007 set_bit(SW_RADIO, tpacpi_inputdev->swbit); 2086 set_bit(SW_RADIO, tpacpi_inputdev->swbit);
2008 } 2087 }
2088 if (tp_features.hotkey_tablet) {
2089 set_bit(EV_SW, tpacpi_inputdev->evbit);
2090 set_bit(SW_TABLET_MODE, tpacpi_inputdev->swbit);
2091 }
2009 2092
2010 dbg_printk(TPACPI_DBG_INIT, 2093 dbg_printk(TPACPI_DBG_INIT,
2011 "enabling hot key handling\n"); 2094 "enabling hot key handling\n");
@@ -2023,12 +2106,12 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
2023 (hotkey_report_mode < 2) ? 2106 (hotkey_report_mode < 2) ?
2024 "enabled" : "disabled"); 2107 "enabled" : "disabled");
2025 2108
2026#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
2027 tpacpi_inputdev->open = &hotkey_inputdev_open; 2109 tpacpi_inputdev->open = &hotkey_inputdev_open;
2028 tpacpi_inputdev->close = &hotkey_inputdev_close; 2110 tpacpi_inputdev->close = &hotkey_inputdev_close;
2029 2111
2030 hotkey_poll_setup_safe(1); 2112 hotkey_poll_setup_safe(1);
2031#endif 2113 tpacpi_input_send_radiosw();
2114 tpacpi_input_send_tabletsw();
2032 } 2115 }
2033 2116
2034 return (tp_features.hotkey)? 0 : 1; 2117 return (tp_features.hotkey)? 0 : 1;
@@ -2156,11 +2239,15 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
2156 /* 0x5000-0x5FFF: human interface helpers */ 2239 /* 0x5000-0x5FFF: human interface helpers */
2157 switch (hkey) { 2240 switch (hkey) {
2158 case 0x5010: /* Lenovo new BIOS: brightness changed */ 2241 case 0x5010: /* Lenovo new BIOS: brightness changed */
2159 case 0x5009: /* X61t: swivel up (tablet mode) */
2160 case 0x500a: /* X61t: swivel down (normal mode) */
2161 case 0x500b: /* X61t: tablet pen inserted into bay */ 2242 case 0x500b: /* X61t: tablet pen inserted into bay */
2162 case 0x500c: /* X61t: tablet pen removed from bay */ 2243 case 0x500c: /* X61t: tablet pen removed from bay */
2163 break; 2244 break;
2245 case 0x5009: /* X41t-X61t: swivel up (tablet mode) */
2246 case 0x500a: /* X41t-X61t: swivel down (normal mode) */
2247 tpacpi_input_send_tabletsw();
2248 hotkey_tablet_mode_notify_change();
2249 send_acpi_ev = 0;
2250 break;
2164 case 0x5001: 2251 case 0x5001:
2165 case 0x5002: 2252 case 0x5002:
2166 /* LID switch events. Do not propagate */ 2253 /* LID switch events. Do not propagate */
@@ -2219,11 +2306,10 @@ static void hotkey_resume(void)
2219 "from firmware\n"); 2306 "from firmware\n");
2220 tpacpi_input_send_radiosw(); 2307 tpacpi_input_send_radiosw();
2221 hotkey_radio_sw_notify_change(); 2308 hotkey_radio_sw_notify_change();
2309 hotkey_tablet_mode_notify_change();
2222 hotkey_wakeup_reason_notify_change(); 2310 hotkey_wakeup_reason_notify_change();
2223 hotkey_wakeup_hotunplug_complete_notify_change(); 2311 hotkey_wakeup_hotunplug_complete_notify_change();
2224#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
2225 hotkey_poll_setup_safe(0); 2312 hotkey_poll_setup_safe(0);
2226#endif
2227} 2313}
2228 2314
2229/* procfs -------------------------------------------------------------- */ 2315/* procfs -------------------------------------------------------------- */
@@ -2676,6 +2762,8 @@ static struct ibm_struct wan_driver_data = {
2676 * Video subdriver 2762 * Video subdriver
2677 */ 2763 */
2678 2764
2765#ifdef CONFIG_THINKPAD_ACPI_VIDEO
2766
2679enum video_access_mode { 2767enum video_access_mode {
2680 TPACPI_VIDEO_NONE = 0, 2768 TPACPI_VIDEO_NONE = 0,
2681 TPACPI_VIDEO_570, /* 570 */ 2769 TPACPI_VIDEO_570, /* 570 */
@@ -2703,13 +2791,6 @@ static int video_orig_autosw;
2703static int video_autosw_get(void); 2791static int video_autosw_get(void);
2704static int video_autosw_set(int enable); 2792static int video_autosw_set(int enable);
2705 2793
2706TPACPI_HANDLE(vid, root, "\\_SB.PCI.AGP.VGA", /* 570 */
2707 "\\_SB.PCI0.AGP0.VID0", /* 600e/x, 770x */
2708 "\\_SB.PCI0.VID0", /* 770e */
2709 "\\_SB.PCI0.VID", /* A21e, G4x, R50e, X30, X40 */
2710 "\\_SB.PCI0.AGP.VID", /* all others */
2711 ); /* R30, R31 */
2712
2713TPACPI_HANDLE(vid2, root, "\\_SB.PCI0.AGPB.VID"); /* G41 */ 2794TPACPI_HANDLE(vid2, root, "\\_SB.PCI0.AGPB.VID"); /* G41 */
2714 2795
2715static int __init video_init(struct ibm_init_struct *iibm) 2796static int __init video_init(struct ibm_init_struct *iibm)
@@ -3019,6 +3100,8 @@ static struct ibm_struct video_driver_data = {
3019 .exit = video_exit, 3100 .exit = video_exit,
3020}; 3101};
3021 3102
3103#endif /* CONFIG_THINKPAD_ACPI_VIDEO */
3104
3022/************************************************************************* 3105/*************************************************************************
3023 * Light (thinklight) subdriver 3106 * Light (thinklight) subdriver
3024 */ 3107 */
@@ -5803,10 +5886,12 @@ static struct ibm_init_struct ibms_init[] __initdata = {
5803 .init = wan_init, 5886 .init = wan_init,
5804 .data = &wan_driver_data, 5887 .data = &wan_driver_data,
5805 }, 5888 },
5889#ifdef CONFIG_THINKPAD_ACPI_VIDEO
5806 { 5890 {
5807 .init = video_init, 5891 .init = video_init,
5808 .data = &video_driver_data, 5892 .data = &video_driver_data,
5809 }, 5893 },
5894#endif
5810 { 5895 {
5811 .init = light_init, 5896 .init = light_init,
5812 .data = &light_driver_data, 5897 .data = &light_driver_data,
@@ -5918,7 +6003,7 @@ MODULE_PARM_DESC(hotkey_report_mode,
5918 6003
5919#define TPACPI_PARAM(feature) \ 6004#define TPACPI_PARAM(feature) \
5920 module_param_call(feature, set_ibm_param, NULL, NULL, 0); \ 6005 module_param_call(feature, set_ibm_param, NULL, NULL, 0); \
5921 MODULE_PARM_DESC(feature, "Simulates thinkpad-aci procfs command " \ 6006 MODULE_PARM_DESC(feature, "Simulates thinkpad-acpi procfs command " \
5922 "at module load, see documentation") 6007 "at module load, see documentation")
5923 6008
5924TPACPI_PARAM(hotkey); 6009TPACPI_PARAM(hotkey);
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 2f2d308c9aa3..4a23654184fc 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -242,8 +242,6 @@ EXPORT_SYMBOL(pci_osc_control_set);
242 * choose from highest power _SxD to lowest power _SxW 242 * choose from highest power _SxD to lowest power _SxW
243 * else // no _PRW at S-state x 243 * else // no _PRW at S-state x
244 * choose highest power _SxD or any lower power 244 * choose highest power _SxD or any lower power
245 *
246 * currently we simply return _SxD, if present.
247 */ 245 */
248 246
249static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev, 247static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev,
diff --git a/drivers/thermal/thermal.c b/drivers/thermal/thermal.c
index e782b3e7fcdb..8b86e53ccf7a 100644
--- a/drivers/thermal/thermal.c
+++ b/drivers/thermal/thermal.c
@@ -306,12 +306,23 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
306{ 306{
307 struct thermal_cooling_device_instance *dev; 307 struct thermal_cooling_device_instance *dev;
308 struct thermal_cooling_device_instance *pos; 308 struct thermal_cooling_device_instance *pos;
309 struct thermal_zone_device *pos1;
310 struct thermal_cooling_device *pos2;
309 int result; 311 int result;
310 312
311 if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE)) 313 if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE))
312 return -EINVAL; 314 return -EINVAL;
313 315
314 if (!tz || !cdev) 316 list_for_each_entry(pos1, &thermal_tz_list, node) {
317 if (pos1 == tz)
318 break;
319 }
320 list_for_each_entry(pos2, &thermal_cdev_list, node) {
321 if (pos2 == cdev)
322 break;
323 }
324
325 if (tz != pos1 || cdev != pos2)
315 return -EINVAL; 326 return -EINVAL;
316 327
317 dev = 328 dev =
@@ -437,20 +448,20 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type,
437 int result; 448 int result;
438 449
439 if (strlen(type) >= THERMAL_NAME_LENGTH) 450 if (strlen(type) >= THERMAL_NAME_LENGTH)
440 return NULL; 451 return ERR_PTR(-EINVAL);
441 452
442 if (!ops || !ops->get_max_state || !ops->get_cur_state || 453 if (!ops || !ops->get_max_state || !ops->get_cur_state ||
443 !ops->set_cur_state) 454 !ops->set_cur_state)
444 return NULL; 455 return ERR_PTR(-EINVAL);
445 456
446 cdev = kzalloc(sizeof(struct thermal_cooling_device), GFP_KERNEL); 457 cdev = kzalloc(sizeof(struct thermal_cooling_device), GFP_KERNEL);
447 if (!cdev) 458 if (!cdev)
448 return NULL; 459 return ERR_PTR(-ENOMEM);
449 460
450 result = get_idr(&thermal_cdev_idr, &thermal_idr_lock, &cdev->id); 461 result = get_idr(&thermal_cdev_idr, &thermal_idr_lock, &cdev->id);
451 if (result) { 462 if (result) {
452 kfree(cdev); 463 kfree(cdev);
453 return NULL; 464 return ERR_PTR(result);
454 } 465 }
455 466
456 strcpy(cdev->type, type); 467 strcpy(cdev->type, type);
@@ -462,7 +473,7 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type,
462 if (result) { 473 if (result) {
463 release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); 474 release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id);
464 kfree(cdev); 475 kfree(cdev);
465 return NULL; 476 return ERR_PTR(result);
466 } 477 }
467 478
468 /* sys I/F */ 479 /* sys I/F */
@@ -498,7 +509,7 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type,
498 unregister: 509 unregister:
499 release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); 510 release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id);
500 device_unregister(&cdev->device); 511 device_unregister(&cdev->device);
501 return NULL; 512 return ERR_PTR(result);
502} 513}
503 514
504EXPORT_SYMBOL(thermal_cooling_device_register); 515EXPORT_SYMBOL(thermal_cooling_device_register);
@@ -570,17 +581,17 @@ struct thermal_zone_device *thermal_zone_device_register(char *type,
570 int count; 581 int count;
571 582
572 if (strlen(type) >= THERMAL_NAME_LENGTH) 583 if (strlen(type) >= THERMAL_NAME_LENGTH)
573 return NULL; 584 return ERR_PTR(-EINVAL);
574 585
575 if (trips > THERMAL_MAX_TRIPS || trips < 0) 586 if (trips > THERMAL_MAX_TRIPS || trips < 0)
576 return NULL; 587 return ERR_PTR(-EINVAL);
577 588
578 if (!ops || !ops->get_temp) 589 if (!ops || !ops->get_temp)
579 return NULL; 590 return ERR_PTR(-EINVAL);
580 591
581 tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL); 592 tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL);
582 if (!tz) 593 if (!tz)
583 return NULL; 594 return ERR_PTR(-ENOMEM);
584 595
585 INIT_LIST_HEAD(&tz->cooling_devices); 596 INIT_LIST_HEAD(&tz->cooling_devices);
586 idr_init(&tz->idr); 597 idr_init(&tz->idr);
@@ -588,7 +599,7 @@ struct thermal_zone_device *thermal_zone_device_register(char *type,
588 result = get_idr(&thermal_tz_idr, &thermal_idr_lock, &tz->id); 599 result = get_idr(&thermal_tz_idr, &thermal_idr_lock, &tz->id);
589 if (result) { 600 if (result) {
590 kfree(tz); 601 kfree(tz);
591 return NULL; 602 return ERR_PTR(result);
592 } 603 }
593 604
594 strcpy(tz->type, type); 605 strcpy(tz->type, type);
@@ -601,7 +612,7 @@ struct thermal_zone_device *thermal_zone_device_register(char *type,
601 if (result) { 612 if (result) {
602 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); 613 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
603 kfree(tz); 614 kfree(tz);
604 return NULL; 615 return ERR_PTR(result);
605 } 616 }
606 617
607 /* sys I/F */ 618 /* sys I/F */
@@ -643,7 +654,7 @@ struct thermal_zone_device *thermal_zone_device_register(char *type,
643 unregister: 654 unregister:
644 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); 655 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
645 device_unregister(&tz->device); 656 device_unregister(&tz->device);
646 return NULL; 657 return ERR_PTR(result);
647} 658}
648 659
649EXPORT_SYMBOL(thermal_zone_device_register); 660EXPORT_SYMBOL(thermal_zone_device_register);