Skip to content

Commit 555b818

Browse files
endriftJiri Kosina
authored andcommitted
HID: hid-steam: Make client_opened a counter
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 <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 691ead1 commit 555b818

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/hid/hid-steam.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct steam_device {
125125
spinlock_t lock;
126126
struct hid_device *hdev, *client_hdev;
127127
struct mutex report_mutex;
128-
bool client_opened;
128+
unsigned long client_opened;
129129
struct input_dev __rcu *input;
130130
unsigned long quirks;
131131
struct work_struct work_connect;
@@ -648,7 +648,7 @@ static void steam_battery_unregister(struct steam_device *steam)
648648
static int steam_register(struct steam_device *steam)
649649
{
650650
int ret;
651-
bool client_opened;
651+
unsigned long client_opened;
652652
unsigned long flags;
653653

654654
/*
@@ -771,7 +771,7 @@ static int steam_client_ll_open(struct hid_device *hdev)
771771
unsigned long flags;
772772

773773
spin_lock_irqsave(&steam->lock, flags);
774-
steam->client_opened = true;
774+
steam->client_opened++;
775775
spin_unlock_irqrestore(&steam->lock, flags);
776776

777777
steam_input_unregister(steam);
@@ -787,7 +787,7 @@ static void steam_client_ll_close(struct hid_device *hdev)
787787
bool connected;
788788

789789
spin_lock_irqsave(&steam->lock, flags);
790-
steam->client_opened = false;
790+
steam->client_opened--;
791791
connected = steam->connected && !steam->client_opened;
792792
spin_unlock_irqrestore(&steam->lock, flags);
793793

@@ -959,7 +959,7 @@ static void steam_remove(struct hid_device *hdev)
959959
cancel_work_sync(&steam->work_connect);
960960
hid_destroy_device(steam->client_hdev);
961961
steam->client_hdev = NULL;
962-
steam->client_opened = false;
962+
steam->client_opened = 0;
963963
if (steam->quirks & STEAM_QUIRK_WIRELESS) {
964964
hid_info(hdev, "Steam wireless receiver disconnected");
965965
}

0 commit comments

Comments
 (0)