From: Vicki Pfau <vi@endrift.com>
To: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
linux-input@vger.kernel.org
Cc: Vicki Pfau <vi@endrift.com>
Subject: [PATCH 4/7] HID: hid-steam: Make client_opened a counter
Date: Tue, 19 Dec 2023 19:38:34 -0800 [thread overview]
Message-ID: <20231220033837.2135194-4-vi@endrift.com> (raw)
In-Reply-To: <20231220033837.2135194-1-vi@endrift.com>
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 <vi@endrift.com>
---
drivers/hid/hid-steam.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
index 57cb58941c9f..667b5b09f931 100644
--- a/drivers/hid/hid-steam.c
+++ b/drivers/hid/hid-steam.c
@@ -125,7 +125,7 @@ struct steam_device {
spinlock_t lock;
struct hid_device *hdev, *client_hdev;
struct mutex report_mutex;
- bool client_opened;
+ unsigned long client_opened;
struct input_dev __rcu *input;
unsigned long quirks;
struct work_struct work_connect;
@@ -648,7 +648,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;
unsigned long flags;
/*
@@ -771,7 +771,7 @@ static int steam_client_ll_open(struct hid_device *hdev)
unsigned long flags;
spin_lock_irqsave(&steam->lock, flags);
- steam->client_opened = true;
+ steam->client_opened++;
spin_unlock_irqrestore(&steam->lock, flags);
steam_input_unregister(steam);
@@ -787,7 +787,7 @@ static void steam_client_ll_close(struct hid_device *hdev)
bool connected;
spin_lock_irqsave(&steam->lock, flags);
- steam->client_opened = false;
+ steam->client_opened--;
connected = steam->connected && !steam->client_opened;
spin_unlock_irqrestore(&steam->lock, flags);
@@ -959,7 +959,7 @@ static void steam_remove(struct hid_device *hdev)
cancel_work_sync(&steam->work_connect);
hid_destroy_device(steam->client_hdev);
steam->client_hdev = NULL;
- steam->client_opened = false;
+ steam->client_opened = 0;
if (steam->quirks & STEAM_QUIRK_WIRELESS) {
hid_info(hdev, "Steam wireless receiver disconnected");
}
--
2.42.0
next prev parent reply other threads:[~2023-12-20 3:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-20 3:36 [PATCH 0/7] HID: hid-steam: Upstream more SteamOS patches Vicki Pfau
2023-12-20 3:38 ` [PATCH 1/7] HID: hid-steam: Avoid overwriting smoothing parameter Vicki Pfau
2023-12-20 3:38 ` [PATCH 2/7] HID: hid-steam: Disable watchdog instead of using a heartbeat Vicki Pfau
2023-12-20 3:38 ` [PATCH 3/7] HID: hid-steam: Clean up locking Vicki Pfau
2023-12-20 3:38 ` Vicki Pfau [this message]
2023-12-20 3:38 ` [PATCH 5/7] HID: hid-steam: Update list of identifiers from SDL Vicki Pfau
2023-12-20 3:38 ` [PATCH 6/7] HID: hid-steam: Better handling of serial number length Vicki Pfau
2023-12-20 3:38 ` [PATCH 7/7] HID: hid-steam: Add gamepad-only mode switched to by holding options Vicki Pfau
2024-01-02 10:21 ` [PATCH 0/7] HID: hid-steam: Upstream more SteamOS patches Jiri Kosina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231220033837.2135194-4-vi@endrift.com \
--to=vi@endrift.com \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox