fujitsu-laptop: Use RFKILL support bitmask from firmware

Up until now, we polled the rfkill status for every incoming FUJ02E3 ACPI event.
It turns out that the firmware has a bitmask which indicates what rfkill-related
state it can report.
The rfkill_supported bitmask is now used to avoid polling for rfkill at all in
the notification handler if there is no support. Also, it is used in the platform
device callbacks. As before we register all callbacks and report "unknown" if the
firmware does not give us status updates for that particular bit.

This was fed through checkpatch.pl and tested on the S6420, S7020 and P8010
platforms.

Signed-off-by: Tony Vroon <tony@linx.net>
Tested-by: Stephen Gildea <stepheng+linux@gildea.com>
Acked-by: Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Signed-off-by: Len Brown <len.brown@intel.com>

authored by Tony Vroon and committed by Len Brown 4898c2b2 adfafefd

+18 -7
+18 -7
drivers/platform/x86/fujitsu-laptop.c
··· 166 166 struct platform_device *pf_device; 167 167 struct kfifo *fifo; 168 168 spinlock_t fifo_lock; 169 + int rfkill_supported; 169 170 int rfkill_state; 170 171 int logolamp_registered; 171 172 int kblamps_registered; ··· 527 526 show_lid_state(struct device *dev, 528 527 struct device_attribute *attr, char *buf) 529 528 { 530 - if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD) 529 + if (!(fujitsu_hotkey->rfkill_supported & 0x100)) 531 530 return sprintf(buf, "unknown\n"); 532 531 if (fujitsu_hotkey->rfkill_state & 0x100) 533 532 return sprintf(buf, "open\n"); ··· 539 538 show_dock_state(struct device *dev, 540 539 struct device_attribute *attr, char *buf) 541 540 { 542 - if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD) 541 + if (!(fujitsu_hotkey->rfkill_supported & 0x200)) 543 542 return sprintf(buf, "unknown\n"); 544 543 if (fujitsu_hotkey->rfkill_state & 0x200) 545 544 return sprintf(buf, "docked\n"); ··· 551 550 show_radios_state(struct device *dev, 552 551 struct device_attribute *attr, char *buf) 553 552 { 554 - if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD) 553 + if (!(fujitsu_hotkey->rfkill_supported & 0x20)) 555 554 return sprintf(buf, "unknown\n"); 556 555 if (fujitsu_hotkey->rfkill_state & 0x20) 557 556 return sprintf(buf, "on\n"); ··· 929 928 ; /* No action, result is discarded */ 930 929 vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i); 931 930 932 - fujitsu_hotkey->rfkill_state = 933 - call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); 931 + fujitsu_hotkey->rfkill_supported = 932 + call_fext_func(FUNC_RFKILL, 0x0, 0x0, 0x0); 933 + 934 + /* Make sure our bitmask of supported functions is cleared if the 935 + RFKILL function block is not implemented, like on the S7020. */ 936 + if (fujitsu_hotkey->rfkill_supported == UNSUPPORTED_CMD) 937 + fujitsu_hotkey->rfkill_supported = 0; 938 + 939 + if (fujitsu_hotkey->rfkill_supported) 940 + fujitsu_hotkey->rfkill_state = 941 + call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); 934 942 935 943 /* Suspect this is a keymap of the application panel, print it */ 936 944 printk(KERN_INFO "fujitsu-laptop: BTNI: [0x%x]\n", ··· 1015 1005 1016 1006 input = fujitsu_hotkey->input; 1017 1007 1018 - fujitsu_hotkey->rfkill_state = 1019 - call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); 1008 + if (fujitsu_hotkey->rfkill_supported) 1009 + fujitsu_hotkey->rfkill_state = 1010 + call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); 1020 1011 1021 1012 switch (event) { 1022 1013 case ACPI_FUJITSU_NOTIFY_CODE1: