diff options
-rw-r--r-- | 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 a47a24f8820d..0b14aea8ebd5 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 | |||
36 | return 0; | 36 | return 0; |
37 | } | 37 | } |
38 | 38 | ||
39 | static ssize_t show_port_number(struct device *dev, | ||
40 | struct device_attribute *attr, char *buf) | ||
41 | { | ||
42 | struct usb_serial_port *port = to_usb_serial_port(dev); | ||
43 | |||
44 | return sprintf(buf, "%d\n", port->number - port->serial->minor); | ||
45 | } | ||
46 | |||
47 | static DEVICE_ATTR(port_number, S_IRUGO, show_port_number, NULL); | ||
48 | |||
39 | static int usb_serial_device_probe (struct device *dev) | 49 | static int usb_serial_device_probe (struct device *dev) |
40 | { | 50 | { |
41 | struct usb_serial_driver *driver; | 51 | struct usb_serial_driver *driver; |
@@ -62,6 +72,10 @@ static int usb_serial_device_probe (struct device *dev) | |||
62 | goto exit; | 72 | goto exit; |
63 | } | 73 | } |
64 | 74 | ||
75 | retval = device_create_file(dev, &dev_attr_port_number); | ||
76 | if (retval) | ||
77 | goto exit; | ||
78 | |||
65 | minor = port->number; | 79 | minor = port->number; |
66 | tty_register_device (usb_serial_tty_driver, minor, dev); | 80 | tty_register_device (usb_serial_tty_driver, minor, dev); |
67 | dev_info(&port->serial->dev->dev, | 81 | dev_info(&port->serial->dev->dev, |
@@ -84,6 +98,8 @@ static int usb_serial_device_remove (struct device *dev) | |||
84 | return -ENODEV; | 98 | return -ENODEV; |
85 | } | 99 | } |
86 | 100 | ||
101 | device_remove_file(&port->dev, &dev_attr_port_number); | ||
102 | |||
87 | driver = port->serial->type; | 103 | driver = port->serial->type; |
88 | if (driver->port_remove) { | 104 | if (driver->port_remove) { |
89 | if (!try_module_get(driver->driver.owner)) { | 105 | if (!try_module_get(driver->driver.owner)) { |