Skip to content

Commit 41ab653

Browse files
endriftJiri Kosina
authored andcommitted
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>
1 parent 27c0278 commit 41ab653

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/hid/hid-steam.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,13 @@ static void steam_set_lizard_mode(struct steam_device *steam, bool enable)
558558
if (steam->gamepad_mode)
559559
enable = false;
560560

561+
mutex_lock(&steam->report_mutex);
561562
if (enable) {
562-
mutex_lock(&steam->report_mutex);
563563
/* enable esc, enter, cursors */
564564
steam_send_report_byte(steam, ID_SET_DEFAULT_DIGITAL_MAPPINGS);
565565
/* reset settings */
566566
steam_send_report_byte(steam, ID_LOAD_DEFAULT_SETTINGS);
567-
mutex_unlock(&steam->report_mutex);
568567
} else {
569-
mutex_lock(&steam->report_mutex);
570568
/* disable esc, enter, cursor */
571569
steam_send_report_byte(steam, ID_CLEAR_DIGITAL_MAPPINGS);
572570

@@ -578,15 +576,14 @@ static void steam_set_lizard_mode(struct steam_device *steam, bool enable)
578576
SETTING_RIGHT_TRACKPAD_CLICK_PRESSURE, 0xFFFF, /* disable haptic click */
579577
SETTING_STEAM_WATCHDOG_ENABLE, 0, /* disable watchdog that tests if Steam is active */
580578
0);
581-
mutex_unlock(&steam->report_mutex);
582579
} else {
583580
steam_write_settings(steam,
584581
SETTING_LEFT_TRACKPAD_MODE, TRACKPAD_NONE, /* disable mouse */
585582
SETTING_RIGHT_TRACKPAD_MODE, TRACKPAD_NONE, /* disable mouse */
586583
0);
587-
mutex_unlock(&steam->report_mutex);
588584
}
589585
}
586+
mutex_unlock(&steam->report_mutex);
590587
}
591588

592589
static int steam_input_open(struct input_dev *dev)

0 commit comments

Comments
 (0)