Re: [PATCH v4 03/16] HID: ft260: add GPIO support

From
sashiko-bot@kernel.org
Date
2026-11-17 20:23:54
Also in
linux-gpio, linux-serial
Reply to
Michael Zaidman, 2026-11-17
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] HID: ft260: unused gpio state field and macros in
  ft260_gpio_init()
--

commit 8d81adc5ba43eb8c745172cf336bbd09bc7bc28f
Author: Michael Zaidman [off-list ref]

HID: ft260: add GPIO support

This commit adds gpiochip support for the FT260 multifunctional pins,
exposes pin function selection via sysfs, and tracks enabled GPIOs across
UART modes.
quoted hunk ↗ jump to hunk
diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c
index 869e7b924b30a..acd92248256f9 100644
--- a/drivers/hid/hid-ft260.c
+++ b/drivers/hid/hid-ft260.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -57,6 +59,11 @@ MODULE_PARM_DESC(debug, "Toggle FT260 debugging messages");
 #define FT260_RD_DATA_MAX 180
 #define FT260_WR_I2C_DATA_MAX 60
 #define FT260_WR_UART_DATA_MAX 60
+#define FT260_GPIOCHIP "ft260_gpio"
+#define FT260_GPIO_0_5_COUNT 6
+#define FT260_GPIO_A_H_COUNT 8
+#define FT260_GPIO_TOTAL (FT260_GPIO_0_5_COUNT + FT260_GPIO_A_H_COUNT)
+#define FT260_GPIO_MASK GENMASK(FT260_GPIO_TOTAL - 1, 0)
[ ... ]
quoted hunk ↗ jump to hunk
+/* GPIO groups */
+#define FT260_GPIO_WAKEUP		FT260_GPIO_3
+#define FT260_GPIO_I2C_DEFAULT		(FT260_GPIO_0 | FT260_GPIO_1)
[ ... ]
quoted hunk ↗ jump to hunk
@@ -359,6 +470,11 @@ struct ft260_device {
 	u16 read_idx;
 	u16 read_len;
 	u16 clock;
+	u16 gpio_en;
+	struct gpio_chip gc;
+	struct ft260_gpio_state gpio;
+	u16 gpio_uart_mode[FT260_GPIO_UART_MODES];
+	bool uart_dcd_ri;
 };
[ ... ]
quoted hunk ↗ jump to hunk
+static int ft260_gpio_init(struct ft260_device *dev,
+			   struct ft260_get_system_status_report *cfg)
+{
[ ... ]
quoted hunk ↗ jump to hunk
+	/* Wakeup chip */
+	(void)ft260_hid_feature_report_get(dev->hdev, FT260_CHIP_VERSION,
+					(u8 *)&ver, sizeof(ver));
+
+	ret = ft260_hid_feature_report_get(hdev, FT260_GPIO, (u8 *)&gbuf,
+					   sizeof(gbuf));
+	if (ret < 0)
+		hid_warn(hdev, "cannot read GPIO state: %d\n", ret);
+	else
+		dev->gpio = gbuf.gpio;
[Severity: Low]
Is dev->gpio (along with this FT260_GPIO feature report read in
ft260_gpio_init()) still needed now that ft260_gpio_set() and
ft260_gpio_direction_set() read FT260_GPIO from the chip before modifying a
pin?

dev->gpio is written in ft260_gpio_init(), ft260_gpio_set(), and
ft260_gpio_direction_set(), but never read in this commit.  Although commit
"HID: ft260: uart: add modem pins control via ioctl" briefly reads
port->gpio in ft260_uart_tiocmset(), commit "HID: ft260: i2c: recover a bus
held by a slave" changes ft260_uart_tiocmset() to read FT260_GPIO directly
from the chip as well, leaving dev->gpio write-only at the end of the
series.

Also, FT260_GPIOCHIP and FT260_GPIO_WAKEUP are unused because
ft260_gpio_init() formats dev->gc.label with devm_kasprintf() and checks
enable_wakeup_int with FT260_GPIO_3 directly.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117200423.19561-1-michael.zaidman@gmail.com?part=3
Thread (27 messages) 27 messages, 4 authors, last reply 1d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help