Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Basavaraj Natikar" <Basavaraj.Natikar@amd.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH 3/3] Input: misc: Add AMD SFH tablet-mode switch driver
Date: Tue, 21 Jul 2026 17:54:28 +0000	[thread overview]
Message-ID: <20260721175429.32BF81F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260721174422.3109166-4-Basavaraj.Natikar@amd.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The initial hardware state of the tablet mode switch is redundantly queried and synchronized after `input_register_device()` exposes the device to userspace, creating a race condition.
- [Low] Violation of input subsystem naming convention for error variables.
--

--- Patch [3]: [PATCH 3/3] Input: misc: Add AMD SFH tablet-mode switch driver ---
commit e88c97b2482f6ed434b346336b9c6f9164d73473
Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>

Input: misc: Add AMD SFH tablet-mode switch driver

This commit introduces a new driver for AMD convertible laptops. It exposes
the SW_TABLET_MODE switch by polling the operating-mode sensor provided by
the AMD Sensor Fusion Hub.

> diff --git a/drivers/input/misc/amd_sfh_tabletmode.c b/drivers/input/misc/amd_sfh_tabletmode.c
> new file mode 100644
> index 0000000000000..f88edebbf35d5
> --- /dev/null
> +++ b/drivers/input/misc/amd_sfh_tabletmode.c

[ ... ]

> +static int sfh_tm_probe(struct auxiliary_device *auxdev,
> +			const struct auxiliary_device_id *id)
> +{
> +	struct amd_sfh_info info = {};
> +	struct device *dev = &auxdev->dev;
> +	struct input_dev *input;
> +	int rc;

[Severity: Low]
This isn't a bug, but does using 'rc' instead of 'error' or 'err' violate
the input subsystem maintainer preference? 

The input subsystem guidelines suggest using 'error' or 'err' for variables
that only hold negative error codes and 0 for success.

[ ... ]

> +	rc = input_setup_polling(input, sfh_tm_poll);
> +	if (rc)
> +		return rc;
> +	input_set_poll_interval(input, POLL_INTERVAL_MS);
> +
> +	rc = input_register_device(input);
> +	if (rc)
> +		return rc;
> +
> +	sfh_tm_poll(input);

[Severity: Medium]
Should sfh_tm_poll() be called before input_register_device()?

Calling it after registration exposes a race condition where userspace
components reacting to the device creation uevent might read the
SW_TABLET_MODE state before sfh_tm_poll() executes.

They will read the default uninitialized state (0), which may incorrectly
leave the keyboard and touchpad active if the device is actually folded into
tablet mode.

> +
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260721174422.3109166-1-Basavaraj.Natikar@amd.com?part=3

      reply	other threads:[~2026-07-21 17:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21 17:44 [PATCH 0/3] Add SW_TABLET_MODE support for AMD SFH convertibles Basavaraj Natikar
2026-07-21 17:44 ` [PATCH 1/3] HID: amd_sfh: Add accessor to read the operating-mode sensor Basavaraj Natikar
2026-07-21 18:04   ` sashiko-bot
2026-07-21 17:44 ` [PATCH 2/3] HID: amd_sfh: Register tablet-mode auxiliary device Basavaraj Natikar
2026-07-21 17:44 ` [PATCH 3/3] Input: misc: Add AMD SFH tablet-mode switch driver Basavaraj Natikar
2026-07-21 17:54   ` sashiko-bot [this message]

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=20260721175429.32BF81F00A3E@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=dmitry.torokhov@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox