From ac9e4edd3e19df53d14e321adcb74ffcd27cb122 Mon Sep 17 00:00:00 2001 From: Lan Tianyu Date: Sun, 20 Jan 2013 01:53:32 +0800 Subject: [PATCH] --- yaml --- r: 354575 b: refs/heads/master c: cef7468caff29d3333fba4d0ececd82063ce80d5 h: refs/heads/master i: 354573: b5412aca34d0d3628cf9fdcced4c9c75e4673c65 354571: 96e5ed4585cba0c57c826bee4e0e456b67a89cd3 354567: cc0e8fdd1df89901b790e59581d777acdcdbef2d 354559: 9c74971874c8c6b438a25c0116caaf8fe091f2bb v: v3 --- [refs] | 2 +- trunk/Documentation/ABI/testing/sysfs-bus-usb | 9 ++++ trunk/drivers/usb/core/port.c | 43 +++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 49b7cdb8cc52..ecfa6b148e68 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9f7344fbaf191de63df315c7e0fa4c976e2ea419 +refs/heads/master: cef7468caff29d3333fba4d0ececd82063ce80d5 diff --git a/trunk/Documentation/ABI/testing/sysfs-bus-usb b/trunk/Documentation/ABI/testing/sysfs-bus-usb index b6fbe514a869..c8baaf53594a 100644 --- a/trunk/Documentation/ABI/testing/sysfs-bus-usb +++ b/trunk/Documentation/ABI/testing/sysfs-bus-usb @@ -227,3 +227,12 @@ Contact: Lan Tianyu Description: The /sys/bus/usb/devices/.../(hub interface)/portX is usb port device's sysfs directory. + +What: /sys/bus/usb/devices/.../(hub interface)/portX/connect_type +Date: January 2013 +Contact: Lan Tianyu +Description: + Some platforms provide usb port connect types through ACPI. + This attribute is to expose these information to user space. + The file will read "hotplug", "wired" and "not used" if the + information is available, and "unknown" otherwise. diff --git a/trunk/drivers/usb/core/port.c b/trunk/drivers/usb/core/port.c index 3734850120ae..fe5959fc021b 100644 --- a/trunk/drivers/usb/core/port.c +++ b/trunk/drivers/usb/core/port.c @@ -20,6 +20,48 @@ #include "hub.h" +static const struct attribute_group *port_dev_group[]; + +static ssize_t show_port_connect_type(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct usb_port *port_dev = to_usb_port(dev); + char *result; + + switch (port_dev->connect_type) { + case USB_PORT_CONNECT_TYPE_HOT_PLUG: + result = "hotplug"; + break; + case USB_PORT_CONNECT_TYPE_HARD_WIRED: + result = "hardwired"; + break; + case USB_PORT_NOT_USED: + result = "not used"; + break; + default: + result = "unknown"; + break; + } + + return sprintf(buf, "%s\n", result); +} +static DEVICE_ATTR(connect_type, S_IRUGO, show_port_connect_type, + NULL); + +static struct attribute *port_dev_attrs[] = { + &dev_attr_connect_type.attr, + NULL, +}; + +static struct attribute_group port_dev_attr_grp = { + .attrs = port_dev_attrs, +}; + +static const struct attribute_group *port_dev_group[] = { + &port_dev_attr_grp, + NULL, +}; + static void usb_port_device_release(struct device *dev) { 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) hub->ports[port1 - 1] = port_dev; port_dev->dev.parent = hub->intfdev; + port_dev->dev.groups = port_dev_group; port_dev->dev.type = &usb_port_device_type; dev_set_name(&port_dev->dev, "port%d", port1);