From nobody Thu Apr 2 23:18:12 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0D12C54EE9 for ; Mon, 19 Sep 2022 13:25:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230490AbiISNZt (ORCPT ); Mon, 19 Sep 2022 09:25:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230265AbiISNZb (ORCPT ); Mon, 19 Sep 2022 09:25:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4072ECE3E; Mon, 19 Sep 2022 06:25:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7D473B81BE2; Mon, 19 Sep 2022 13:25:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A6F8C433B5; Mon, 19 Sep 2022 13:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663593926; bh=Tff0msRmVXjswmkJrDQx5mdytkeF8V7Bwkf1RbtpykA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F9Z1IH4/jlUoM1g1n73j9vu07Jo2fx2KBmmmwxjwVv9D2BXeackQe+Ay+pr6uAEKN ph3jJwj7eXyjwpMNz4ZuSpH1cGpV0Fjeo5XRE5yL5oz56NfE01OwdR1xJuNS7GwPCf 28GI7ySSfulNUV3dQ2t7yVAJS1wV/oCsBozyelbT2AlrIg7jTtBnzixBjX02FjNKXI +9KWXqGvz8VzaSZCJypY5S3IgMC0c+vUKMrZ3ZVnT0CdUi5MDx92VrbPSetd7xRIXd q21cKV4yhHjmH0SoYNeRCrL8OU2idzVyEI9CHRuT3g4Ip2idFPUNasL7pWXx71SvU1 rdHaHv/1uSzLA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oaGmB-0005R5-27; Mon, 19 Sep 2022 15:25:31 +0200 From: Johan Hovold To: Johan Hovold Cc: Jiasheng Jiang , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] USB: serial: ftdi_sio: clean up attribute visibility logic Date: Mon, 19 Sep 2022 15:24:54 +0200 Message-Id: <20220919132456.20851-2-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220919132456.20851-1-johan@kernel.org> References: <20220919132456.20851-1-johan@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Clean up the attribute visibility logic by defaulting to attributes being visible and explicitly listing the exceptions. Signed-off-by: Johan Hovold Reviewed-by: Greg Kroah-Hartman --- drivers/usb/serial/ftdi_sio.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 147b5e80595a..a5fc199cde0b 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1775,19 +1775,18 @@ static umode_t ftdi_is_visible(struct kobject *kobj= , struct attribute *attr, int struct usb_serial_port *port =3D to_usb_serial_port(dev); struct ftdi_private *priv =3D usb_get_serial_port_data(port); enum ftdi_chip_type type =3D priv->chip_type; - umode_t mode =3D attr->mode; =20 - if (type !=3D SIO) { - if (attr =3D=3D &dev_attr_event_char.attr) - return mode; + if (attr =3D=3D &dev_attr_event_char.attr) { + if (type =3D=3D SIO) + return 0; } =20 - if (type !=3D SIO && type !=3D FT232A) { - if (attr =3D=3D &dev_attr_latency_timer.attr) - return mode; + if (attr =3D=3D &dev_attr_latency_timer.attr) { + if (type =3D=3D SIO || type =3D=3D FT232A) + return 0; } =20 - return 0; + return attr->mode; } =20 static const struct attribute_group ftdi_group =3D { --=20 2.35.1 From nobody Thu Apr 2 23:18:12 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08AA6C6FA8B for ; Mon, 19 Sep 2022 13:25:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230391AbiISNZe (ORCPT ); Mon, 19 Sep 2022 09:25:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230112AbiISNZb (ORCPT ); Mon, 19 Sep 2022 09:25:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40842D10F; Mon, 19 Sep 2022 06:25:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 71312B81BD9; Mon, 19 Sep 2022 13:25:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 256DAC433C1; Mon, 19 Sep 2022 13:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663593926; bh=YaeRxWbt+/MWcq8tF2wVcj1FK8OAKg3UKPDh2LMI0H8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oGDaRJJbV5AY9AJdcBpa5yc4VlrZD3NtG4Na7iZu/uG9K6jI8438B9TjZi9Qi3IIa IVmiU4yxKVKdrT5ISZ3ZJejM1CReitaxL+KbyKFPekdUwO8IKKfHdwHtWmcyQ6L6F4 qRjU2wWzdpj6CuDj6mwP9DFgqO9B4Xq4yOgixiUntCTgRXyh2HV+sSsUyokmMD/3d/ aXbXCjExPzEn8yIuKoGN0ImIyBbfPU9MBGIs6isB6qW0RGhm27HlKxzdMz6Z7b1fJN 4XnSXUgtSJ64RqH3tgdxGC2fuLftkDwZLFbA79jrsK8JegLOn0/2VkqRp22TxahObe Pv8o6KCrvuDzA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oaGmB-0005R7-50; Mon, 19 Sep 2022 15:25:31 +0200 From: Johan Hovold To: Johan Hovold Cc: Jiasheng Jiang , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] USB: serial: ftdi_sio: move driver structure Date: Mon, 19 Sep 2022 15:24:55 +0200 Message-Id: <20220919132456.20851-3-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220919132456.20851-1-johan@kernel.org> References: <20220919132456.20851-1-johan@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Move the definition of the USB serial driver structure to the end of the file where it is used and drop the now redundant forward declarations. Signed-off-by: Johan Hovold Reviewed-by: Greg Kroah-Hartman --- drivers/usb/serial/ftdi_sio.c | 101 ++++++++++++---------------------- 1 file changed, 35 insertions(+), 66 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index a5fc199cde0b..cd594937b0e6 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1108,77 +1108,11 @@ static const char *ftdi_chip_name[] =3D { #define FTDI_STATUS_B1_MASK (FTDI_RS_BI) /* End TIOCMIWAIT */ =20 -/* function prototypes for a FTDI serial converter */ -static int ftdi_sio_probe(struct usb_serial *serial, - const struct usb_device_id *id); -static int ftdi_sio_port_probe(struct usb_serial_port *port); -static void ftdi_sio_port_remove(struct usb_serial_port *port); -static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port= ); -static void ftdi_dtr_rts(struct usb_serial_port *port, int on); -static void ftdi_process_read_urb(struct urb *urb); -static int ftdi_prepare_write_buffer(struct usb_serial_port *port, - void *dest, size_t size); static void ftdi_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old); -static int ftdi_tiocmget(struct tty_struct *tty); -static int ftdi_tiocmset(struct tty_struct *tty, - unsigned int set, unsigned int clear); -static int ftdi_ioctl(struct tty_struct *tty, - unsigned int cmd, unsigned long arg); -static void get_serial_info(struct tty_struct *tty, struct serial_struct *= ss); -static int set_serial_info(struct tty_struct *tty, - struct serial_struct *ss); -static void ftdi_break_ctl(struct tty_struct *tty, int break_state); -static bool ftdi_tx_empty(struct usb_serial_port *port); static int ftdi_get_modem_status(struct usb_serial_port *port, unsigned char status[2]); =20 -static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int ba= se); -static unsigned short int ftdi_232am_baud_to_divisor(int baud); -static u32 ftdi_232bm_baud_base_to_divisor(int baud, int base); -static u32 ftdi_232bm_baud_to_divisor(int baud); -static u32 ftdi_2232h_baud_base_to_divisor(int baud, int base); -static u32 ftdi_2232h_baud_to_divisor(int baud); - -static const struct attribute_group *ftdi_groups[]; - -static struct usb_serial_driver ftdi_sio_device =3D { - .driver =3D { - .owner =3D THIS_MODULE, - .name =3D "ftdi_sio", - .dev_groups =3D ftdi_groups, - }, - .description =3D "FTDI USB Serial Device", - .id_table =3D id_table_combined, - .num_ports =3D 1, - .bulk_in_size =3D 512, - .bulk_out_size =3D 256, - .probe =3D ftdi_sio_probe, - .port_probe =3D ftdi_sio_port_probe, - .port_remove =3D ftdi_sio_port_remove, - .open =3D ftdi_open, - .dtr_rts =3D ftdi_dtr_rts, - .throttle =3D usb_serial_generic_throttle, - .unthrottle =3D usb_serial_generic_unthrottle, - .process_read_urb =3D ftdi_process_read_urb, - .prepare_write_buffer =3D ftdi_prepare_write_buffer, - .tiocmget =3D ftdi_tiocmget, - .tiocmset =3D ftdi_tiocmset, - .tiocmiwait =3D usb_serial_generic_tiocmiwait, - .get_icount =3D usb_serial_generic_get_icount, - .ioctl =3D ftdi_ioctl, - .get_serial =3D get_serial_info, - .set_serial =3D set_serial_info, - .set_termios =3D ftdi_set_termios, - .break_ctl =3D ftdi_break_ctl, - .tx_empty =3D ftdi_tx_empty, -}; - -static struct usb_serial_driver * const serial_drivers[] =3D { - &ftdi_sio_device, NULL -}; - - #define WDR_TIMEOUT 5000 /* default urb timeout */ #define WDR_SHORT_TIMEOUT 1000 /* shorter urb timeout */ =20 @@ -2931,6 +2865,41 @@ static int ftdi_ioctl(struct tty_struct *tty, return -ENOIOCTLCMD; } =20 +static struct usb_serial_driver ftdi_sio_device =3D { + .driver =3D { + .owner =3D THIS_MODULE, + .name =3D "ftdi_sio", + .dev_groups =3D ftdi_groups, + }, + .description =3D "FTDI USB Serial Device", + .id_table =3D id_table_combined, + .num_ports =3D 1, + .bulk_in_size =3D 512, + .bulk_out_size =3D 256, + .probe =3D ftdi_sio_probe, + .port_probe =3D ftdi_sio_port_probe, + .port_remove =3D ftdi_sio_port_remove, + .open =3D ftdi_open, + .dtr_rts =3D ftdi_dtr_rts, + .throttle =3D usb_serial_generic_throttle, + .unthrottle =3D usb_serial_generic_unthrottle, + .process_read_urb =3D ftdi_process_read_urb, + .prepare_write_buffer =3D ftdi_prepare_write_buffer, + .tiocmget =3D ftdi_tiocmget, + .tiocmset =3D ftdi_tiocmset, + .tiocmiwait =3D usb_serial_generic_tiocmiwait, + .get_icount =3D usb_serial_generic_get_icount, + .ioctl =3D ftdi_ioctl, + .get_serial =3D get_serial_info, + .set_serial =3D set_serial_info, + .set_termios =3D ftdi_set_termios, + .break_ctl =3D ftdi_break_ctl, + .tx_empty =3D ftdi_tx_empty, +}; + +static struct usb_serial_driver * const serial_drivers[] =3D { + &ftdi_sio_device, NULL +}; module_usb_serial_driver(serial_drivers, id_table_combined); =20 MODULE_AUTHOR(DRIVER_AUTHOR); --=20 2.35.1 From nobody Thu Apr 2 23:18:12 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B0E9C54EE9 for ; Mon, 19 Sep 2022 13:25:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbiISNZl (ORCPT ); Mon, 19 Sep 2022 09:25:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbiISNZb (ORCPT ); Mon, 19 Sep 2022 09:25:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40342CE0C; Mon, 19 Sep 2022 06:25:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6BF5FB81AE8; Mon, 19 Sep 2022 13:25:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22B8EC433D6; Mon, 19 Sep 2022 13:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663593926; bh=BGhrQD7LEio4Kzy/pFpU7z6uraCfbjuQ8M4hk6gm7kY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m/ge5JnI9Za+mApsbGZjOYiNxGuPzMaNK9x7zigNnuawK+GG7x3j2YVsxXP4bXoN8 4hkWvjFmJyBpIsa+bytJb46UEjPMfd34GZ8K773UlysZBy9sbmTgSQwqOf8JKemA5L W3wxagytkIyG57jOLptQ87ev/Lg4xYtetLlCw+pBEJ5AYA7YFY9yRpTrwIvOGtNNbh SYgI0bHaMHl0I/lb0F4EYa6ctGJCgOFsSM5HWgmNqBX6hAbm21sfr9lgNYy4lLBM8F FR5hEztjXh27NaTV6f/3jA9B4cUC5futvJpOHgLx0Wute7K6FK1233ZnAMsJBVshaE NaG9tW8uB++NQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oaGmB-0005RA-7V; Mon, 19 Sep 2022 15:25:31 +0200 From: Johan Hovold To: Johan Hovold Cc: Jiasheng Jiang , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] USB: serial: ftdi_sio: clean up driver prefix Date: Mon, 19 Sep 2022 15:24:56 +0200 Message-Id: <20220919132456.20851-4-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220919132456.20851-1-johan@kernel.org> References: <20220919132456.20851-1-johan@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Drop the "sio" infix from the few remaining definitions and symbol names that still had it. Signed-off-by: Johan Hovold Reviewed-by: Greg Kroah-Hartman --- drivers/usb/serial/ftdi_sio.c | 38 ++++++++++++++++------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index cd594937b0e6..f584ce29fc9f 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -100,8 +100,7 @@ struct ftdi_private { #endif }; =20 -/* struct ftdi_sio_quirk is used by devices requiring special attention. */ -struct ftdi_sio_quirk { +struct ftdi_quirk { int (*probe)(struct usb_serial *); /* Special settings for probed ports. */ void (*port_probe)(struct ftdi_private *); @@ -114,27 +113,27 @@ static int ftdi_8u2232c_probe(struct usb_serial *se= rial); static void ftdi_USB_UIRT_setup(struct ftdi_private *priv); static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv); =20 -static const struct ftdi_sio_quirk ftdi_jtag_quirk =3D { +static const struct ftdi_quirk ftdi_jtag_quirk =3D { .probe =3D ftdi_jtag_probe, }; =20 -static const struct ftdi_sio_quirk ftdi_NDI_device_quirk =3D { +static const struct ftdi_quirk ftdi_NDI_device_quirk =3D { .probe =3D ftdi_NDI_device_setup, }; =20 -static const struct ftdi_sio_quirk ftdi_USB_UIRT_quirk =3D { +static const struct ftdi_quirk ftdi_USB_UIRT_quirk =3D { .port_probe =3D ftdi_USB_UIRT_setup, }; =20 -static const struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk =3D { +static const struct ftdi_quirk ftdi_HE_TIRA1_quirk =3D { .port_probe =3D ftdi_HE_TIRA1_setup, }; =20 -static const struct ftdi_sio_quirk ftdi_stmclite_quirk =3D { +static const struct ftdi_quirk ftdi_stmclite_quirk =3D { .probe =3D ftdi_stmclite_probe, }; =20 -static const struct ftdi_sio_quirk ftdi_8u2232c_quirk =3D { +static const struct ftdi_quirk ftdi_8u2232c_quirk =3D { .probe =3D ftdi_8u2232c_probe, }; =20 @@ -2170,12 +2169,9 @@ static void ftdi_gpio_remove(struct usb_serial_port = *port) { } * ***********************************************************************= **** */ =20 -/* Probe function to check for special devices */ -static int ftdi_sio_probe(struct usb_serial *serial, - const struct usb_device_id *id) +static int ftdi_probe(struct usb_serial *serial, const struct usb_device_i= d *id) { - const struct ftdi_sio_quirk *quirk =3D - (struct ftdi_sio_quirk *)id->driver_info; + const struct ftdi_quirk *quirk =3D (struct ftdi_quirk *)id->driver_info; =20 if (quirk && quirk->probe) { int ret =3D quirk->probe(serial); @@ -2188,10 +2184,10 @@ static int ftdi_sio_probe(struct usb_serial *serial, return 0; } =20 -static int ftdi_sio_port_probe(struct usb_serial_port *port) +static int ftdi_port_probe(struct usb_serial_port *port) { + const struct ftdi_quirk *quirk =3D usb_get_serial_data(port->serial); struct ftdi_private *priv; - const struct ftdi_sio_quirk *quirk =3D usb_get_serial_data(port->serial); int result; =20 priv =3D kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); @@ -2337,7 +2333,7 @@ static int ftdi_stmclite_probe(struct usb_serial *ser= ial) return 0; } =20 -static void ftdi_sio_port_remove(struct usb_serial_port *port) +static void ftdi_port_remove(struct usb_serial_port *port) { struct ftdi_private *priv =3D usb_get_serial_port_data(port); =20 @@ -2865,7 +2861,7 @@ static int ftdi_ioctl(struct tty_struct *tty, return -ENOIOCTLCMD; } =20 -static struct usb_serial_driver ftdi_sio_device =3D { +static struct usb_serial_driver ftdi_device =3D { .driver =3D { .owner =3D THIS_MODULE, .name =3D "ftdi_sio", @@ -2876,9 +2872,9 @@ static struct usb_serial_driver ftdi_sio_device =3D { .num_ports =3D 1, .bulk_in_size =3D 512, .bulk_out_size =3D 256, - .probe =3D ftdi_sio_probe, - .port_probe =3D ftdi_sio_port_probe, - .port_remove =3D ftdi_sio_port_remove, + .probe =3D ftdi_probe, + .port_probe =3D ftdi_port_probe, + .port_remove =3D ftdi_port_remove, .open =3D ftdi_open, .dtr_rts =3D ftdi_dtr_rts, .throttle =3D usb_serial_generic_throttle, @@ -2898,7 +2894,7 @@ static struct usb_serial_driver ftdi_sio_device =3D { }; =20 static struct usb_serial_driver * const serial_drivers[] =3D { - &ftdi_sio_device, NULL + &ftdi_device, NULL }; module_usb_serial_driver(serial_drivers, id_table_combined); =20 --=20 2.35.1