Commit:     ce0d9325b19555f05b08cbb1ea4c2393eec188ec
Parent:     fdf99c9ec10cb9cd44be3ac0bd007a49ac6dc751
Author:     Roman Kagan <[EMAIL PROTECTED]>
AuthorDate: Fri Aug 24 20:22:52 2007 +0400
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Fri Oct 12 14:55:20 2007 -0700

    usb-serial: show port number in sysfs
    Some usb-serial devices (e.g. certain Edgeport models) have more than
    one serial port on the same USB device/interface.
    Currently the only way to distinguish these ports 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]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
 drivers/usb/serial/bus.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index a47a24f..0b14aea 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -36,6 +36,16 @@ static int usb_serial_device_match (struct device *dev, 
struct device_driver *dr
        return 0;
+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(port_number, S_IRUGO, show_port_number, NULL);
 static int usb_serial_device_probe (struct device *dev)
        struct usb_serial_driver *driver;
@@ -62,6 +72,10 @@ static int usb_serial_device_probe (struct device *dev)
                        goto exit;
+       retval = device_create_file(dev, &dev_attr_port_number);
+       if (retval)
+               goto exit;
        minor = port->number;
        tty_register_device (usb_serial_tty_driver, minor, dev);
@@ -84,6 +98,8 @@ static int usb_serial_device_remove (struct device *dev)
                return -ENODEV;
+       device_remove_file(&port->dev, &dev_attr_port_number);
        driver = port->serial->type;
        if (driver->port_remove) {
                if (!try_module_get(driver->driver.owner)) {
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to