summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicki Pfau <vi@endrift.com>2025-02-05 06:55:28 +0300
committerJiri Kosina <jkosina@suse.com>2025-02-07 16:28:12 +0300
commit41ab65301d0319df771bce29ee6c07fc112cebd9 (patch)
tree3fc7f3e7e2fc0e5d37d88e48c2cd7b4b3b501ddc
parent27c02784773a69fd896e42f3cec73be8c5c83c1f (diff)
downloadlinux-41ab65301d0319df771bce29ee6c07fc112cebd9.tar.xz
HID: hid-steam: Mutex cleanup in steam_set_lizard_mode()
Both branches of this if/else start with mutex_lock and end with mutex_unlock. This hoists the mutex lock/unlock outside of the if statement for simplicity. Signed-off-by: Vicki Pfau <vi@endrift.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
-rw-r--r--drivers/hid/hid-steam.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
index af38fc8eb34f..98ca1fea6330 100644
--- a/drivers/hid/hid-steam.c
+++ b/drivers/hid/hid-steam.c
@@ -558,15 +558,13 @@ static void steam_set_lizard_mode(struct steam_device *steam, bool enable)
if (steam->gamepad_mode)
enable = false;
+ mutex_lock(&steam->report_mutex);
if (enable) {
- mutex_lock(&steam->report_mutex);
/* enable esc, enter, cursors */
steam_send_report_byte(steam, ID_SET_DEFAULT_DIGITAL_MAPPINGS);
/* reset settings */
steam_send_report_byte(steam, ID_LOAD_DEFAULT_SETTINGS);
- mutex_unlock(&steam->report_mutex);
} else {
- mutex_lock(&steam->report_mutex);
/* disable esc, enter, cursor */
steam_send_report_byte(steam, ID_CLEAR_DIGITAL_MAPPINGS);
@@ -578,15 +576,14 @@ static void steam_set_lizard_mode(struct steam_device *steam, bool enable)
SETTING_RIGHT_TRACKPAD_CLICK_PRESSURE, 0xFFFF, /* disable haptic click */
SETTING_STEAM_WATCHDOG_ENABLE, 0, /* disable watchdog that tests if Steam is active */
0);
- mutex_unlock(&steam->report_mutex);
} else {
steam_write_settings(steam,
SETTING_LEFT_TRACKPAD_MODE, TRACKPAD_NONE, /* disable mouse */
SETTING_RIGHT_TRACKPAD_MODE, TRACKPAD_NONE, /* disable mouse */
0);
- mutex_unlock(&steam->report_mutex);
}
}
+ mutex_unlock(&steam->report_mutex);
}
static int steam_input_open(struct input_dev *dev)