Commit de15b94f authored by Darren Hart (VMware)'s avatar Darren Hart (VMware)

platform/x86: fujitsu-laptop: Simplify soft key handling

The hardcoded BIT(X) used in the soft key handling can be confusing and
prone to errors.

Instead, use the status FLAG_* defines for the sparse keymap index.
Rather than check for each known bit, use a bitmask to filter for all
known soft keys, and use the for_each_set_bit iterator.

Cc: Jan-Marek Glogowski <glogow@fbihome.de>
Cc: Michał Kępień <kernel@kempniu.pl>
Reviewed-by: default avatarJonathan Woithe <jwoithe@just42.net>
Signed-off-by: default avatarDarren Hart (VMware) <dvhart@infradead.org>
parent 60cc43fc
...@@ -91,6 +91,9 @@ ...@@ -91,6 +91,9 @@
#define FLAG_RFKILL BIT(5) #define FLAG_RFKILL BIT(5)
#define FLAG_LID BIT(8) #define FLAG_LID BIT(8)
#define FLAG_DOCK BIT(9) #define FLAG_DOCK BIT(9)
#define FLAG_TOUCHPAD_TOGGLE BIT(26)
#define FLAG_MICMUTE BIT(29)
#define FLAG_SOFTKEYS (FLAG_RFKILL | FLAG_TOUCHPAD_TOGGLE | FLAG_MICMUTE)
/* FUNC interface - LED control */ /* FUNC interface - LED control */
#define FUNC_LED_OFF BIT(0) #define FUNC_LED_OFF BIT(0)
...@@ -461,9 +464,10 @@ static const struct key_entry keymap_default[] = { ...@@ -461,9 +464,10 @@ static const struct key_entry keymap_default[] = {
{ KE_KEY, KEY3_CODE, { KEY_PROG3 } }, { KE_KEY, KEY3_CODE, { KEY_PROG3 } },
{ KE_KEY, KEY4_CODE, { KEY_PROG4 } }, { KE_KEY, KEY4_CODE, { KEY_PROG4 } },
{ KE_KEY, KEY5_CODE, { KEY_RFKILL } }, { KE_KEY, KEY5_CODE, { KEY_RFKILL } },
{ KE_KEY, BIT(5), { KEY_RFKILL } }, /* Soft keys read from status flags */
{ KE_KEY, BIT(26), { KEY_TOUCHPAD_TOGGLE } }, { KE_KEY, FLAG_RFKILL, { KEY_RFKILL } },
{ KE_KEY, BIT(29), { KEY_MICMUTE } }, { KE_KEY, FLAG_TOUCHPAD_TOGGLE, { KEY_TOUCHPAD_TOGGLE } },
{ KE_KEY, FLAG_MICMUTE, { KEY_MICMUTE } },
{ KE_END, 0 } { KE_END, 0 }
}; };
...@@ -903,7 +907,8 @@ static void acpi_fujitsu_laptop_release(struct acpi_device *device) ...@@ -903,7 +907,8 @@ static void acpi_fujitsu_laptop_release(struct acpi_device *device)
static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event) static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event)
{ {
struct fujitsu_laptop *priv = acpi_driver_data(device); struct fujitsu_laptop *priv = acpi_driver_data(device);
int scancode, i = 0, ret; unsigned long flags;
int scancode, i = 0;
unsigned int irb; unsigned int irb;
if (event != ACPI_FUJITSU_NOTIFY_CODE) { if (event != ACPI_FUJITSU_NOTIFY_CODE) {
...@@ -930,21 +935,17 @@ static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event) ...@@ -930,21 +935,17 @@ static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event)
"Unknown GIRB result [%x]\n", irb); "Unknown GIRB result [%x]\n", irb);
} }
/* On some models (first seen on the Skylake-based Lifebook /*
* E736/E746/E756), the touchpad toggle hotkey (Fn+F4) is * First seen on the Skylake-based Lifebook E736/E746/E756), the
* handled in software; its state is queried using FUNC_FLAGS * touchpad toggle hotkey (Fn+F4) is handled in software. Other models
* have since added additional "soft keys". These are reported in the
* status flags queried using FUNC_FLAGS.
*/ */
if (priv->flags_supported & (BIT(5) | BIT(26) | BIT(29))) { if (priv->flags_supported & (FLAG_SOFTKEYS)) {
ret = call_fext_func(device, FUNC_FLAGS, 0x1, 0x0, 0x0); flags = call_fext_func(device, FUNC_FLAGS, 0x1, 0x0, 0x0);
if (ret & BIT(5)) flags &= (FLAG_SOFTKEYS);
sparse_keymap_report_event(priv->input, for_each_set_bit(i, &flags, BITS_PER_LONG)
BIT(5), 1, true); sparse_keymap_report_event(priv->input, BIT(i), 1, true);
if (ret & BIT(26))
sparse_keymap_report_event(priv->input,
BIT(26), 1, true);
if (ret & BIT(29))
sparse_keymap_report_event(priv->input,
BIT(29), 1, true);
} }
} }
......
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