Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Uddhav Swami" <uddhavswami@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2] HID: add driver for Gigabyte Aero vendor-specific brightness keys
Date: Wed, 15 Jul 2026 04:27:59 +0000	[thread overview]
Message-ID: <20260715042759.DF8C71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260715041556.112673-1-uddhavswami@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Unconditional capability mapping forces the registration of all hid_inputs and unpredictably overwrites drvdata->input.
- [Low] Uses 'ret' instead of 'error' or 'err' for error variable.
--

--- Patch [1]: [PATCH v2] HID: add driver for Gigabyte Aero vendor-specific brightness keys ---
commit a88dff22dbe03f72cc6b7e002b5c019c9cd1010f
Author: Uddhav Swami <uddhavswami@gmail.com>

HID: add driver for Gigabyte Aero vendor-specific brightness keys

This patch intercepts vendor-defined HID reports for brightness keys on
Gigabyte Aero laptops and maps them to standard KEY_BRIGHTNESSUP and
KEY_BRIGHTNESSDOWN input events.

> diff --git a/drivers/hid/hid-gigabyte.c b/drivers/hid/hid-gigabyte.c
> new file mode 100644
> index 0000000000000..3f0c9a1b6bc1d
> --- /dev/null
> +++ b/drivers/hid/hid-gigabyte.c

[ ... ]

> +static int gigabyte_aero_input_configured(struct hid_device *hdev,
> +					  struct hid_input *hi)
> +{
> +	struct gigabyte_drvdata *drvdata = hid_get_drvdata(hdev);
> +	struct input_dev *input = hi->input;
> +
> +	input_set_capability(input, EV_KEY, KEY_BRIGHTNESSUP);
> +	input_set_capability(input, EV_KEY, KEY_BRIGHTNESSDOWN);
> +
> +	drvdata->input = input;

[Severity: Medium]
Does this code accidentally force the registration of all hid_inputs?

Since capabilities are applied unconditionally to every hid_input application
exposed by the device, it appears this defeats the HID core's
hidinput_has_been_populated() check. This could result in dummy input devices
being registered for collections that have no mapped usages and would
otherwise be cleaned up.

Also, because drvdata->input is unconditionally overwritten on every callback
during device probe, will brightness events be unpredictably routed to
whichever hid_input happened to be parsed last by the HID core?

> +
> +	return 0;
> +}
> +
> +static int gigabyte_aero_probe(struct hid_device *hdev,
> +			       const struct hid_device_id *id)
> +{
> +	struct gigabyte_drvdata *drvdata;
> +	int ret;

[Severity: Low]
This isn't a bug, but could we use a different variable name here?

The input subsystem maintainer preferences suggest using 'error' or 'err' for
variables that hold only negative error codes and 0 for success, rather than
'ret'.

> +
> +	drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL);
> +	if (!drvdata)
> +		return -ENOMEM;

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260715041556.112673-1-uddhavswami@gmail.com?part=1

  reply	other threads:[~2026-07-15  4:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15  0:44 [PATCH] HID: add driver for Gigabyte Aero vendor-specific brightness keys Uddhav Swami
2026-07-15  1:08 ` sashiko-bot
2026-07-15  4:15 ` [PATCH v2] " Uddhav Swami
2026-07-15  4:27   ` sashiko-bot [this message]
2026-07-15  5:59 ` [PATCH v3] " Uddhav Swami

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=20260715042759.DF8C71F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=uddhavswami@gmail.com \
    /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