Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Denis Benato" <denis.benato@linux.dev>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v13 16/18] HID: asus: document ROG Ally sysfs attributes
Date: Wed, 04 Nov 2026 01:55:03 +0000	[thread overview]
Message-ID: <sashiko-outbox-196415@kernel.org> (raw)
In-Reply-To: <20261104013935.512713-17-denis.benato@linux.dev>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] HID: asus: inverted sysfs_streq() check in find_button_by_name()
- [Low] HID: asus: response_curve_index ABI doc mismatches multi-line output
--

commit 82b20f9d7b18cb0817f799140de2a8d33e0549b4
Author: Denis Benato <denis.benato@linux.dev>

HID: asus: document ROG Ally sysfs attributes

This commit documents the sysfs attributes exposed by hid-asus for configuring
the ASUS ROG Ally and ROG Ally X gamepad controller, including emulation mode,
vibration, joystick calibration, trigger limits, and button mappings.

> diff --git a/Documentation/ABI/testing/sysfs-driver-hid-asus b/Documentation/ABI/testing/sysfs-driver-hid-asus
> index 30e0d17d4cecc..515eb7c550fc5 100644
> --- a/Documentation/ABI/testing/sysfs-driver-hid-asus
> +++ b/Documentation/ABI/testing/sysfs-driver-hid-asus
> @@ -93,3 +93,392 @@ Description:
>  
>  		Access: Read only
>  		Valid values: a single line of text
> +

[ ... ]

> +What:		/sys/bus/hid/drivers/asus/<dev>/left_joystick_axis/response_curve_index
> +		/sys/bus/hid/drivers/asus/<dev>/right_joystick_axis/response_curve_index
> +Date:		October 2026
> +Contact:	linux-input@vger.kernel.org
> +Description:
> +		Explanation of the format of the sibling response_curve
> +		file.
> +
> +		The files are created on the configuration interface of
> +		a bound ASUS ROG Ally or ROG Ally X controller.
> +
> +		Access: Read only
> +		Valid values: a single line of text

[Severity: Low]
Does response_curve_index actually return a single line of text?

In drivers/hid/hid-asus.c, response_curve_index_show() emits six lines of text
with embedded newlines:

drivers/hid/hid-asus.c:response_curve_index_show() {
	return sysfs_emit(buf,
			  "move_1 resp_1 move_2 resp_2 move_3 resp_3 move_4 resp_4\n"
			  "\n"
			  "move_N: joystick deflection percentage at which curve point N\n"
			  "is placed (0-100, each move_N must be greater than the\n"
			  "previous one). resp_N: response percentage applied from\n"
			  "point N on (0-100).\n");
}

Should this entry describe the multi-line output, or should
response_curve_index_show() emit a single line?

[ ... ]

> +What:		/sys/bus/hid/drivers/asus/<dev>/<btn>/remap
> +Date:		October 2026
> +Contact:	linux-input@vger.kernel.org
> +Description:
> +		Target the button is remapped to, by name. A write
> +		sends the mapping to the controller and is rejected
> +		when the name is unknown or not valid for the button
> +		in the current mode; the recorded mapping is restored
> +		when the controller rejects it.
> +
> +		"NONE" is always valid. In "gamepad" mode only gamepad
> +		codes are valid, in "desktop" mode only keyboard,
> +		mouse and media codes are; btn_m1 and btn_m2 accept
> +		every code.
> +
> +		The file is created in one directory per button of the
> +		configuration interface of a bound ASUS ROG Ally or
> +		ROG Ally X controller. <btn> is one of: btn_a, btn_b,
> +		btn_x, btn_y, btn_lb, btn_rb, dpad_up, dpad_down,
> +		dpad_left, dpad_right, btn_l3, btn_r3, btn_menu,
> +		btn_view, btn_m1 and btn_m2.
> +
> +		Access: Read/Write
> +		Valid values: one name from the sibling
> +		remap_available file

[Severity: High]
Does the driver implementation match this documented behavior for <btn>/remap
and <btn>/macro?

In drivers/hid/hid-asus.c, find_button_by_name() negates sysfs_streq():

drivers/hid/hid-asus.c:find_button_by_name() {
	for (i = 0; i < ARRAY_SIZE(ally_btn_codes); i++) {
		if (!sysfs_streq(ally_btn_codes[i].name, name))
			return &ally_btn_codes[i];
	}

	return NULL;
}

Since sysfs_streq() returns true when the strings match, !sysfs_streq()
returns the first entry in ally_btn_codes[] whose name does not match name.

Because ally_btn_codes[0] is "NONE" and ally_btn_codes[1] is "BTN_SOUTH",
calling find_button_by_name("NONE") returns "BTN_SOUTH", while calling it with
any other string (including unknown names in button_remap_store()) matches
index 0 and returns "NONE" instead of NULL.

Consequently, ally_set_button_pair_mappings_default() initializes every button
and macro slot to "BTN_SOUTH", ally_set_default_gamepad_mapping() and
ally_set_default_keyboard_mapping() set explicitly mapped buttons to "NONE",
and writes to <btn>/remap or <btn>/macro never reject unknown names with
-EINVAL.

Should the negation in find_button_by_name() be removed?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261104013935.512713-1-denis.benato@linux.dev?part=16

  reply	other threads:[~2026-11-04  1:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  1:39 [PATCH v13 00/18] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-11-04  1:39 ` [PATCH v13 01/18] HID: asus: size feature reports from the HID report descriptor Denis Benato
2026-11-04  1:39 ` [PATCH v13 02/18] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-11-04  2:07   ` sashiko-bot
2026-11-04  1:39 ` [PATCH v13 03/18] HID: asus: add gamepad configuration Denis Benato
2026-11-04  1:59   ` sashiko-bot
2026-11-04  1:39 ` [PATCH v13 04/18] HID: asus: add vibration strength configuration Denis Benato
2026-11-04  1:39 ` [PATCH v13 05/18] HID: asus: add joysticks inner and outer range configuration Denis Benato
2026-11-04  1:53   ` sashiko-bot
2026-11-04  1:39 ` [PATCH v13 06/18] HID: asus: add triggers " Denis Benato
2026-11-04  1:39 ` [PATCH v13 07/18] HID: asus: add joysticks anti-deadzone configuration Denis Benato
2026-11-04  1:39 ` [PATCH v13 08/18] HID: asus: add support for response curve Denis Benato
2026-11-04  1:39 ` [PATCH v13 09/18] HID: asus: add support to force feedback Denis Benato
2026-11-04  1:39 ` [PATCH v13 10/18] HID: asus: add support for gamepad mode Denis Benato
2026-11-04  1:39 ` [PATCH v13 11/18] HID: asus: add support for turbo buttons Denis Benato
2026-11-04  1:52   ` sashiko-bot
2026-11-04  1:39 ` [PATCH v13 12/18] HID: asus: add support for btn remapping Denis Benato
2026-11-04  1:58   ` sashiko-bot
2026-11-04  1:39 ` [PATCH v13 13/18] HID: asus: identify XG Mobile stations and bind the LED to the reported model Denis Benato
2026-11-04  1:39 ` [PATCH v13 14/18] HID: asus: expose XG Mobile identity and firmware information Denis Benato
2026-11-04  1:39 ` [PATCH v13 15/18] HID: asus: document ROG XG Mobile sysfs attributes Denis Benato
2026-11-04  1:39 ` [PATCH v13 16/18] HID: asus: document ROG Ally " Denis Benato
2026-11-04  1:55   ` sashiko-bot [this message]
2026-11-04  1:39 ` [PATCH v13 17/18] platform/x86: asus-armoury: pick the eGPU activation from the reported GPU Denis Benato
2026-11-04  1:39 ` [PATCH v13 18/18] MAINTAINERS: add maintainer for the ASUS HID driver Denis Benato

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-196415@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=denis.benato@linux.dev \
    --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