All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lee Jones" <lee@kernel.org>, linux-input@vger.kernel.org
Cc: dmitry.torokhov@gmail.com
Subject: Re: [STABLE v5.15-v5.10 2/6] HID: hid-steam: Make client_opened a counter
Date: Tue, 13 Oct 2026 09:38:25 +0000	[thread overview]
Message-ID: <sashiko-outbox-169361@kernel.org> (raw)
In-Reply-To: <20261013091215.529531-2-lee@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] hid: hid-steam: Redundant manual refcounting in open/close callbacks
--

commit 606f575d1b062004ef69d4378f3403ab1764d5a8
Author: Vicki Pfau <vi@endrift.com>

HID: hid-steam: Make client_opened a counter

This patch changes the client_opened flag from a boolean to a counter. The
intent is to track how many clients have opened the hidraw node so that
concurrent opens and closes do not prematurely re-enable lizard mode.

> diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
> index 379e7765a93e9..78104e1246e82 100644
> --- a/drivers/hid/hid-steam.c
> +++ b/drivers/hid/hid-steam.c
[ ... ]
> @@ -624,7 +624,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++;

[Severity: Low]
This isn't a bug, but is this manual refcounting redundant?

The commit message indicates this change is to handle multiple clients opening
the device at the same time. However, the HID core already natively refcounts
and serializes the low-level open and close callbacks.

Looking at hid_hw_open() in drivers/hid/hid-core.c:

	if (!hdev->ll_open_count++) {
		ret = hdev->ll_driver->open(hdev);
		...
	}

Since the core only calls the low-level open callback on the 0 to 1 transition
and the close callback on the 1 to 0 transition, concurrent opens are handled
before reaching steam_client_ll_open(). Does this mean the manual counter
behaves identically to the original boolean flag and won't actually track
multiple clients at this level?

>  	mutex_unlock(&steam->mutex);
>  
>  	steam_input_unregister(steam);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013091215.529531-1-lee@kernel.org?part=2

  reply	other threads:[~2026-10-13  9:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  9:12 [STABLE v5.15-v5.10 1/6] HID: hid-steam: Fix cleanup in probe() Lee Jones
2026-10-13  9:12 ` [STABLE v5.15-v5.10 2/6] HID: hid-steam: Make client_opened a counter Lee Jones
2026-10-13  9:38   ` sashiko-bot [this message]
2026-10-13  9:12 ` [STABLE v5.15-v5.10 3/6] HID: steam: Fully unregister controller when hidraw is opened Lee Jones
2026-10-13  9:50   ` sashiko-bot
2026-10-13  9:12 ` [STABLE v5.15-v5.10 4/6] HID: steam: Rearrange teardown sequence Lee Jones
2026-10-13  9:12 ` [STABLE v5.15-v5.10 5/6] HID: steam: Refactor registration Lee Jones
2026-10-13 10:21   ` sashiko-bot
2026-10-13  9:12 ` [STABLE v5.15-v5.10 6/6] HID: steam: Clean up locking Lee Jones
2026-10-13 10:36   ` sashiko-bot

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=sashiko-outbox-169361@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.