[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201130153742.9163-4-johan@kernel.org>
Date: Mon, 30 Nov 2020 16:37:40 +0100
From: Johan Hovold <johan@...nel.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Jiri Slaby <jirislaby@...nel.org>,
"Mychaela N . Falconia" <falcon@...ecalypso.org>,
linux-serial@...r.kernel.org, linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org, Johan Hovold <johan@...nel.org>
Subject: [PATCH 3/5] USB: serial: add sysfs attribute to suppress ready signalling on open
Add a nordy sysfs attribute to suppress raising the modem-control lines
on open to signal DTE readiness.
This can be use to prevent undesirable side-effects on open for
applications where the DTR and RTS lines are used for non-standard
purposes such as generating power-on and reset pulses.
Signed-off-by: Johan Hovold <johan@...nel.org>
---
drivers/usb/serial/bus.c | 38 ++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index eb0195cf37dd..37bbeab6666e 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -35,6 +35,40 @@ static int usb_serial_device_match(struct device *dev,
return 0;
}
+static ssize_t nordy_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct usb_serial_port *port = dev_get_drvdata(dev);
+
+ return sprintf(buf, "%d\n", tty_port_nordy(&port->port));
+}
+
+static ssize_t nordy_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct usb_serial_port *port = dev_get_drvdata(dev);
+ unsigned int val;
+ int ret;
+
+ ret = kstrtouint(buf, 0, &val);
+ if (ret)
+ return ret;
+
+ if (val > 1)
+ return -EINVAL;
+
+ tty_port_set_nordy(&port->port, val);
+
+ return count;
+}
+static DEVICE_ATTR_RW(nordy);
+
+static struct attribute *tty_attrs[] = {
+ &dev_attr_nordy.attr,
+ NULL
+};
+ATTRIBUTE_GROUPS(tty);
+
static int usb_serial_device_probe(struct device *dev)
{
struct usb_serial_driver *driver;
@@ -60,8 +94,8 @@ static int usb_serial_device_probe(struct device *dev)
}
minor = port->minor;
- tty_dev = tty_port_register_device(&port->port, usb_serial_tty_driver,
- minor, dev);
+ tty_dev = tty_port_register_device_attr(&port->port,
+ usb_serial_tty_driver, minor, dev, port, tty_groups);
if (IS_ERR(tty_dev)) {
retval = PTR_ERR(tty_dev);
goto err_port_remove;
--
2.26.2
Powered by blists - more mailing lists