aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-13 23:41:48 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-13 23:41:48 -0500
commitf9300eaaac1ca300083ad41937923a90cc3a2394 (patch)
tree724b72ad729a8b85c09d2d54f8ca7d8ba22d774f /drivers/platform/x86
parent7f2dc5c4bcbff035b0d03f7aa78a182664b21e47 (diff)
parentfaddf2f5d278f1656e9444961bdd8d9db4deb5bf (diff)
Merge tag 'pm+acpi-3.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI and power management updates from Rafael J Wysocki: - New power capping framework and the the Intel Running Average Power Limit (RAPL) driver using it from Srinivas Pandruvada and Jacob Pan. - Addition of the in-kernel switching feature to the arm_big_little cpufreq driver from Viresh Kumar and Nicolas Pitre. - cpufreq support for iMac G5 from Aaro Koskinen. - Baytrail processors support for intel_pstate from Dirk Brandewie. - cpufreq support for Midway/ECX-2000 from Mark Langsdorf. - ARM vexpress/TC2 cpufreq support from Sudeep KarkadaNagesha. - ACPI power management support for the I2C and SPI bus types from Mika Westerberg and Lv Zheng. - cpufreq core fixes and cleanups from Viresh Kumar, Srivatsa S Bhat, Stratos Karafotis, Xiaoguang Chen, Lan Tianyu. - cpufreq drivers updates (mostly fixes and cleanups) from Viresh Kumar, Aaro Koskinen, Jungseok Lee, Sudeep KarkadaNagesha, Lukasz Majewski, Manish Badarkhe, Hans-Christian Egtvedt, Evgeny Kapaev. - intel_pstate updates from Dirk Brandewie and Adrian Huang. - ACPICA update to version 20130927 includig fixes and cleanups and some reduction of divergences between the ACPICA code in the kernel and ACPICA upstream in order to improve the automatic ACPICA patch generation process. From Bob Moore, Lv Zheng, Tomasz Nowicki, Naresh Bhat, Bjorn Helgaas, David E Box. - ACPI IPMI driver fixes and cleanups from Lv Zheng. - ACPI hotplug fixes and cleanups from Bjorn Helgaas, Toshi Kani, Zhang Yanfei, Rafael J Wysocki. - Conversion of the ACPI AC driver to the platform bus type and multiple driver fixes and cleanups related to ACPI from Zhang Rui. - ACPI processor driver fixes and cleanups from Hanjun Guo, Jiang Liu, Bartlomiej Zolnierkiewicz, Mathieu Rhéaume, Rafael J Wysocki. - Fixes and cleanups and new blacklist entries related to the ACPI video support from Aaron Lu, Felipe Contreras, Lennart Poettering, Kirill Tkhai. - cpuidle core cleanups from Viresh Kumar and Lorenzo Pieralisi. - cpuidle drivers fixes and cleanups from Daniel Lezcano, Jingoo Han, Bartlomiej Zolnierkiewicz, Prarit Bhargava. - devfreq updates from Sachin Kamat, Dan Carpenter, Manish Badarkhe. - Operation Performance Points (OPP) core updates from Nishanth Menon. - Runtime power management core fix from Rafael J Wysocki and update from Ulf Hansson. - Hibernation fixes from Aaron Lu and Rafael J Wysocki. - Device suspend/resume lockup detection mechanism from Benoit Goby. - Removal of unused proc directories created for various ACPI drivers from Lan Tianyu. - ACPI LPSS driver fix and new device IDs for the ACPI platform scan handler from Heikki Krogerus and Jarkko Nikula. - New ACPI _OSI blacklist entry for Toshiba NB100 from Levente Kurusa. - Assorted fixes and cleanups related to ACPI from Andy Shevchenko, Al Stone, Bartlomiej Zolnierkiewicz, Colin Ian King, Dan Carpenter, Felipe Contreras, Jianguo Wu, Lan Tianyu, Yinghai Lu, Mathias Krause, Liu Chuansheng. - Assorted PM fixes and cleanups from Andy Shevchenko, Thierry Reding, Jean-Christophe Plagniol-Villard. * tag 'pm+acpi-3.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (386 commits) cpufreq: conservative: fix requested_freq reduction issue ACPI / hotplug: Consolidate deferred execution of ACPI hotplug routines PM / runtime: Use pm_runtime_put_sync() in __device_release_driver() ACPI / event: remove unneeded NULL pointer check Revert "ACPI / video: Ignore BIOS initial backlight value for HP 250 G1" ACPI / video: Quirk initial backlight level 0 ACPI / video: Fix initial level validity test intel_pstate: skip the driver if ACPI has power mgmt option PM / hibernate: Avoid overflow in hibernate_preallocate_memory() ACPI / hotplug: Do not execute "insert in progress" _OST ACPI / hotplug: Carry out PCI root eject directly ACPI / hotplug: Merge device hot-removal routines ACPI / hotplug: Make acpi_bus_hot_remove_device() internal ACPI / hotplug: Simplify device ejection routines ACPI / hotplug: Fix handle_root_bridge_removal() ACPI / hotplug: Refuse to hot-remove all objects with disabled hotplug ACPI / scan: Start matching drivers after trying scan handlers ACPI: Remove acpi_pci_slot_init() headers from internal.h ACPI / blacklist: fix name of ThinkPad Edge E530 PowerCap: Fix build error with option -Werror=format-security ... Conflicts: arch/arm/mach-omap2/opp.c drivers/Kconfig drivers/spi/spi.c
Diffstat (limited to 'drivers/platform/x86')
-rw-r--r--drivers/platform/x86/eeepc-laptop.c8
-rw-r--r--drivers/platform/x86/fujitsu-laptop.c44
-rw-r--r--drivers/platform/x86/ideapad-laptop.c344
-rw-r--r--drivers/platform/x86/intel-rst.c48
-rw-r--r--drivers/platform/x86/intel-smartconnect.c27
-rw-r--r--drivers/platform/x86/intel_menlow.c8
-rw-r--r--drivers/platform/x86/sony-laptop.c28
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c31
-rw-r--r--drivers/platform/x86/topstar-laptop.c8
-rw-r--r--drivers/platform/x86/toshiba_acpi.c44
-rw-r--r--drivers/platform/x86/wmi.c30
11 files changed, 264 insertions, 356 deletions
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index a6afd4108beb..aefcc32e5634 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -190,16 +190,10 @@ struct eeepc_laptop {
190 */ 190 */
191static int write_acpi_int(acpi_handle handle, const char *method, int val) 191static int write_acpi_int(acpi_handle handle, const char *method, int val)
192{ 192{
193 struct acpi_object_list params;
194 union acpi_object in_obj;
195 acpi_status status; 193 acpi_status status;
196 194
197 params.count = 1; 195 status = acpi_execute_simple_method(handle, (char *)method, val);
198 params.pointer = &in_obj;
199 in_obj.type = ACPI_TYPE_INTEGER;
200 in_obj.integer.value = val;
201 196
202 status = acpi_evaluate_object(handle, (char *)method, &params, NULL);
203 return (status == AE_OK ? 0 : -1); 197 return (status == AE_OK ? 0 : -1);
204} 198}
205 199
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 52b8a97efde1..9d30d69aa78f 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -219,8 +219,7 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
219 { .type = ACPI_TYPE_INTEGER } 219 { .type = ACPI_TYPE_INTEGER }
220 }; 220 };
221 struct acpi_object_list arg_list = { 4, &params[0] }; 221 struct acpi_object_list arg_list = { 4, &params[0] };
222 struct acpi_buffer output; 222 unsigned long long value;
223 union acpi_object out_obj;
224 acpi_handle handle = NULL; 223 acpi_handle handle = NULL;
225 224
226 status = acpi_get_handle(fujitsu_hotkey->acpi_handle, "FUNC", &handle); 225 status = acpi_get_handle(fujitsu_hotkey->acpi_handle, "FUNC", &handle);
@@ -235,10 +234,7 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
235 params[2].integer.value = arg1; 234 params[2].integer.value = arg1;
236 params[3].integer.value = arg2; 235 params[3].integer.value = arg2;
237 236
238 output.length = sizeof(out_obj); 237 status = acpi_evaluate_integer(handle, NULL, &arg_list, &value);
239 output.pointer = &out_obj;
240
241 status = acpi_evaluate_object(handle, NULL, &arg_list, &output);
242 if (ACPI_FAILURE(status)) { 238 if (ACPI_FAILURE(status)) {
243 vdbg_printk(FUJLAPTOP_DBG_WARN, 239 vdbg_printk(FUJLAPTOP_DBG_WARN,
244 "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) call failed\n", 240 "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) call failed\n",
@@ -246,18 +242,10 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
246 return -ENODEV; 242 return -ENODEV;
247 } 243 }
248 244
249 if (out_obj.type != ACPI_TYPE_INTEGER) {
250 vdbg_printk(FUJLAPTOP_DBG_WARN,
251 "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) did not "
252 "return an integer\n",
253 cmd, arg0, arg1, arg2);
254 return -ENODEV;
255 }
256
257 vdbg_printk(FUJLAPTOP_DBG_TRACE, 245 vdbg_printk(FUJLAPTOP_DBG_TRACE,
258 "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n", 246 "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n",
259 cmd, arg0, arg1, arg2, (int)out_obj.integer.value); 247 cmd, arg0, arg1, arg2, (int)value);
260 return out_obj.integer.value; 248 return value;
261} 249}
262 250
263#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) 251#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
@@ -317,8 +305,6 @@ static enum led_brightness kblamps_get(struct led_classdev *cdev)
317static int set_lcd_level(int level) 305static int set_lcd_level(int level)
318{ 306{
319 acpi_status status = AE_OK; 307 acpi_status status = AE_OK;
320 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
321 struct acpi_object_list arg_list = { 1, &arg0 };
322 acpi_handle handle = NULL; 308 acpi_handle handle = NULL;
323 309
324 vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBLL [%d]\n", 310 vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBLL [%d]\n",
@@ -333,9 +319,8 @@ static int set_lcd_level(int level)
333 return -ENODEV; 319 return -ENODEV;
334 } 320 }
335 321
336 arg0.integer.value = level;
337 322
338 status = acpi_evaluate_object(handle, NULL, &arg_list, NULL); 323 status = acpi_execute_simple_method(handle, NULL, level);
339 if (ACPI_FAILURE(status)) 324 if (ACPI_FAILURE(status))
340 return -ENODEV; 325 return -ENODEV;
341 326
@@ -345,8 +330,6 @@ static int set_lcd_level(int level)
345static int set_lcd_level_alt(int level) 330static int set_lcd_level_alt(int level)
346{ 331{
347 acpi_status status = AE_OK; 332 acpi_status status = AE_OK;
348 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
349 struct acpi_object_list arg_list = { 1, &arg0 };
350 acpi_handle handle = NULL; 333 acpi_handle handle = NULL;
351 334
352 vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBL2 [%d]\n", 335 vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBL2 [%d]\n",
@@ -361,9 +344,7 @@ static int set_lcd_level_alt(int level)
361 return -ENODEV; 344 return -ENODEV;
362 } 345 }
363 346
364 arg0.integer.value = level; 347 status = acpi_execute_simple_method(handle, NULL, level);
365
366 status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
367 if (ACPI_FAILURE(status)) 348 if (ACPI_FAILURE(status))
368 return -ENODEV; 349 return -ENODEV;
369 350
@@ -586,11 +567,10 @@ static struct platform_driver fujitsupf_driver = {
586 567
587static void dmi_check_cb_common(const struct dmi_system_id *id) 568static void dmi_check_cb_common(const struct dmi_system_id *id)
588{ 569{
589 acpi_handle handle;
590 pr_info("Identified laptop model '%s'\n", id->ident); 570 pr_info("Identified laptop model '%s'\n", id->ident);
591 if (use_alt_lcd_levels == -1) { 571 if (use_alt_lcd_levels == -1) {
592 if (ACPI_SUCCESS(acpi_get_handle(NULL, 572 if (acpi_has_method(NULL,
593 "\\_SB.PCI0.LPCB.FJEX.SBL2", &handle))) 573 "\\_SB.PCI0.LPCB.FJEX.SBL2"))
594 use_alt_lcd_levels = 1; 574 use_alt_lcd_levels = 1;
595 else 575 else
596 use_alt_lcd_levels = 0; 576 use_alt_lcd_levels = 0;
@@ -653,7 +633,6 @@ static struct dmi_system_id fujitsu_dmi_table[] = {
653 633
654static int acpi_fujitsu_add(struct acpi_device *device) 634static int acpi_fujitsu_add(struct acpi_device *device)
655{ 635{
656 acpi_handle handle;
657 int result = 0; 636 int result = 0;
658 int state = 0; 637 int state = 0;
659 struct input_dev *input; 638 struct input_dev *input;
@@ -702,8 +681,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
702 681
703 fujitsu->dev = device; 682 fujitsu->dev = device;
704 683
705 if (ACPI_SUCCESS 684 if (acpi_has_method(device->handle, METHOD_NAME__INI)) {
706 (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) {
707 vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n"); 685 vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
708 if (ACPI_FAILURE 686 if (ACPI_FAILURE
709 (acpi_evaluate_object 687 (acpi_evaluate_object
@@ -803,7 +781,6 @@ static void acpi_fujitsu_notify(struct acpi_device *device, u32 event)
803 781
804static int acpi_fujitsu_hotkey_add(struct acpi_device *device) 782static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
805{ 783{
806 acpi_handle handle;
807 int result = 0; 784 int result = 0;
808 int state = 0; 785 int state = 0;
809 struct input_dev *input; 786 struct input_dev *input;
@@ -866,8 +843,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
866 843
867 fujitsu_hotkey->dev = device; 844 fujitsu_hotkey->dev = device;
868 845
869 if (ACPI_SUCCESS 846 if (acpi_has_method(device->handle, METHOD_NAME__INI)) {
870 (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) {
871 vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n"); 847 vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
872 if (ACPI_FAILURE 848 if (ACPI_FAILURE
873 (acpi_evaluate_object 849 (acpi_evaluate_object
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 89c4519d48ac..6788acc22ab9 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -72,8 +72,15 @@ enum {
72 VPCCMD_W_BL_POWER = 0x33, 72 VPCCMD_W_BL_POWER = 0x33,
73}; 73};
74 74
75struct ideapad_rfk_priv {
76 int dev;
77 struct ideapad_private *priv;
78};
79
75struct ideapad_private { 80struct ideapad_private {
81 struct acpi_device *adev;
76 struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM]; 82 struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM];
83 struct ideapad_rfk_priv rfk_priv[IDEAPAD_RFKILL_DEV_NUM];
77 struct platform_device *platform_device; 84 struct platform_device *platform_device;
78 struct input_dev *inputdev; 85 struct input_dev *inputdev;
79 struct backlight_device *blightdev; 86 struct backlight_device *blightdev;
@@ -81,8 +88,6 @@ struct ideapad_private {
81 unsigned long cfg; 88 unsigned long cfg;
82}; 89};
83 90
84static acpi_handle ideapad_handle;
85static struct ideapad_private *ideapad_priv;
86static bool no_bt_rfkill; 91static bool no_bt_rfkill;
87module_param(no_bt_rfkill, bool, 0444); 92module_param(no_bt_rfkill, bool, 0444);
88MODULE_PARM_DESC(no_bt_rfkill, "No rfkill for bluetooth."); 93MODULE_PARM_DESC(no_bt_rfkill, "No rfkill for bluetooth.");
@@ -200,34 +205,38 @@ static int write_ec_cmd(acpi_handle handle, int cmd, unsigned long data)
200 */ 205 */
201static int debugfs_status_show(struct seq_file *s, void *data) 206static int debugfs_status_show(struct seq_file *s, void *data)
202{ 207{
208 struct ideapad_private *priv = s->private;
203 unsigned long value; 209 unsigned long value;
204 210
205 if (!read_ec_data(ideapad_handle, VPCCMD_R_BL_MAX, &value)) 211 if (!priv)
212 return -EINVAL;
213
214 if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &value))
206 seq_printf(s, "Backlight max:\t%lu\n", value); 215 seq_printf(s, "Backlight max:\t%lu\n", value);
207 if (!read_ec_data(ideapad_handle, VPCCMD_R_BL, &value)) 216 if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL, &value))
208 seq_printf(s, "Backlight now:\t%lu\n", value); 217 seq_printf(s, "Backlight now:\t%lu\n", value);
209 if (!read_ec_data(ideapad_handle, VPCCMD_R_BL_POWER, &value)) 218 if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &value))
210 seq_printf(s, "BL power value:\t%s\n", value ? "On" : "Off"); 219 seq_printf(s, "BL power value:\t%s\n", value ? "On" : "Off");
211 seq_printf(s, "=====================\n"); 220 seq_printf(s, "=====================\n");
212 221
213 if (!read_ec_data(ideapad_handle, VPCCMD_R_RF, &value)) 222 if (!read_ec_data(priv->adev->handle, VPCCMD_R_RF, &value))
214 seq_printf(s, "Radio status:\t%s(%lu)\n", 223 seq_printf(s, "Radio status:\t%s(%lu)\n",
215 value ? "On" : "Off", value); 224 value ? "On" : "Off", value);
216 if (!read_ec_data(ideapad_handle, VPCCMD_R_WIFI, &value)) 225 if (!read_ec_data(priv->adev->handle, VPCCMD_R_WIFI, &value))
217 seq_printf(s, "Wifi status:\t%s(%lu)\n", 226 seq_printf(s, "Wifi status:\t%s(%lu)\n",
218 value ? "On" : "Off", value); 227 value ? "On" : "Off", value);
219 if (!read_ec_data(ideapad_handle, VPCCMD_R_BT, &value)) 228 if (!read_ec_data(priv->adev->handle, VPCCMD_R_BT, &value))
220 seq_printf(s, "BT status:\t%s(%lu)\n", 229 seq_printf(s, "BT status:\t%s(%lu)\n",
221 value ? "On" : "Off", value); 230 value ? "On" : "Off", value);
222 if (!read_ec_data(ideapad_handle, VPCCMD_R_3G, &value)) 231 if (!read_ec_data(priv->adev->handle, VPCCMD_R_3G, &value))
223 seq_printf(s, "3G status:\t%s(%lu)\n", 232 seq_printf(s, "3G status:\t%s(%lu)\n",
224 value ? "On" : "Off", value); 233 value ? "On" : "Off", value);
225 seq_printf(s, "=====================\n"); 234 seq_printf(s, "=====================\n");
226 235
227 if (!read_ec_data(ideapad_handle, VPCCMD_R_TOUCHPAD, &value)) 236 if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value))
228 seq_printf(s, "Touchpad status:%s(%lu)\n", 237 seq_printf(s, "Touchpad status:%s(%lu)\n",
229 value ? "On" : "Off", value); 238 value ? "On" : "Off", value);
230 if (!read_ec_data(ideapad_handle, VPCCMD_R_CAMERA, &value)) 239 if (!read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &value))
231 seq_printf(s, "Camera status:\t%s(%lu)\n", 240 seq_printf(s, "Camera status:\t%s(%lu)\n",
232 value ? "On" : "Off", value); 241 value ? "On" : "Off", value);
233 242
@@ -236,7 +245,7 @@ static int debugfs_status_show(struct seq_file *s, void *data)
236 245
237static int debugfs_status_open(struct inode *inode, struct file *file) 246static int debugfs_status_open(struct inode *inode, struct file *file)
238{ 247{
239 return single_open(file, debugfs_status_show, NULL); 248 return single_open(file, debugfs_status_show, inode->i_private);
240} 249}
241 250
242static const struct file_operations debugfs_status_fops = { 251static const struct file_operations debugfs_status_fops = {
@@ -249,21 +258,23 @@ static const struct file_operations debugfs_status_fops = {
249 258
250static int debugfs_cfg_show(struct seq_file *s, void *data) 259static int debugfs_cfg_show(struct seq_file *s, void *data)
251{ 260{
252 if (!ideapad_priv) { 261 struct ideapad_private *priv = s->private;
262
263 if (!priv) {
253 seq_printf(s, "cfg: N/A\n"); 264 seq_printf(s, "cfg: N/A\n");
254 } else { 265 } else {
255 seq_printf(s, "cfg: 0x%.8lX\n\nCapability: ", 266 seq_printf(s, "cfg: 0x%.8lX\n\nCapability: ",
256 ideapad_priv->cfg); 267 priv->cfg);
257 if (test_bit(CFG_BT_BIT, &ideapad_priv->cfg)) 268 if (test_bit(CFG_BT_BIT, &priv->cfg))
258 seq_printf(s, "Bluetooth "); 269 seq_printf(s, "Bluetooth ");
259 if (test_bit(CFG_3G_BIT, &ideapad_priv->cfg)) 270 if (test_bit(CFG_3G_BIT, &priv->cfg))
260 seq_printf(s, "3G "); 271 seq_printf(s, "3G ");
261 if (test_bit(CFG_WIFI_BIT, &ideapad_priv->cfg)) 272 if (test_bit(CFG_WIFI_BIT, &priv->cfg))
262 seq_printf(s, "Wireless "); 273 seq_printf(s, "Wireless ");
263 if (test_bit(CFG_CAMERA_BIT, &ideapad_priv->cfg)) 274 if (test_bit(CFG_CAMERA_BIT, &priv->cfg))
264 seq_printf(s, "Camera "); 275 seq_printf(s, "Camera ");
265 seq_printf(s, "\nGraphic: "); 276 seq_printf(s, "\nGraphic: ");
266 switch ((ideapad_priv->cfg)&0x700) { 277 switch ((priv->cfg)&0x700) {
267 case 0x100: 278 case 0x100:
268 seq_printf(s, "Intel"); 279 seq_printf(s, "Intel");
269 break; 280 break;
@@ -287,7 +298,7 @@ static int debugfs_cfg_show(struct seq_file *s, void *data)
287 298
288static int debugfs_cfg_open(struct inode *inode, struct file *file) 299static int debugfs_cfg_open(struct inode *inode, struct file *file)
289{ 300{
290 return single_open(file, debugfs_cfg_show, NULL); 301 return single_open(file, debugfs_cfg_show, inode->i_private);
291} 302}
292 303
293static const struct file_operations debugfs_cfg_fops = { 304static const struct file_operations debugfs_cfg_fops = {
@@ -308,14 +319,14 @@ static int ideapad_debugfs_init(struct ideapad_private *priv)
308 goto errout; 319 goto errout;
309 } 320 }
310 321
311 node = debugfs_create_file("cfg", S_IRUGO, priv->debug, NULL, 322 node = debugfs_create_file("cfg", S_IRUGO, priv->debug, priv,
312 &debugfs_cfg_fops); 323 &debugfs_cfg_fops);
313 if (!node) { 324 if (!node) {
314 pr_err("failed to create cfg in debugfs"); 325 pr_err("failed to create cfg in debugfs");
315 goto errout; 326 goto errout;
316 } 327 }
317 328
318 node = debugfs_create_file("status", S_IRUGO, priv->debug, NULL, 329 node = debugfs_create_file("status", S_IRUGO, priv->debug, priv,
319 &debugfs_status_fops); 330 &debugfs_status_fops);
320 if (!node) { 331 if (!node) {
321 pr_err("failed to create status in debugfs"); 332 pr_err("failed to create status in debugfs");
@@ -342,8 +353,9 @@ static ssize_t show_ideapad_cam(struct device *dev,
342 char *buf) 353 char *buf)
343{ 354{
344 unsigned long result; 355 unsigned long result;
356 struct ideapad_private *priv = dev_get_drvdata(dev);
345 357
346 if (read_ec_data(ideapad_handle, VPCCMD_R_CAMERA, &result)) 358 if (read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &result))
347 return sprintf(buf, "-1\n"); 359 return sprintf(buf, "-1\n");
348 return sprintf(buf, "%lu\n", result); 360 return sprintf(buf, "%lu\n", result);
349} 361}
@@ -353,12 +365,13 @@ static ssize_t store_ideapad_cam(struct device *dev,
353 const char *buf, size_t count) 365 const char *buf, size_t count)
354{ 366{
355 int ret, state; 367 int ret, state;
368 struct ideapad_private *priv = dev_get_drvdata(dev);
356 369
357 if (!count) 370 if (!count)
358 return 0; 371 return 0;
359 if (sscanf(buf, "%i", &state) != 1) 372 if (sscanf(buf, "%i", &state) != 1)
360 return -EINVAL; 373 return -EINVAL;
361 ret = write_ec_cmd(ideapad_handle, VPCCMD_W_CAMERA, state); 374 ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_CAMERA, state);
362 if (ret < 0) 375 if (ret < 0)
363 return -EIO; 376 return -EIO;
364 return count; 377 return count;
@@ -371,8 +384,9 @@ static ssize_t show_ideapad_fan(struct device *dev,
371 char *buf) 384 char *buf)
372{ 385{
373 unsigned long result; 386 unsigned long result;
387 struct ideapad_private *priv = dev_get_drvdata(dev);
374 388
375 if (read_ec_data(ideapad_handle, VPCCMD_R_FAN, &result)) 389 if (read_ec_data(priv->adev->handle, VPCCMD_R_FAN, &result))
376 return sprintf(buf, "-1\n"); 390 return sprintf(buf, "-1\n");
377 return sprintf(buf, "%lu\n", result); 391 return sprintf(buf, "%lu\n", result);
378} 392}
@@ -382,6 +396,7 @@ static ssize_t store_ideapad_fan(struct device *dev,
382 const char *buf, size_t count) 396 const char *buf, size_t count)
383{ 397{
384 int ret, state; 398 int ret, state;
399 struct ideapad_private *priv = dev_get_drvdata(dev);
385 400
386 if (!count) 401 if (!count)
387 return 0; 402 return 0;
@@ -389,7 +404,7 @@ static ssize_t store_ideapad_fan(struct device *dev,
389 return -EINVAL; 404 return -EINVAL;
390 if (state < 0 || state > 4 || state == 3) 405 if (state < 0 || state > 4 || state == 3)
391 return -EINVAL; 406 return -EINVAL;
392 ret = write_ec_cmd(ideapad_handle, VPCCMD_W_FAN, state); 407 ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_FAN, state);
393 if (ret < 0) 408 if (ret < 0)
394 return -EIO; 409 return -EIO;
395 return count; 410 return count;
@@ -415,7 +430,8 @@ static umode_t ideapad_is_visible(struct kobject *kobj,
415 supported = test_bit(CFG_CAMERA_BIT, &(priv->cfg)); 430 supported = test_bit(CFG_CAMERA_BIT, &(priv->cfg));
416 else if (attr == &dev_attr_fan_mode.attr) { 431 else if (attr == &dev_attr_fan_mode.attr) {
417 unsigned long value; 432 unsigned long value;
418 supported = !read_ec_data(ideapad_handle, VPCCMD_R_FAN, &value); 433 supported = !read_ec_data(priv->adev->handle, VPCCMD_R_FAN,
434 &value);
419 } else 435 } else
420 supported = true; 436 supported = true;
421 437
@@ -445,9 +461,9 @@ const struct ideapad_rfk_data ideapad_rfk_data[] = {
445 461
446static int ideapad_rfk_set(void *data, bool blocked) 462static int ideapad_rfk_set(void *data, bool blocked)
447{ 463{
448 unsigned long opcode = (unsigned long)data; 464 struct ideapad_rfk_priv *priv = data;
449 465
450 return write_ec_cmd(ideapad_handle, opcode, !blocked); 466 return write_ec_cmd(priv->priv->adev->handle, priv->dev, !blocked);
451} 467}
452 468
453static struct rfkill_ops ideapad_rfk_ops = { 469static struct rfkill_ops ideapad_rfk_ops = {
@@ -459,7 +475,7 @@ static void ideapad_sync_rfk_state(struct ideapad_private *priv)
459 unsigned long hw_blocked; 475 unsigned long hw_blocked;
460 int i; 476 int i;
461 477
462 if (read_ec_data(ideapad_handle, VPCCMD_R_RF, &hw_blocked)) 478 if (read_ec_data(priv->adev->handle, VPCCMD_R_RF, &hw_blocked))
463 return; 479 return;
464 hw_blocked = !hw_blocked; 480 hw_blocked = !hw_blocked;
465 481
@@ -468,27 +484,30 @@ static void ideapad_sync_rfk_state(struct ideapad_private *priv)
468 rfkill_set_hw_state(priv->rfk[i], hw_blocked); 484 rfkill_set_hw_state(priv->rfk[i], hw_blocked);
469} 485}
470 486
471static int ideapad_register_rfkill(struct acpi_device *adevice, int dev) 487static int ideapad_register_rfkill(struct ideapad_private *priv, int dev)
472{ 488{
473 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
474 int ret; 489 int ret;
475 unsigned long sw_blocked; 490 unsigned long sw_blocked;
476 491
477 if (no_bt_rfkill && 492 if (no_bt_rfkill &&
478 (ideapad_rfk_data[dev].type == RFKILL_TYPE_BLUETOOTH)) { 493 (ideapad_rfk_data[dev].type == RFKILL_TYPE_BLUETOOTH)) {
479 /* Force to enable bluetooth when no_bt_rfkill=1 */ 494 /* Force to enable bluetooth when no_bt_rfkill=1 */
480 write_ec_cmd(ideapad_handle, 495 write_ec_cmd(priv->adev->handle,
481 ideapad_rfk_data[dev].opcode, 1); 496 ideapad_rfk_data[dev].opcode, 1);
482 return 0; 497 return 0;
483 } 498 }
484 499 priv->rfk_priv[dev].dev = dev;
485 priv->rfk[dev] = rfkill_alloc(ideapad_rfk_data[dev].name, &adevice->dev, 500 priv->rfk_priv[dev].priv = priv;
486 ideapad_rfk_data[dev].type, &ideapad_rfk_ops, 501
487 (void *)(long)dev); 502 priv->rfk[dev] = rfkill_alloc(ideapad_rfk_data[dev].name,
503 &priv->platform_device->dev,
504 ideapad_rfk_data[dev].type,
505 &ideapad_rfk_ops,
506 &priv->rfk_priv[dev]);
488 if (!priv->rfk[dev]) 507 if (!priv->rfk[dev])
489 return -ENOMEM; 508 return -ENOMEM;
490 509
491 if (read_ec_data(ideapad_handle, ideapad_rfk_data[dev].opcode-1, 510 if (read_ec_data(priv->adev->handle, ideapad_rfk_data[dev].opcode-1,
492 &sw_blocked)) { 511 &sw_blocked)) {
493 rfkill_init_sw_state(priv->rfk[dev], 0); 512 rfkill_init_sw_state(priv->rfk[dev], 0);
494 } else { 513 } else {
@@ -504,10 +523,8 @@ static int ideapad_register_rfkill(struct acpi_device *adevice, int dev)
504 return 0; 523 return 0;
505} 524}
506 525
507static void ideapad_unregister_rfkill(struct acpi_device *adevice, int dev) 526static void ideapad_unregister_rfkill(struct ideapad_private *priv, int dev)
508{ 527{
509 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
510
511 if (!priv->rfk[dev]) 528 if (!priv->rfk[dev])
512 return; 529 return;
513 530
@@ -518,37 +535,16 @@ static void ideapad_unregister_rfkill(struct acpi_device *adevice, int dev)
518/* 535/*
519 * Platform device 536 * Platform device
520 */ 537 */
521static int ideapad_platform_init(struct ideapad_private *priv) 538static int ideapad_sysfs_init(struct ideapad_private *priv)
522{ 539{
523 int result; 540 return sysfs_create_group(&priv->platform_device->dev.kobj,
524
525 priv->platform_device = platform_device_alloc("ideapad", -1);
526 if (!priv->platform_device)
527 return -ENOMEM;
528 platform_set_drvdata(priv->platform_device, priv);
529
530 result = platform_device_add(priv->platform_device);
531 if (result)
532 goto fail_platform_device;
533
534 result = sysfs_create_group(&priv->platform_device->dev.kobj,
535 &ideapad_attribute_group); 541 &ideapad_attribute_group);
536 if (result)
537 goto fail_sysfs;
538 return 0;
539
540fail_sysfs:
541 platform_device_del(priv->platform_device);
542fail_platform_device:
543 platform_device_put(priv->platform_device);
544 return result;
545} 542}
546 543
547static void ideapad_platform_exit(struct ideapad_private *priv) 544static void ideapad_sysfs_exit(struct ideapad_private *priv)
548{ 545{
549 sysfs_remove_group(&priv->platform_device->dev.kobj, 546 sysfs_remove_group(&priv->platform_device->dev.kobj,
550 &ideapad_attribute_group); 547 &ideapad_attribute_group);
551 platform_device_unregister(priv->platform_device);
552} 548}
553 549
554/* 550/*
@@ -623,7 +619,7 @@ static void ideapad_input_novokey(struct ideapad_private *priv)
623{ 619{
624 unsigned long long_pressed; 620 unsigned long long_pressed;
625 621
626 if (read_ec_data(ideapad_handle, VPCCMD_R_NOVO, &long_pressed)) 622 if (read_ec_data(priv->adev->handle, VPCCMD_R_NOVO, &long_pressed))
627 return; 623 return;
628 if (long_pressed) 624 if (long_pressed)
629 ideapad_input_report(priv, 17); 625 ideapad_input_report(priv, 17);
@@ -635,7 +631,7 @@ static void ideapad_check_special_buttons(struct ideapad_private *priv)
635{ 631{
636 unsigned long bit, value; 632 unsigned long bit, value;
637 633
638 read_ec_data(ideapad_handle, VPCCMD_R_SPECIAL_BUTTONS, &value); 634 read_ec_data(priv->adev->handle, VPCCMD_R_SPECIAL_BUTTONS, &value);
639 635
640 for (bit = 0; bit < 16; bit++) { 636 for (bit = 0; bit < 16; bit++) {
641 if (test_bit(bit, &value)) { 637 if (test_bit(bit, &value)) {
@@ -662,19 +658,28 @@ static void ideapad_check_special_buttons(struct ideapad_private *priv)
662 */ 658 */
663static int ideapad_backlight_get_brightness(struct backlight_device *blightdev) 659static int ideapad_backlight_get_brightness(struct backlight_device *blightdev)
664{ 660{
661 struct ideapad_private *priv = bl_get_data(blightdev);
665 unsigned long now; 662 unsigned long now;
666 663
667 if (read_ec_data(ideapad_handle, VPCCMD_R_BL, &now)) 664 if (!priv)
665 return -EINVAL;
666
667 if (read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now))
668 return -EIO; 668 return -EIO;
669 return now; 669 return now;
670} 670}
671 671
672static int ideapad_backlight_update_status(struct backlight_device *blightdev) 672static int ideapad_backlight_update_status(struct backlight_device *blightdev)
673{ 673{
674 if (write_ec_cmd(ideapad_handle, VPCCMD_W_BL, 674 struct ideapad_private *priv = bl_get_data(blightdev);
675
676 if (!priv)
677 return -EINVAL;
678
679 if (write_ec_cmd(priv->adev->handle, VPCCMD_W_BL,
675 blightdev->props.brightness)) 680 blightdev->props.brightness))
676 return -EIO; 681 return -EIO;
677 if (write_ec_cmd(ideapad_handle, VPCCMD_W_BL_POWER, 682 if (write_ec_cmd(priv->adev->handle, VPCCMD_W_BL_POWER,
678 blightdev->props.power == FB_BLANK_POWERDOWN ? 0 : 1)) 683 blightdev->props.power == FB_BLANK_POWERDOWN ? 0 : 1))
679 return -EIO; 684 return -EIO;
680 685
@@ -692,11 +697,11 @@ static int ideapad_backlight_init(struct ideapad_private *priv)
692 struct backlight_properties props; 697 struct backlight_properties props;
693 unsigned long max, now, power; 698 unsigned long max, now, power;
694 699
695 if (read_ec_data(ideapad_handle, VPCCMD_R_BL_MAX, &max)) 700 if (read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &max))
696 return -EIO; 701 return -EIO;
697 if (read_ec_data(ideapad_handle, VPCCMD_R_BL, &now)) 702 if (read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now))
698 return -EIO; 703 return -EIO;
699 if (read_ec_data(ideapad_handle, VPCCMD_R_BL_POWER, &power)) 704 if (read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &power))
700 return -EIO; 705 return -EIO;
701 706
702 memset(&props, 0, sizeof(struct backlight_properties)); 707 memset(&props, 0, sizeof(struct backlight_properties));
@@ -734,7 +739,7 @@ static void ideapad_backlight_notify_power(struct ideapad_private *priv)
734 739
735 if (!blightdev) 740 if (!blightdev)
736 return; 741 return;
737 if (read_ec_data(ideapad_handle, VPCCMD_R_BL_POWER, &power)) 742 if (read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &power))
738 return; 743 return;
739 blightdev->props.power = power ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 744 blightdev->props.power = power ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
740} 745}
@@ -745,7 +750,7 @@ static void ideapad_backlight_notify_brightness(struct ideapad_private *priv)
745 750
746 /* if we control brightness via acpi video driver */ 751 /* if we control brightness via acpi video driver */
747 if (priv->blightdev == NULL) { 752 if (priv->blightdev == NULL) {
748 read_ec_data(ideapad_handle, VPCCMD_R_BL, &now); 753 read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now);
749 return; 754 return;
750 } 755 }
751 756
@@ -755,19 +760,12 @@ static void ideapad_backlight_notify_brightness(struct ideapad_private *priv)
755/* 760/*
756 * module init/exit 761 * module init/exit
757 */ 762 */
758static const struct acpi_device_id ideapad_device_ids[] = { 763static void ideapad_sync_touchpad_state(struct ideapad_private *priv)
759 { "VPC2004", 0},
760 { "", 0},
761};
762MODULE_DEVICE_TABLE(acpi, ideapad_device_ids);
763
764static void ideapad_sync_touchpad_state(struct acpi_device *adevice)
765{ 764{
766 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
767 unsigned long value; 765 unsigned long value;
768 766
769 /* Without reading from EC touchpad LED doesn't switch state */ 767 /* Without reading from EC touchpad LED doesn't switch state */
770 if (!read_ec_data(adevice->handle, VPCCMD_R_TOUCHPAD, &value)) { 768 if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) {
771 /* Some IdeaPads don't really turn off touchpad - they only 769 /* Some IdeaPads don't really turn off touchpad - they only
772 * switch the LED state. We (de)activate KBC AUX port to turn 770 * switch the LED state. We (de)activate KBC AUX port to turn
773 * touchpad off and on. We send KEY_TOUCHPAD_OFF and 771 * touchpad off and on. We send KEY_TOUCHPAD_OFF and
@@ -779,26 +777,77 @@ static void ideapad_sync_touchpad_state(struct acpi_device *adevice)
779 } 777 }
780} 778}
781 779
782static int ideapad_acpi_add(struct acpi_device *adevice) 780static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data)
781{
782 struct ideapad_private *priv = data;
783 unsigned long vpc1, vpc2, vpc_bit;
784
785 if (read_ec_data(handle, VPCCMD_R_VPC1, &vpc1))
786 return;
787 if (read_ec_data(handle, VPCCMD_R_VPC2, &vpc2))
788 return;
789
790 vpc1 = (vpc2 << 8) | vpc1;
791 for (vpc_bit = 0; vpc_bit < 16; vpc_bit++) {
792 if (test_bit(vpc_bit, &vpc1)) {
793 switch (vpc_bit) {
794 case 9:
795 ideapad_sync_rfk_state(priv);
796 break;
797 case 13:
798 case 11:
799 case 7:
800 case 6:
801 ideapad_input_report(priv, vpc_bit);
802 break;
803 case 5:
804 ideapad_sync_touchpad_state(priv);
805 break;
806 case 4:
807 ideapad_backlight_notify_brightness(priv);
808 break;
809 case 3:
810 ideapad_input_novokey(priv);
811 break;
812 case 2:
813 ideapad_backlight_notify_power(priv);
814 break;
815 case 0:
816 ideapad_check_special_buttons(priv);
817 break;
818 default:
819 pr_info("Unknown event: %lu\n", vpc_bit);
820 }
821 }
822 }
823}
824
825static int ideapad_acpi_add(struct platform_device *pdev)
783{ 826{
784 int ret, i; 827 int ret, i;
785 int cfg; 828 int cfg;
786 struct ideapad_private *priv; 829 struct ideapad_private *priv;
830 struct acpi_device *adev;
831
832 ret = acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev);
833 if (ret)
834 return -ENODEV;
787 835
788 if (read_method_int(adevice->handle, "_CFG", &cfg)) 836 if (read_method_int(adev->handle, "_CFG", &cfg))
789 return -ENODEV; 837 return -ENODEV;
790 838
791 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 839 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
792 if (!priv) 840 if (!priv)
793 return -ENOMEM; 841 return -ENOMEM;
794 dev_set_drvdata(&adevice->dev, priv); 842
795 ideapad_priv = priv; 843 dev_set_drvdata(&pdev->dev, priv);
796 ideapad_handle = adevice->handle;
797 priv->cfg = cfg; 844 priv->cfg = cfg;
845 priv->adev = adev;
846 priv->platform_device = pdev;
798 847
799 ret = ideapad_platform_init(priv); 848 ret = ideapad_sysfs_init(priv);
800 if (ret) 849 if (ret)
801 goto platform_failed; 850 goto sysfs_failed;
802 851
803 ret = ideapad_debugfs_init(priv); 852 ret = ideapad_debugfs_init(priv);
804 if (ret) 853 if (ret)
@@ -810,117 +859,92 @@ static int ideapad_acpi_add(struct acpi_device *adevice)
810 859
811 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) { 860 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) {
812 if (test_bit(ideapad_rfk_data[i].cfgbit, &priv->cfg)) 861 if (test_bit(ideapad_rfk_data[i].cfgbit, &priv->cfg))
813 ideapad_register_rfkill(adevice, i); 862 ideapad_register_rfkill(priv, i);
814 else 863 else
815 priv->rfk[i] = NULL; 864 priv->rfk[i] = NULL;
816 } 865 }
817 ideapad_sync_rfk_state(priv); 866 ideapad_sync_rfk_state(priv);
818 ideapad_sync_touchpad_state(adevice); 867 ideapad_sync_touchpad_state(priv);
819 868
820 if (!acpi_video_backlight_support()) { 869 if (!acpi_video_backlight_support()) {
821 ret = ideapad_backlight_init(priv); 870 ret = ideapad_backlight_init(priv);
822 if (ret && ret != -ENODEV) 871 if (ret && ret != -ENODEV)
823 goto backlight_failed; 872 goto backlight_failed;
824 } 873 }
874 ret = acpi_install_notify_handler(adev->handle,
875 ACPI_DEVICE_NOTIFY, ideapad_acpi_notify, priv);
876 if (ret)
877 goto notification_failed;
825 878
826 return 0; 879 return 0;
827 880notification_failed:
881 ideapad_backlight_exit(priv);
828backlight_failed: 882backlight_failed:
829 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) 883 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++)
830 ideapad_unregister_rfkill(adevice, i); 884 ideapad_unregister_rfkill(priv, i);
831 ideapad_input_exit(priv); 885 ideapad_input_exit(priv);
832input_failed: 886input_failed:
833 ideapad_debugfs_exit(priv); 887 ideapad_debugfs_exit(priv);
834debugfs_failed: 888debugfs_failed:
835 ideapad_platform_exit(priv); 889 ideapad_sysfs_exit(priv);
836platform_failed: 890sysfs_failed:
837 kfree(priv); 891 kfree(priv);
838 return ret; 892 return ret;
839} 893}
840 894
841static int ideapad_acpi_remove(struct acpi_device *adevice) 895static int ideapad_acpi_remove(struct platform_device *pdev)
842{ 896{
843 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev); 897 struct ideapad_private *priv = dev_get_drvdata(&pdev->dev);
844 int i; 898 int i;
845 899
900 acpi_remove_notify_handler(priv->adev->handle,
901 ACPI_DEVICE_NOTIFY, ideapad_acpi_notify);
846 ideapad_backlight_exit(priv); 902 ideapad_backlight_exit(priv);
847 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) 903 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++)
848 ideapad_unregister_rfkill(adevice, i); 904 ideapad_unregister_rfkill(priv, i);
849 ideapad_input_exit(priv); 905 ideapad_input_exit(priv);
850 ideapad_debugfs_exit(priv); 906 ideapad_debugfs_exit(priv);
851 ideapad_platform_exit(priv); 907 ideapad_sysfs_exit(priv);
852 dev_set_drvdata(&adevice->dev, NULL); 908 dev_set_drvdata(&pdev->dev, NULL);
853 kfree(priv); 909 kfree(priv);
854 910
855 return 0; 911 return 0;
856} 912}
857 913
858static void ideapad_acpi_notify(struct acpi_device *adevice, u32 event) 914#ifdef CONFIG_PM_SLEEP
915static int ideapad_acpi_resume(struct device *device)
859{ 916{
860 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev); 917 struct ideapad_private *priv;
861 acpi_handle handle = adevice->handle;
862 unsigned long vpc1, vpc2, vpc_bit;
863
864 if (read_ec_data(handle, VPCCMD_R_VPC1, &vpc1))
865 return;
866 if (read_ec_data(handle, VPCCMD_R_VPC2, &vpc2))
867 return;
868 918
869 vpc1 = (vpc2 << 8) | vpc1; 919 if (!device)
870 for (vpc_bit = 0; vpc_bit < 16; vpc_bit++) { 920 return -EINVAL;
871 if (test_bit(vpc_bit, &vpc1)) { 921 priv = dev_get_drvdata(device);
872 switch (vpc_bit) {
873 case 9:
874 ideapad_sync_rfk_state(priv);
875 break;
876 case 13:
877 case 11:
878 case 7:
879 case 6:
880 ideapad_input_report(priv, vpc_bit);
881 break;
882 case 5:
883 ideapad_sync_touchpad_state(adevice);
884 break;
885 case 4:
886 ideapad_backlight_notify_brightness(priv);
887 break;
888 case 3:
889 ideapad_input_novokey(priv);
890 break;
891 case 2:
892 ideapad_backlight_notify_power(priv);
893 break;
894 case 0:
895 ideapad_check_special_buttons(priv);
896 break;
897 default:
898 pr_info("Unknown event: %lu\n", vpc_bit);
899 }
900 }
901 }
902}
903 922
904static int ideapad_acpi_resume(struct device *device) 923 ideapad_sync_rfk_state(priv);
905{ 924 ideapad_sync_touchpad_state(priv);
906 ideapad_sync_rfk_state(ideapad_priv);
907 ideapad_sync_touchpad_state(to_acpi_device(device));
908 return 0; 925 return 0;
909} 926}
910 927#endif
911static SIMPLE_DEV_PM_OPS(ideapad_pm, NULL, ideapad_acpi_resume); 928static SIMPLE_DEV_PM_OPS(ideapad_pm, NULL, ideapad_acpi_resume);
912 929
913static struct acpi_driver ideapad_acpi_driver = { 930static const struct acpi_device_id ideapad_device_ids[] = {
914 .name = "ideapad_acpi", 931 { "VPC2004", 0},
915 .class = "IdeaPad", 932 { "", 0},
916 .ids = ideapad_device_ids,
917 .ops.add = ideapad_acpi_add,
918 .ops.remove = ideapad_acpi_remove,
919 .ops.notify = ideapad_acpi_notify,
920 .drv.pm = &ideapad_pm,
921 .owner = THIS_MODULE,
922}; 933};
923module_acpi_driver(ideapad_acpi_driver); 934MODULE_DEVICE_TABLE(acpi, ideapad_device_ids);
935
936static struct platform_driver ideapad_acpi_driver = {
937 .probe = ideapad_acpi_add,
938 .remove = ideapad_acpi_remove,
939 .driver = {
940 .name = "ideapad_acpi",
941 .owner = THIS_MODULE,
942 .pm = &ideapad_pm,
943 .acpi_match_table = ACPI_PTR(ideapad_device_ids),
944 },
945};
946
947module_platform_driver(ideapad_acpi_driver);
924 948
925MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); 949MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
926MODULE_DESCRIPTION("IdeaPad ACPI Extras"); 950MODULE_DESCRIPTION("IdeaPad ACPI Extras");
diff --git a/drivers/platform/x86/intel-rst.c b/drivers/platform/x86/intel-rst.c
index 41b740cb28bc..a2083a9e5662 100644
--- a/drivers/platform/x86/intel-rst.c
+++ b/drivers/platform/x86/intel-rst.c
@@ -29,24 +29,16 @@ static ssize_t irst_show_wakeup_events(struct device *dev,
29 char *buf) 29 char *buf)
30{ 30{
31 struct acpi_device *acpi; 31 struct acpi_device *acpi;
32 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 32 unsigned long long value;
33 union acpi_object *result;
34 acpi_status status; 33 acpi_status status;
35 34
36 acpi = to_acpi_device(dev); 35 acpi = to_acpi_device(dev);
37 36
38 status = acpi_evaluate_object(acpi->handle, "GFFS", NULL, &output); 37 status = acpi_evaluate_integer(acpi->handle, "GFFS", NULL, &value);
39 if (!ACPI_SUCCESS(status)) 38 if (!ACPI_SUCCESS(status))
40 return -EINVAL; 39 return -EINVAL;
41 40
42 result = output.pointer; 41 return sprintf(buf, "%lld\n", value);
43
44 if (result->type != ACPI_TYPE_INTEGER) {
45 kfree(result);
46 return -EINVAL;
47 }
48
49 return sprintf(buf, "%lld\n", result->integer.value);
50} 42}
51 43
52static ssize_t irst_store_wakeup_events(struct device *dev, 44static ssize_t irst_store_wakeup_events(struct device *dev,
@@ -54,8 +46,6 @@ static ssize_t irst_store_wakeup_events(struct device *dev,
54 const char *buf, size_t count) 46 const char *buf, size_t count)
55{ 47{
56 struct acpi_device *acpi; 48 struct acpi_device *acpi;
57 struct acpi_object_list input;
58 union acpi_object param;
59 acpi_status status; 49 acpi_status status;
60 unsigned long value; 50 unsigned long value;
61 int error; 51 int error;
@@ -67,13 +57,7 @@ static ssize_t irst_store_wakeup_events(struct device *dev,
67 if (error) 57 if (error)
68 return error; 58 return error;
69 59
70 param.type = ACPI_TYPE_INTEGER; 60 status = acpi_execute_simple_method(acpi->handle, "SFFS", value);
71 param.integer.value = value;
72
73 input.count = 1;
74 input.pointer = &param;
75
76 status = acpi_evaluate_object(acpi->handle, "SFFS", &input, NULL);
77 61
78 if (!ACPI_SUCCESS(status)) 62 if (!ACPI_SUCCESS(status))
79 return -EINVAL; 63 return -EINVAL;
@@ -91,24 +75,16 @@ static ssize_t irst_show_wakeup_time(struct device *dev,
91 struct device_attribute *attr, char *buf) 75 struct device_attribute *attr, char *buf)
92{ 76{
93 struct acpi_device *acpi; 77 struct acpi_device *acpi;
94 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 78 unsigned long long value;
95 union acpi_object *result;
96 acpi_status status; 79 acpi_status status;
97 80
98 acpi = to_acpi_device(dev); 81 acpi = to_acpi_device(dev);
99 82
100 status = acpi_evaluate_object(acpi->handle, "GFTV", NULL, &output); 83 status = acpi_evaluate_integer(acpi->handle, "GFTV", NULL, &value);
101 if (!ACPI_SUCCESS(status)) 84 if (!ACPI_SUCCESS(status))
102 return -EINVAL; 85 return -EINVAL;
103 86
104 result = output.pointer; 87 return sprintf(buf, "%lld\n", value);
105
106 if (result->type != ACPI_TYPE_INTEGER) {
107 kfree(result);
108 return -EINVAL;
109 }
110
111 return sprintf(buf, "%lld\n", result->integer.value);
112} 88}
113 89
114static ssize_t irst_store_wakeup_time(struct device *dev, 90static ssize_t irst_store_wakeup_time(struct device *dev,
@@ -116,8 +92,6 @@ static ssize_t irst_store_wakeup_time(struct device *dev,
116 const char *buf, size_t count) 92 const char *buf, size_t count)
117{ 93{
118 struct acpi_device *acpi; 94 struct acpi_device *acpi;
119 struct acpi_object_list input;
120 union acpi_object param;
121 acpi_status status; 95 acpi_status status;
122 unsigned long value; 96 unsigned long value;
123 int error; 97 int error;
@@ -129,13 +103,7 @@ static ssize_t irst_store_wakeup_time(struct device *dev,
129 if (error) 103 if (error)
130 return error; 104 return error;
131 105
132 param.type = ACPI_TYPE_INTEGER; 106 status = acpi_execute_simple_method(acpi->handle, "SFTV", value);
133 param.integer.value = value;
134
135 input.count = 1;
136 input.pointer = &param;
137
138 status = acpi_evaluate_object(acpi->handle, "SFTV", &input, NULL);
139 107
140 if (!ACPI_SUCCESS(status)) 108 if (!ACPI_SUCCESS(status))
141 return -EINVAL; 109 return -EINVAL;
diff --git a/drivers/platform/x86/intel-smartconnect.c b/drivers/platform/x86/intel-smartconnect.c
index 52259dcabecb..1838400dc036 100644
--- a/drivers/platform/x86/intel-smartconnect.c
+++ b/drivers/platform/x86/intel-smartconnect.c
@@ -25,37 +25,18 @@ MODULE_LICENSE("GPL");
25 25
26static int smartconnect_acpi_init(struct acpi_device *acpi) 26static int smartconnect_acpi_init(struct acpi_device *acpi)
27{ 27{
28 struct acpi_object_list input; 28 unsigned long long value;
29 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
30 union acpi_object *result;
31 union acpi_object param;
32 acpi_status status; 29 acpi_status status;
33 30
34 status = acpi_evaluate_object(acpi->handle, "GAOS", NULL, &output); 31 status = acpi_evaluate_integer(acpi->handle, "GAOS", NULL, &value);
35 if (!ACPI_SUCCESS(status)) 32 if (!ACPI_SUCCESS(status))
36 return -EINVAL; 33 return -EINVAL;
37 34
38 result = output.pointer; 35 if (value & 0x1) {
39
40 if (result->type != ACPI_TYPE_INTEGER) {
41 kfree(result);
42 return -EINVAL;
43 }
44
45 if (result->integer.value & 0x1) {
46 param.type = ACPI_TYPE_INTEGER;
47 param.integer.value = 0;
48
49 input.count = 1;
50 input.pointer = &param;
51
52 dev_info(&acpi->dev, "Disabling Intel Smart Connect\n"); 36 dev_info(&acpi->dev, "Disabling Intel Smart Connect\n");
53 status = acpi_evaluate_object(acpi->handle, "SAOS", &input, 37 status = acpi_execute_simple_method(acpi->handle, "SAOS", 0);
54 NULL);
55 } 38 }
56 39
57 kfree(result);
58
59 return 0; 40 return 0;
60} 41}
61 42
diff --git a/drivers/platform/x86/intel_menlow.c b/drivers/platform/x86/intel_menlow.c
index d6cfc1558c2f..11244f8703c4 100644
--- a/drivers/platform/x86/intel_menlow.c
+++ b/drivers/platform/x86/intel_menlow.c
@@ -156,19 +156,15 @@ static struct thermal_cooling_device_ops memory_cooling_ops = {
156static int intel_menlow_memory_add(struct acpi_device *device) 156static int intel_menlow_memory_add(struct acpi_device *device)
157{ 157{
158 int result = -ENODEV; 158 int result = -ENODEV;
159 acpi_status status = AE_OK;
160 acpi_handle dummy;
161 struct thermal_cooling_device *cdev; 159 struct thermal_cooling_device *cdev;
162 160
163 if (!device) 161 if (!device)
164 return -EINVAL; 162 return -EINVAL;
165 163
166 status = acpi_get_handle(device->handle, MEMORY_GET_BANDWIDTH, &dummy); 164 if (!acpi_has_method(device->handle, MEMORY_GET_BANDWIDTH))
167 if (ACPI_FAILURE(status))
168 goto end; 165 goto end;
169 166
170 status = acpi_get_handle(device->handle, MEMORY_SET_BANDWIDTH, &dummy); 167 if (!acpi_has_method(device->handle, MEMORY_SET_BANDWIDTH))
171 if (ACPI_FAILURE(status))
172 goto end; 168 goto end;
173 169
174 cdev = thermal_cooling_device_register("Memory controller", device, 170 cdev = thermal_cooling_device_register("Memory controller", device,
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 13ec195f0ca6..47caab0ea7a1 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -1508,7 +1508,6 @@ static void sony_nc_function_resume(void)
1508static int sony_nc_resume(struct device *dev) 1508static int sony_nc_resume(struct device *dev)
1509{ 1509{
1510 struct sony_nc_value *item; 1510 struct sony_nc_value *item;
1511 acpi_handle handle;
1512 1511
1513 for (item = sony_nc_values; item->name; item++) { 1512 for (item = sony_nc_values; item->name; item++) {
1514 int ret; 1513 int ret;
@@ -1523,15 +1522,13 @@ static int sony_nc_resume(struct device *dev)
1523 } 1522 }
1524 } 1523 }
1525 1524
1526 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "ECON", 1525 if (acpi_has_method(sony_nc_acpi_handle, "ECON")) {
1527 &handle))) {
1528 int arg = 1; 1526 int arg = 1;
1529 if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL)) 1527 if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL))
1530 dprintk("ECON Method failed\n"); 1528 dprintk("ECON Method failed\n");
1531 } 1529 }
1532 1530
1533 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "SN00", 1531 if (acpi_has_method(sony_nc_acpi_handle, "SN00"))
1534 &handle)))
1535 sony_nc_function_resume(); 1532 sony_nc_function_resume();
1536 1533
1537 return 0; 1534 return 0;
@@ -2682,7 +2679,6 @@ static void sony_nc_backlight_ng_read_limits(int handle,
2682 2679
2683static void sony_nc_backlight_setup(void) 2680static void sony_nc_backlight_setup(void)
2684{ 2681{
2685 acpi_handle unused;
2686 int max_brightness = 0; 2682 int max_brightness = 0;
2687 const struct backlight_ops *ops = NULL; 2683 const struct backlight_ops *ops = NULL;
2688 struct backlight_properties props; 2684 struct backlight_properties props;
@@ -2717,8 +2713,7 @@ static void sony_nc_backlight_setup(void)
2717 sony_nc_backlight_ng_read_limits(0x14c, &sony_bl_props); 2713 sony_nc_backlight_ng_read_limits(0x14c, &sony_bl_props);
2718 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; 2714 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
2719 2715
2720 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", 2716 } else if (acpi_has_method(sony_nc_acpi_handle, "GBRT")) {
2721 &unused))) {
2722 ops = &sony_backlight_ops; 2717 ops = &sony_backlight_ops;
2723 max_brightness = SONY_MAX_BRIGHTNESS - 1; 2718 max_brightness = SONY_MAX_BRIGHTNESS - 1;
2724 2719
@@ -2750,7 +2745,6 @@ static int sony_nc_add(struct acpi_device *device)
2750{ 2745{
2751 acpi_status status; 2746 acpi_status status;
2752 int result = 0; 2747 int result = 0;
2753 acpi_handle handle;
2754 struct sony_nc_value *item; 2748 struct sony_nc_value *item;
2755 2749
2756 pr_info("%s v%s\n", SONY_NC_DRIVER_NAME, SONY_LAPTOP_DRIVER_VERSION); 2750 pr_info("%s v%s\n", SONY_NC_DRIVER_NAME, SONY_LAPTOP_DRIVER_VERSION);
@@ -2790,15 +2784,13 @@ static int sony_nc_add(struct acpi_device *device)
2790 goto outplatform; 2784 goto outplatform;
2791 } 2785 }
2792 2786
2793 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "ECON", 2787 if (acpi_has_method(sony_nc_acpi_handle, "ECON")) {
2794 &handle))) {
2795 int arg = 1; 2788 int arg = 1;
2796 if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL)) 2789 if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL))
2797 dprintk("ECON Method failed\n"); 2790 dprintk("ECON Method failed\n");
2798 } 2791 }
2799 2792
2800 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "SN00", 2793 if (acpi_has_method(sony_nc_acpi_handle, "SN00")) {
2801 &handle))) {
2802 dprintk("Doing SNC setup\n"); 2794 dprintk("Doing SNC setup\n");
2803 /* retrieve the available handles */ 2795 /* retrieve the available handles */
2804 result = sony_nc_handles_setup(sony_pf_device); 2796 result = sony_nc_handles_setup(sony_pf_device);
@@ -2821,9 +2813,8 @@ static int sony_nc_add(struct acpi_device *device)
2821 2813
2822 /* find the available acpiget as described in the DSDT */ 2814 /* find the available acpiget as described in the DSDT */
2823 for (; item->acpiget && *item->acpiget; ++item->acpiget) { 2815 for (; item->acpiget && *item->acpiget; ++item->acpiget) {
2824 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, 2816 if (acpi_has_method(sony_nc_acpi_handle,
2825 *item->acpiget, 2817 *item->acpiget)) {
2826 &handle))) {
2827 dprintk("Found %s getter: %s\n", 2818 dprintk("Found %s getter: %s\n",
2828 item->name, *item->acpiget); 2819 item->name, *item->acpiget);
2829 item->devattr.attr.mode |= S_IRUGO; 2820 item->devattr.attr.mode |= S_IRUGO;
@@ -2833,9 +2824,8 @@ static int sony_nc_add(struct acpi_device *device)
2833 2824
2834 /* find the available acpiset as described in the DSDT */ 2825 /* find the available acpiset as described in the DSDT */
2835 for (; item->acpiset && *item->acpiset; ++item->acpiset) { 2826 for (; item->acpiset && *item->acpiset; ++item->acpiset) {
2836 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, 2827 if (acpi_has_method(sony_nc_acpi_handle,
2837 *item->acpiset, 2828 *item->acpiset)) {
2838 &handle))) {
2839 dprintk("Found %s setter: %s\n", 2829 dprintk("Found %s setter: %s\n",
2840 item->name, *item->acpiset); 2830 item->name, *item->acpiset);
2841 item->devattr.attr.mode |= S_IWUSR; 2831 item->devattr.attr.mode |= S_IWUSR;
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 0b7efb269cf1..05e046aa5e31 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -701,6 +701,14 @@ static void __init drv_acpi_handle_init(const char *name,
701static acpi_status __init tpacpi_acpi_handle_locate_callback(acpi_handle handle, 701static acpi_status __init tpacpi_acpi_handle_locate_callback(acpi_handle handle,
702 u32 level, void *context, void **return_value) 702 u32 level, void *context, void **return_value)
703{ 703{
704 struct acpi_device *dev;
705 if (!strcmp(context, "video")) {
706 if (acpi_bus_get_device(handle, &dev))
707 return AE_OK;
708 if (strcmp(ACPI_VIDEO_HID, acpi_device_hid(dev)))
709 return AE_OK;
710 }
711
704 *(acpi_handle *)return_value = handle; 712 *(acpi_handle *)return_value = handle;
705 713
706 return AE_CTRL_TERMINATE; 714 return AE_CTRL_TERMINATE;
@@ -713,10 +721,10 @@ static void __init tpacpi_acpi_handle_locate(const char *name,
713 acpi_status status; 721 acpi_status status;
714 acpi_handle device_found; 722 acpi_handle device_found;
715 723
716 BUG_ON(!name || !hid || !handle); 724 BUG_ON(!name || !handle);
717 vdbg_printk(TPACPI_DBG_INIT, 725 vdbg_printk(TPACPI_DBG_INIT,
718 "trying to locate ACPI handle for %s, using HID %s\n", 726 "trying to locate ACPI handle for %s, using HID %s\n",
719 name, hid); 727 name, hid ? hid : "NULL");
720 728
721 memset(&device_found, 0, sizeof(device_found)); 729 memset(&device_found, 0, sizeof(device_found));
722 status = acpi_get_devices(hid, tpacpi_acpi_handle_locate_callback, 730 status = acpi_get_devices(hid, tpacpi_acpi_handle_locate_callback,
@@ -6091,19 +6099,28 @@ static int __init tpacpi_query_bcl_levels(acpi_handle handle)
6091{ 6099{
6092 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 6100 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
6093 union acpi_object *obj; 6101 union acpi_object *obj;
6102 struct acpi_device *device, *child;
6094 int rc; 6103 int rc;
6095 6104
6096 if (ACPI_SUCCESS(acpi_evaluate_object(handle, "_BCL", NULL, &buffer))) { 6105 if (acpi_bus_get_device(handle, &device))
6106 return 0;
6107
6108 rc = 0;
6109 list_for_each_entry(child, &device->children, node) {
6110 acpi_status status = acpi_evaluate_object(child->handle, "_BCL",
6111 NULL, &buffer);
6112 if (ACPI_FAILURE(status))
6113 continue;
6114
6097 obj = (union acpi_object *)buffer.pointer; 6115 obj = (union acpi_object *)buffer.pointer;
6098 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { 6116 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) {
6099 pr_err("Unknown _BCL data, please report this to %s\n", 6117 pr_err("Unknown _BCL data, please report this to %s\n",
6100 TPACPI_MAIL); 6118 TPACPI_MAIL);
6101 rc = 0; 6119 rc = 0;
6102 } else { 6120 } else {
6103 rc = obj->package.count; 6121 rc = obj->package.count;
6104 } 6122 }
6105 } else { 6123 break;
6106 return 0;
6107 } 6124 }
6108 6125
6109 kfree(buffer.pointer); 6126 kfree(buffer.pointer);
@@ -6119,7 +6136,7 @@ static unsigned int __init tpacpi_check_std_acpi_brightness_support(void)
6119 acpi_handle video_device; 6136 acpi_handle video_device;
6120 int bcl_levels = 0; 6137 int bcl_levels = 0;
6121 6138
6122 tpacpi_acpi_handle_locate("video", ACPI_VIDEO_HID, &video_device); 6139 tpacpi_acpi_handle_locate("video", NULL, &video_device);
6123 if (video_device) 6140 if (video_device)
6124 bcl_levels = tpacpi_query_bcl_levels(video_device); 6141 bcl_levels = tpacpi_query_bcl_levels(video_device);
6125 6142
diff --git a/drivers/platform/x86/topstar-laptop.c b/drivers/platform/x86/topstar-laptop.c
index 4ab618c63b45..67897c8740ba 100644
--- a/drivers/platform/x86/topstar-laptop.c
+++ b/drivers/platform/x86/topstar-laptop.c
@@ -80,13 +80,9 @@ static void acpi_topstar_notify(struct acpi_device *device, u32 event)
80static int acpi_topstar_fncx_switch(struct acpi_device *device, bool state) 80static int acpi_topstar_fncx_switch(struct acpi_device *device, bool state)
81{ 81{
82 acpi_status status; 82 acpi_status status;
83 union acpi_object fncx_params[1] = {
84 { .type = ACPI_TYPE_INTEGER }
85 };
86 struct acpi_object_list fncx_arg_list = { 1, &fncx_params[0] };
87 83
88 fncx_params[0].integer.value = state ? 0x86 : 0x87; 84 status = acpi_execute_simple_method(device->handle, "FNCX",
89 status = acpi_evaluate_object(device->handle, "FNCX", &fncx_arg_list, NULL); 85 state ? 0x86 : 0x87);
90 if (ACPI_FAILURE(status)) { 86 if (ACPI_FAILURE(status)) {
91 pr_err("Unable to switch FNCX notifications\n"); 87 pr_err("Unable to switch FNCX notifications\n");
92 return -ENODEV; 88 return -ENODEV;
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index eb3467ea6d86..0cfadb65f7c6 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -191,16 +191,9 @@ static __inline__ void _set_bit(u32 * word, u32 mask, int value)
191 191
192static int write_acpi_int(const char *methodName, int val) 192static int write_acpi_int(const char *methodName, int val)
193{ 193{
194 struct acpi_object_list params;
195 union acpi_object in_objs[1];
196 acpi_status status; 194 acpi_status status;
197 195
198 params.count = ARRAY_SIZE(in_objs); 196 status = acpi_execute_simple_method(NULL, (char *)methodName, val);
199 params.pointer = in_objs;
200 in_objs[0].type = ACPI_TYPE_INTEGER;
201 in_objs[0].integer.value = val;
202
203 status = acpi_evaluate_object(NULL, (char *)methodName, &params, NULL);
204 return (status == AE_OK) ? 0 : -EIO; 197 return (status == AE_OK) ? 0 : -EIO;
205} 198}
206 199
@@ -947,21 +940,17 @@ static void toshiba_acpi_hotkey_work(struct work_struct *work)
947 */ 940 */
948static int toshiba_acpi_query_hotkey(struct toshiba_acpi_dev *dev) 941static int toshiba_acpi_query_hotkey(struct toshiba_acpi_dev *dev)
949{ 942{
950 struct acpi_buffer buf; 943 unsigned long long value;
951 union acpi_object out_obj;
952 acpi_status status; 944 acpi_status status;
953 945
954 buf.pointer = &out_obj; 946 status = acpi_evaluate_integer(dev->acpi_dev->handle, "INFO",
955 buf.length = sizeof(out_obj); 947 NULL, &value);
956 948 if (ACPI_FAILURE(status)) {
957 status = acpi_evaluate_object(dev->acpi_dev->handle, "INFO",
958 NULL, &buf);
959 if (ACPI_FAILURE(status) || out_obj.type != ACPI_TYPE_INTEGER) {
960 pr_err("ACPI INFO method execution failed\n"); 949 pr_err("ACPI INFO method execution failed\n");
961 return -EIO; 950 return -EIO;
962 } 951 }
963 952
964 return out_obj.integer.value; 953 return value;
965} 954}
966 955
967static void toshiba_acpi_report_hotkey(struct toshiba_acpi_dev *dev, 956static void toshiba_acpi_report_hotkey(struct toshiba_acpi_dev *dev,
@@ -981,7 +970,7 @@ static void toshiba_acpi_report_hotkey(struct toshiba_acpi_dev *dev,
981static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) 970static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
982{ 971{
983 acpi_status status; 972 acpi_status status;
984 acpi_handle ec_handle, handle; 973 acpi_handle ec_handle;
985 int error; 974 int error;
986 u32 hci_result; 975 u32 hci_result;
987 976
@@ -1008,10 +997,7 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
1008 */ 997 */
1009 status = AE_ERROR; 998 status = AE_ERROR;
1010 ec_handle = ec_get_handle(); 999 ec_handle = ec_get_handle();
1011 if (ec_handle) 1000 if (ec_handle && acpi_has_method(ec_handle, "NTFY")) {
1012 status = acpi_get_handle(ec_handle, "NTFY", &handle);
1013
1014 if (ACPI_SUCCESS(status)) {
1015 INIT_WORK(&dev->hotkey_work, toshiba_acpi_hotkey_work); 1001 INIT_WORK(&dev->hotkey_work, toshiba_acpi_hotkey_work);
1016 1002
1017 error = i8042_install_filter(toshiba_acpi_i8042_filter); 1003 error = i8042_install_filter(toshiba_acpi_i8042_filter);
@@ -1027,10 +1013,9 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
1027 * Determine hotkey query interface. Prefer using the INFO 1013 * Determine hotkey query interface. Prefer using the INFO
1028 * method when it is available. 1014 * method when it is available.
1029 */ 1015 */
1030 status = acpi_get_handle(dev->acpi_dev->handle, "INFO", &handle); 1016 if (acpi_has_method(dev->acpi_dev->handle, "INFO"))
1031 if (ACPI_SUCCESS(status)) {
1032 dev->info_supported = 1; 1017 dev->info_supported = 1;
1033 } else { 1018 else {
1034 hci_write1(dev, HCI_SYSTEM_EVENT, 1, &hci_result); 1019 hci_write1(dev, HCI_SYSTEM_EVENT, 1, &hci_result);
1035 if (hci_result == HCI_SUCCESS) 1020 if (hci_result == HCI_SUCCESS)
1036 dev->system_event_supported = 1; 1021 dev->system_event_supported = 1;
@@ -1155,15 +1140,10 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
1155 1140
1156static const char *find_hci_method(acpi_handle handle) 1141static const char *find_hci_method(acpi_handle handle)
1157{ 1142{
1158 acpi_status status; 1143 if (acpi_has_method(handle, "GHCI"))
1159 acpi_handle hci_handle;
1160
1161 status = acpi_get_handle(handle, "GHCI", &hci_handle);
1162 if (ACPI_SUCCESS(status))
1163 return "GHCI"; 1144 return "GHCI";
1164 1145
1165 status = acpi_get_handle(handle, "SPFC", &hci_handle); 1146 if (acpi_has_method(handle, "SPFC"))
1166 if (ACPI_SUCCESS(status))
1167 return "SPFC"; 1147 return "SPFC";
1168 1148
1169 return NULL; 1149 return NULL;
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 601ea9512242..62e8c221d01e 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -252,8 +252,6 @@ static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable)
252{ 252{
253 struct guid_block *block = NULL; 253 struct guid_block *block = NULL;
254 char method[5]; 254 char method[5];
255 struct acpi_object_list input;
256 union acpi_object params[1];
257 acpi_status status; 255 acpi_status status;
258 acpi_handle handle; 256 acpi_handle handle;
259 257
@@ -263,13 +261,9 @@ static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable)
263 if (!block) 261 if (!block)
264 return AE_NOT_EXIST; 262 return AE_NOT_EXIST;
265 263
266 input.count = 1;
267 input.pointer = params;
268 params[0].type = ACPI_TYPE_INTEGER;
269 params[0].integer.value = enable;
270 264
271 snprintf(method, 5, "WE%02X", block->notify_id); 265 snprintf(method, 5, "WE%02X", block->notify_id);
272 status = acpi_evaluate_object(handle, method, &input, NULL); 266 status = acpi_execute_simple_method(handle, method, enable);
273 267
274 if (status != AE_OK && status != AE_NOT_FOUND) 268 if (status != AE_OK && status != AE_NOT_FOUND)
275 return status; 269 return status;
@@ -353,10 +347,10 @@ struct acpi_buffer *out)
353{ 347{
354 struct guid_block *block = NULL; 348 struct guid_block *block = NULL;
355 struct wmi_block *wblock = NULL; 349 struct wmi_block *wblock = NULL;
356 acpi_handle handle, wc_handle; 350 acpi_handle handle;
357 acpi_status status, wc_status = AE_ERROR; 351 acpi_status status, wc_status = AE_ERROR;
358 struct acpi_object_list input, wc_input; 352 struct acpi_object_list input;
359 union acpi_object wc_params[1], wq_params[1]; 353 union acpi_object wq_params[1];
360 char method[5]; 354 char method[5];
361 char wc_method[5] = "WC"; 355 char wc_method[5] = "WC";
362 356
@@ -386,11 +380,6 @@ struct acpi_buffer *out)
386 * enable collection. 380 * enable collection.
387 */ 381 */
388 if (block->flags & ACPI_WMI_EXPENSIVE) { 382 if (block->flags & ACPI_WMI_EXPENSIVE) {
389 wc_input.count = 1;
390 wc_input.pointer = wc_params;
391 wc_params[0].type = ACPI_TYPE_INTEGER;
392 wc_params[0].integer.value = 1;
393
394 strncat(wc_method, block->object_id, 2); 383 strncat(wc_method, block->object_id, 2);
395 384
396 /* 385 /*
@@ -398,10 +387,9 @@ struct acpi_buffer *out)
398 * expensive, but have no corresponding WCxx method. So we 387 * expensive, but have no corresponding WCxx method. So we
399 * should not fail if this happens. 388 * should not fail if this happens.
400 */ 389 */
401 wc_status = acpi_get_handle(handle, wc_method, &wc_handle); 390 if (acpi_has_method(handle, wc_method))
402 if (ACPI_SUCCESS(wc_status)) 391 wc_status = acpi_execute_simple_method(handle,
403 wc_status = acpi_evaluate_object(handle, wc_method, 392 wc_method, 1);
404 &wc_input, NULL);
405 } 393 }
406 394
407 strcpy(method, "WQ"); 395 strcpy(method, "WQ");
@@ -414,9 +402,7 @@ struct acpi_buffer *out)
414 * the WQxx method failed - we should disable collection anyway. 402 * the WQxx method failed - we should disable collection anyway.
415 */ 403 */
416 if ((block->flags & ACPI_WMI_EXPENSIVE) && ACPI_SUCCESS(wc_status)) { 404 if ((block->flags & ACPI_WMI_EXPENSIVE) && ACPI_SUCCESS(wc_status)) {
417 wc_params[0].integer.value = 0; 405 status = acpi_execute_simple_method(handle, wc_method, 0);
418 status = acpi_evaluate_object(handle,
419 wc_method, &wc_input, NULL);
420 } 406 }
421 407
422 return status; 408 return status;