aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorLan Tianyu <tianyu.lan@intel.com>2013-01-19 12:53:32 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-20 19:09:53 -0500
commitcef7468caff29d3333fba4d0ececd82063ce80d5 (patch)
tree5e3a3409f3dc4a37336b2ba05f4893b8f6cb8710 /drivers/usb/core
parent9f7344fbaf191de63df315c7e0fa4c976e2ea419 (diff)
usb: Add "portX/connect_type" attribute to expose usb port's connect type
Some platforms provide usb port connect types through ACPI. This patch is to add this new attribute to expose these information to user space. Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/port.c43
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
23static const struct attribute_group *port_dev_group[];
24
25static 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}
48static DEVICE_ATTR(connect_type, S_IRUGO, show_port_connect_type,
49 NULL);
50
51static struct attribute *port_dev_attrs[] = {
52 &dev_attr_connect_type.attr,
53 NULL,
54};
55
56static struct attribute_group port_dev_attr_grp = {
57 .attrs = port_dev_attrs,
58};
59
60static const struct attribute_group *port_dev_group[] = {
61 &port_dev_attr_grp,
62 NULL,
63};
64
23static void usb_port_device_release(struct device *dev) 65static 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