[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231003001135.2713961-1-sbertrand@witekio.com>
Date: Mon, 2 Oct 2023 17:11:35 -0700
From: Stan Bertrand <stanislasbertrand@...il.com>
To: Johan Hovold <johan@...nel.org>, linux-usb@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org,
Stanislas Bertrand <stanislasbertrand@...il.com>
Subject: [PATCH] USB: serial: ftdi_sio: add ftdi serial to gpiochip label
From: Stanislas Bertrand <stanislasbertrand@...il.com>
Use ftdi serial number on gpiochip label.
Allows to interface with gpiod utils using the serial number:
$ gpiodetect
gpiochip5 [ftdi-cbus-FTRelay2] (4 lines)
gpiochip6 [ftdi-cbus] (4 lines)
gpiochip7 [ftdi-cbus-A106TPEC] (4 lines)
$ gpioget ftdi-cbus-FTRelay2 2
0
Signed-off-by: Stanislas Bertrand <stanislasbertrand@...il.com>
---
drivers/usb/serial/ftdi_sio.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 1bf23611be12..3e1b1c3194a2 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2094,6 +2094,8 @@ static int ftdi_gpio_init(struct usb_serial_port *port)
{
struct ftdi_private *priv = usb_get_serial_port_data(port);
struct usb_serial *serial = port->serial;
+ struct usb_device *udev = serial->dev;
+ const char *label;
int result;
switch (priv->chip_type) {
@@ -2116,6 +2118,15 @@ static int ftdi_gpio_init(struct usb_serial_port *port)
mutex_init(&priv->gpio_lock);
priv->gc.label = "ftdi-cbus";
+
+ if (udev->serial) {
+ label = devm_kasprintf(&udev->dev, GFP_KERNEL, "ftdi-cbus-%s",
+ udev->serial);
+ if (label) {
+ priv->gc.label = label;
+ }
+ }
+
priv->gc.request = ftdi_gpio_request;
priv->gc.get_direction = ftdi_gpio_direction_get;
priv->gc.direction_input = ftdi_gpio_direction_input;
--
2.34.1
Powered by blists - more mailing lists