[PATCH] io_ti: export the port number in sysfs
Roman Kagan <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Message-ID | <1187376382.0@rkagan> |
Some of the Edgeport usb-serial converters have more than one (read two) serial ports on the same USB device. Currently the only way to distinguish them in userspace is by their minor device number: the driver makes them consecutive and in stable order. However, for the purpose of stable naming with udev this is insufficient: when udev handles the ADD event for one of the ports it doesn't know what minor number the other one has. To make stable naming easier, export the port number via sysfs. Signed-off-by: Roman Kagan <[email protected]> Signed-off-by: Dmitry Guryanov <[email protected]> --- drivers/usb/serial/io_ti.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index b867090..a3f5505 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -2834,15 +2834,28 @@ static ssize_t store_uart_mode(struct device *dev, return count; } +static ssize_t show_port_number(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct usb_serial_port *port = to_usb_serial_port(dev); + + return sprintf(buf, "%d\n", port->number - port->serial->minor); +} + static DEVICE_ATTR(uart_mode, S_IWUSR | S_IRUGO, show_uart_mode, store_uart_mode); +static DEVICE_ATTR(port_number, S_IRUGO, show_port_number, NULL); static int edge_create_sysfs_attrs(struct usb_serial_port *port) { - return device_create_file(&port->dev, &dev_attr_uart_mode); + int ret = device_create_file(&port->dev, &dev_attr_uart_mode); + if (!ret) + ret = device_create_file(&port->dev, &dev_attr_port_number); + return ret; } static int edge_remove_sysfs_attrs(struct usb_serial_port *port) { + device_remove_file(&port->dev, &dev_attr_port_number); device_remove_file(&port->dev, &dev_attr_uart_mode); return 0; } -- 1.5.2.5 ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel