diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/usb/core/port.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index 3734850120ae..fe5959fc021b 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c | |||
| @@ -20,6 +20,48 @@ | |||
| 20 | 20 | ||
| 21 | #include "hub.h" | 21 | #include "hub.h" |
| 22 | 22 | ||
| 23 | static const struct attribute_group *port_dev_group[]; | ||
| 24 | |||
| 25 | static ssize_t show_port_connect_type(struct device *dev, | ||
| 26 | struct device_attribute *attr, char *buf) | ||
| 27 | { | ||
| 28 | struct usb_port *port_dev = to_usb_port(dev); | ||
| 29 | char *result; | ||
| 30 | |||
| 31 | switch (port_dev->connect_type) { | ||
| 32 | case USB_PORT_CONNECT_TYPE_HOT_PLUG: | ||
| 33 | result = "hotplug"; | ||
| 34 | break; | ||
| 35 | case USB_PORT_CONNECT_TYPE_HARD_WIRED: | ||
| 36 | result = "hardwired"; | ||
| 37 | break; | ||
| 38 | case USB_PORT_NOT_USED: | ||
| 39 | result = "not used"; | ||
| 40 | break; | ||
| 41 | default: | ||
| 42 | result = "unknown"; | ||
| 43 | break; | ||
| 44 | } | ||
| 45 | |||
| 46 | return sprintf(buf, "%s\n", result); | ||
| 47 | } | ||
| 48 | static DEVICE_ATTR(connect_type, S_IRUGO, show_port_connect_type, | ||
| 49 | NULL); | ||
| 50 | |||
| 51 | static struct attribute *port_dev_attrs[] = { | ||
| 52 | &dev_attr_connect_type.attr, | ||
| 53 | NULL, | ||
| 54 | }; | ||
| 55 | |||
| 56 | static struct attribute_group port_dev_attr_grp = { | ||
| 57 | .attrs = port_dev_attrs, | ||
| 58 | }; | ||
| 59 | |||
| 60 | static const struct attribute_group *port_dev_group[] = { | ||
| 61 | &port_dev_attr_grp, | ||
| 62 | NULL, | ||
| 63 | }; | ||
| 64 | |||
| 23 | static void usb_port_device_release(struct device *dev) | 65 | static void usb_port_device_release(struct device *dev) |
| 24 | { | 66 | { |
| 25 | struct usb_port *port_dev = to_usb_port(dev); | 67 | struct usb_port *port_dev = to_usb_port(dev); |
| @@ -45,6 +87,7 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1) | |||
| 45 | 87 | ||
| 46 | hub->ports[port1 - 1] = port_dev; | 88 | hub->ports[port1 - 1] = port_dev; |
| 47 | port_dev->dev.parent = hub->intfdev; | 89 | port_dev->dev.parent = hub->intfdev; |
| 90 | port_dev->dev.groups = port_dev_group; | ||
| 48 | port_dev->dev.type = &usb_port_device_type; | 91 | port_dev->dev.type = &usb_port_device_type; |
| 49 | dev_set_name(&port_dev->dev, "port%d", port1); | 92 | dev_set_name(&port_dev->dev, "port%d", port1); |
| 50 | 93 | ||
