Commit 4898c2b2 authored by Tony Vroon's avatar Tony Vroon Committed by Len Brown

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: default avatarTony Vroon <tony@linx.net>
Tested-by: default avatarStephen Gildea <stepheng+linux@gildea.com>
Acked-by: default avatarJonathan Woithe <jwoithe@physics.adelaide.edu.au>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent adfafefd
...@@ -166,6 +166,7 @@ struct fujitsu_hotkey_t { ...@@ -166,6 +166,7 @@ struct fujitsu_hotkey_t {
struct platform_device *pf_device; struct platform_device *pf_device;
struct kfifo *fifo; struct kfifo *fifo;
spinlock_t fifo_lock; spinlock_t fifo_lock;
int rfkill_supported;
int rfkill_state; int rfkill_state;
int logolamp_registered; int logolamp_registered;
int kblamps_registered; int kblamps_registered;
...@@ -526,7 +527,7 @@ static ssize_t ...@@ -526,7 +527,7 @@ static ssize_t
show_lid_state(struct device *dev, show_lid_state(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD) if (!(fujitsu_hotkey->rfkill_supported & 0x100))
return sprintf(buf, "unknown\n"); return sprintf(buf, "unknown\n");
if (fujitsu_hotkey->rfkill_state & 0x100) if (fujitsu_hotkey->rfkill_state & 0x100)
return sprintf(buf, "open\n"); return sprintf(buf, "open\n");
...@@ -538,7 +539,7 @@ static ssize_t ...@@ -538,7 +539,7 @@ static ssize_t
show_dock_state(struct device *dev, show_dock_state(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD) if (!(fujitsu_hotkey->rfkill_supported & 0x200))
return sprintf(buf, "unknown\n"); return sprintf(buf, "unknown\n");
if (fujitsu_hotkey->rfkill_state & 0x200) if (fujitsu_hotkey->rfkill_state & 0x200)
return sprintf(buf, "docked\n"); return sprintf(buf, "docked\n");
...@@ -550,7 +551,7 @@ static ssize_t ...@@ -550,7 +551,7 @@ static ssize_t
show_radios_state(struct device *dev, show_radios_state(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD) if (!(fujitsu_hotkey->rfkill_supported & 0x20))
return sprintf(buf, "unknown\n"); return sprintf(buf, "unknown\n");
if (fujitsu_hotkey->rfkill_state & 0x20) if (fujitsu_hotkey->rfkill_state & 0x20)
return sprintf(buf, "on\n"); return sprintf(buf, "on\n");
...@@ -928,6 +929,15 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -928,6 +929,15 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
; /* No action, result is discarded */ ; /* No action, result is discarded */
vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i); vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i);
fujitsu_hotkey->rfkill_supported =
call_fext_func(FUNC_RFKILL, 0x0, 0x0, 0x0);
/* Make sure our bitmask of supported functions is cleared if the
RFKILL function block is not implemented, like on the S7020. */
if (fujitsu_hotkey->rfkill_supported == UNSUPPORTED_CMD)
fujitsu_hotkey->rfkill_supported = 0;
if (fujitsu_hotkey->rfkill_supported)
fujitsu_hotkey->rfkill_state = fujitsu_hotkey->rfkill_state =
call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0);
...@@ -1005,6 +1015,7 @@ static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event, ...@@ -1005,6 +1015,7 @@ static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event,
input = fujitsu_hotkey->input; input = fujitsu_hotkey->input;
if (fujitsu_hotkey->rfkill_supported)
fujitsu_hotkey->rfkill_state = fujitsu_hotkey->rfkill_state =
call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment