5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vicki Pfau [ Upstream commit 555b818adb97eca70210a49ba3f1d27882dde092 ] The client_opened variable was used to track if the hidraw was opened by any clients to silence keyboard/mouse events while opened. However, there was no counting of how many clients were opened, so opening two at the same time and then closing one would fool the driver into thinking it had no remaining opened clients. Signed-off-by: Vicki Pfau Signed-off-by: Jiri Kosina [Lee: Adapt steam_client_ll_open() and steam_client_ll_close() as 691ead124a0c and e1147961b214 are not present] Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/hid/hid-steam.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c index 8832f7987006c..159b55dff799f 100644 --- a/drivers/hid/hid-steam.c +++ b/drivers/hid/hid-steam.c @@ -114,7 +114,7 @@ struct steam_device { spinlock_t lock; struct hid_device *hdev, *client_hdev; struct mutex mutex; - bool client_opened; + unsigned long client_opened; struct input_dev __rcu *input; unsigned long quirks; struct work_struct work_connect; @@ -509,7 +509,7 @@ static void steam_battery_unregister(struct steam_device *steam) static int steam_register(struct steam_device *steam) { int ret; - bool client_opened; + unsigned long client_opened; /* * This function can be called several times in a row with the @@ -634,7 +634,7 @@ static int steam_client_ll_open(struct hid_device *hdev) struct steam_device *steam = hdev->driver_data; mutex_lock(&steam->mutex); - steam->client_opened = true; + steam->client_opened++; mutex_unlock(&steam->mutex); steam_input_unregister(steam); @@ -654,12 +654,12 @@ static void steam_client_ll_close(struct hid_device *hdev) spin_unlock_irqrestore(&steam->lock, flags); mutex_lock(&steam->mutex); - steam->client_opened = false; - if (connected) + steam->client_opened--; + if (connected && !steam->client_opened) steam_set_lizard_mode(steam, lizard_mode); mutex_unlock(&steam->mutex); - if (connected) + if (connected && !steam->client_opened) steam_input_register(steam); } @@ -824,7 +824,7 @@ static void steam_remove(struct hid_device *hdev) } hid_destroy_device(steam->client_hdev); - steam->client_opened = false; + steam->client_opened = 0; cancel_work_sync(&steam->work_connect); if (steam->quirks & STEAM_QUIRK_WIRELESS) { hid_info(hdev, "Steam wireless receiver disconnected"); -- 2.53.0