Commit 33dc2efd authored by Hans de Goede's avatar Hans de Goede

platform/x86: thinkpad_acpi: Make tpacpi_driver_event() return if it handled the event

tpacpi_driver_event() already only responds to hkey events which it knows
about. Make it return a bool and return true when it has handled the event.

This avoids the need to list TP_HKEY_EV_foo values to which it responds
both in its caller and in the function itself.

Instead callers can now call it unconditionally and check the return value.
Tested-by: default avatarMark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarMark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20240424122834.19801-8-hdegoede@redhat.com
parent 9e5d6b98
...@@ -1918,7 +1918,7 @@ static u32 hotkey_acpi_mask; /* events enabled in firmware */ ...@@ -1918,7 +1918,7 @@ static u32 hotkey_acpi_mask; /* events enabled in firmware */
static u16 *hotkey_keycode_map; static u16 *hotkey_keycode_map;
static void tpacpi_driver_event(const unsigned int hkey_event); static bool tpacpi_driver_event(const unsigned int hkey_event);
static void hotkey_driver_event(const unsigned int scancode); static void hotkey_driver_event(const unsigned int scancode);
static void hotkey_poll_setup(const bool may_warn); static void hotkey_poll_setup(const bool may_warn);
...@@ -3726,13 +3726,8 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(const u32 hkey) ...@@ -3726,13 +3726,8 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(const u32 hkey)
static bool hotkey_notify_extended_hotkey(const u32 hkey) static bool hotkey_notify_extended_hotkey(const u32 hkey)
{ {
switch (hkey) { if (tpacpi_driver_event(hkey))
case TP_HKEY_EV_PRIVACYGUARD_TOGGLE:
case TP_HKEY_EV_AMT_TOGGLE:
case TP_HKEY_EV_PROFILE_TOGGLE:
tpacpi_driver_event(hkey);
return true; return true;
}
if (hkey >= TP_HKEY_EV_EXTENDED_KEY_START && if (hkey >= TP_HKEY_EV_EXTENDED_KEY_START &&
hkey <= TP_HKEY_EV_EXTENDED_KEY_END) { hkey <= TP_HKEY_EV_EXTENDED_KEY_END) {
...@@ -11081,24 +11076,28 @@ static struct platform_driver tpacpi_hwmon_pdriver = { ...@@ -11081,24 +11076,28 @@ static struct platform_driver tpacpi_hwmon_pdriver = {
* HKEY event callout for other subdrivers go here * HKEY event callout for other subdrivers go here
* (yes, it is ugly, but it is quick, safe, and gets the job done * (yes, it is ugly, but it is quick, safe, and gets the job done
*/ */
static void tpacpi_driver_event(const unsigned int hkey_event) static bool tpacpi_driver_event(const unsigned int hkey_event)
{ {
if (ibm_backlight_device) {
switch (hkey_event) { switch (hkey_event) {
case TP_HKEY_EV_BRGHT_UP: case TP_HKEY_EV_BRGHT_UP:
case TP_HKEY_EV_BRGHT_DOWN: case TP_HKEY_EV_BRGHT_DOWN:
if (ibm_backlight_device)
tpacpi_brightness_notify_change(); tpacpi_brightness_notify_change();
} /*
} * Key press events are suppressed by default hotkey_user_mask
if (alsa_card) { * and should still be reported if explicitly requested.
switch (hkey_event) { */
return false;
case TP_HKEY_EV_VOL_UP: case TP_HKEY_EV_VOL_UP:
case TP_HKEY_EV_VOL_DOWN: case TP_HKEY_EV_VOL_DOWN:
case TP_HKEY_EV_VOL_MUTE: case TP_HKEY_EV_VOL_MUTE:
if (alsa_card)
volume_alsa_notify_change(); volume_alsa_notify_change();
}
} /* Key events are suppressed by default hotkey_user_mask */
if (tp_features.kbdlight && hkey_event == TP_HKEY_EV_KBD_LIGHT) { return false;
case TP_HKEY_EV_KBD_LIGHT:
if (tp_features.kbdlight) {
enum led_brightness brightness; enum led_brightness brightness;
mutex_lock(&kbdlight_mutex); mutex_lock(&kbdlight_mutex);
...@@ -11116,15 +11115,17 @@ static void tpacpi_driver_event(const unsigned int hkey_event) ...@@ -11116,15 +11115,17 @@ static void tpacpi_driver_event(const unsigned int hkey_event)
mutex_unlock(&kbdlight_mutex); mutex_unlock(&kbdlight_mutex);
} }
/* Key events are suppressed by default hotkey_user_mask */
if (hkey_event == TP_HKEY_EV_THM_CSM_COMPLETED) { return false;
case TP_HKEY_EV_THM_CSM_COMPLETED:
lapsensor_refresh(); lapsensor_refresh();
/* If we are already accessing DYTC then skip dytc update */ /* If we are already accessing DYTC then skip dytc update */
if (!atomic_add_unless(&dytc_ignore_event, -1, 0)) if (!atomic_add_unless(&dytc_ignore_event, -1, 0))
dytc_profile_refresh(); dytc_profile_refresh();
}
if (lcdshadow_dev && hkey_event == TP_HKEY_EV_PRIVACYGUARD_TOGGLE) { return true;
case TP_HKEY_EV_PRIVACYGUARD_TOGGLE:
if (lcdshadow_dev) {
enum drm_privacy_screen_status old_hw_state; enum drm_privacy_screen_status old_hw_state;
bool changed; bool changed;
...@@ -11137,16 +11138,22 @@ static void tpacpi_driver_event(const unsigned int hkey_event) ...@@ -11137,16 +11138,22 @@ static void tpacpi_driver_event(const unsigned int hkey_event)
if (changed) if (changed)
drm_privacy_screen_call_notifier_chain(lcdshadow_dev); drm_privacy_screen_call_notifier_chain(lcdshadow_dev);
} }
if (hkey_event == TP_HKEY_EV_AMT_TOGGLE) { return true;
case TP_HKEY_EV_AMT_TOGGLE:
/* If we're enabling AMT we need to force balanced mode */ /* If we're enabling AMT we need to force balanced mode */
if (!dytc_amt_active) if (!dytc_amt_active)
/* This will also set AMT mode enabled */ /* This will also set AMT mode enabled */
dytc_profile_set(NULL, PLATFORM_PROFILE_BALANCED); dytc_profile_set(NULL, PLATFORM_PROFILE_BALANCED);
else else
dytc_control_amt(!dytc_amt_active); dytc_control_amt(!dytc_amt_active);
}
if (hkey_event == TP_HKEY_EV_PROFILE_TOGGLE) return true;
case TP_HKEY_EV_PROFILE_TOGGLE:
platform_profile_cycle(); platform_profile_cycle();
return true;
}
return false;
} }
static void hotkey_driver_event(const unsigned int scancode) static void hotkey_driver_event(const unsigned int scancode)
......
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