Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 354575
b: refs/heads/master
c: cef7468
h: refs/heads/master
i:
  354573: b5412ac
  354571: 96e5ed4
  354567: cc0e8fd
  354559: 9c74971
v: v3
  • Loading branch information
Lan Tianyu authored and Greg Kroah-Hartman committed Jan 21, 2013
1 parent c53860b commit ac9e4ed
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9f7344fbaf191de63df315c7e0fa4c976e2ea419
refs/heads/master: cef7468caff29d3333fba4d0ececd82063ce80d5
9 changes: 9 additions & 0 deletions trunk/Documentation/ABI/testing/sysfs-bus-usb
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,12 @@ Contact: Lan Tianyu <tianyu.lan@intel.com>
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 <tianyu.lan@intel.com>
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.
43 changes: 43 additions & 0 deletions trunk/drivers/usb/core/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down

0 comments on commit ac9e4ed

Please sign in to comment.