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