lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220911140216.30481-9-johan@kernel.org>
Date:   Sun, 11 Sep 2022 16:02:12 +0200
From:   Johan Hovold <johan@...nel.org>
To:     Johan Hovold <johan@...nel.org>
Cc:     Amireddy mallikarjuna reddy <mallikarjuna.reddy@...ichip.com>,
        arun.pappan@...ichip.com, sowjanya.reddy@...ichip.com,
        malliamireddy009@...il.com, linux-usb@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH 08/12] USB: serial: ftdi_sio: clean up attribute handling

The driver exposes two attributes for all chip types but FT232A, which
doesn't have a configurable latency timer, and SIO, which (probably)
doesn't support the event-char mechanism either.

Explicitly test for the exceptions rather than list each and every
supported device type in the attribute helpers.

Signed-off-by: Johan Hovold <johan@...nel.org>
---
 drivers/usb/serial/ftdi_sio.c | 47 ++++++++++++-----------------------
 1 file changed, 16 insertions(+), 31 deletions(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 58e0acb211df..835e12fc971a 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1726,46 +1726,31 @@ static DEVICE_ATTR_WO(event_char);
 static int create_sysfs_attrs(struct usb_serial_port *port)
 {
 	struct ftdi_private *priv = usb_get_serial_port_data(port);
-	int retval = 0;
-
-	/* XXX I've no idea if the original SIO supports the event_char
-	 * sysfs parameter, so I'm playing it safe.  */
-	if (priv->chip_type != SIO) {
-		dev_dbg(&port->dev, "sysfs attributes for %s\n", ftdi_chip_name[priv->chip_type]);
-		retval = device_create_file(&port->dev, &dev_attr_event_char);
-		if ((!retval) &&
-		    (priv->chip_type == FT232B ||
-		     priv->chip_type == FT2232C ||
-		     priv->chip_type == FT232R ||
-		     priv->chip_type == FT2232H ||
-		     priv->chip_type == FT4232H ||
-		     priv->chip_type == FT232H ||
-		     priv->chip_type == FTX)) {
-			retval = device_create_file(&port->dev,
-						    &dev_attr_latency_timer);
-		}
+	enum ftdi_chip_type type = priv->chip_type;
+	int ret = 0;
+
+	if (type != SIO) {
+		ret = device_create_file(&port->dev, &dev_attr_event_char);
+		if (ret)
+			return ret;
 	}
-	return retval;
+
+	if (type != SIO && type != FT232A)
+		ret = device_create_file(&port->dev, &dev_attr_latency_timer);
+
+	return ret;
 }
 
 static void remove_sysfs_attrs(struct usb_serial_port *port)
 {
 	struct ftdi_private *priv = usb_get_serial_port_data(port);
+	enum ftdi_chip_type type = priv->chip_type;
 
-	/* XXX see create_sysfs_attrs */
-	if (priv->chip_type != SIO) {
+	if (type != SIO)
 		device_remove_file(&port->dev, &dev_attr_event_char);
-		if (priv->chip_type == FT232B ||
-		    priv->chip_type == FT2232C ||
-		    priv->chip_type == FT232R ||
-		    priv->chip_type == FT2232H ||
-		    priv->chip_type == FT4232H ||
-		    priv->chip_type == FT232H ||
-		    priv->chip_type == FTX) {
-			device_remove_file(&port->dev, &dev_attr_latency_timer);
-		}
-	}
 
+	if (type != SIO && type != FT232A)
+		device_remove_file(&port->dev, &dev_attr_latency_timer);
 }
 
 #ifdef CONFIG_GPIOLIB
-- 
2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ