Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 289427
b: refs/heads/master
c: 0846e7e
h: refs/heads/master
i:
  289425: 3877210
  289423: 34bd644
v: v3
  • Loading branch information
Matthew Garrett authored and Greg Kroah-Hartman committed Feb 9, 2012
1 parent f7e6406 commit fedd7ed
Show file tree
Hide file tree
Showing 4 changed files with 43 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: af74d2dae8f85a0e90a30594beb507f5d954fa3f
refs/heads/master: 0846e7e9856c0928223447d9349a877202a63f24
11 changes: 11 additions & 0 deletions trunk/Documentation/ABI/testing/sysfs-bus-usb
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,14 @@ Description:
USB2 hardware LPM is enabled for the device. Developer can
write y/Y/1 or n/N/0 to the file to enable/disable the
feature.

What: /sys/bus/usb/devices/.../removable
Date: February 2012
Contact: Matthew Garrett <mjg@redhat.com>
Description:
Some information about whether a given USB device is
physically fixed to the platform can be inferred from a
combination of hub decriptor bits and platform-specific data
such as ACPI. This file will read either "removable" or
"fixed" if the information is available, and "unknown"
otherwise.
23 changes: 23 additions & 0 deletions trunk/drivers/usb/core/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,28 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
}
static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);

static ssize_t
show_removable(struct device *dev, struct device_attribute *attr, char *buf)
{
struct usb_device *udev;
char *state;

udev = to_usb_device(dev);

switch (udev->removable) {
case USB_DEVICE_REMOVABLE:
state = "removable";
break;
case USB_DEVICE_FIXED:
state = "fixed";
break;
default:
state = "unknown";
}

return sprintf(buf, "%s\n", state);
}
static DEVICE_ATTR(removable, S_IRUGO, show_removable, NULL);

#ifdef CONFIG_PM

Expand Down Expand Up @@ -626,6 +648,7 @@ static struct attribute *dev_attrs[] = {
&dev_attr_avoid_reset_quirk.attr,
&dev_attr_authorized.attr,
&dev_attr_remove.attr,
&dev_attr_removable.attr,
NULL,
};
static struct attribute_group dev_attr_grp = {
Expand Down
8 changes: 8 additions & 0 deletions trunk/include/linux/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,12 @@ struct usb_bus {

struct usb_tt;

enum usb_device_removable {
USB_DEVICE_REMOVABLE_UNKNOWN = 0,
USB_DEVICE_REMOVABLE,
USB_DEVICE_FIXED,
};

/**
* struct usb_device - kernel's representation of a USB device
* @devnum: device number; address on a USB bus
Expand Down Expand Up @@ -432,6 +438,7 @@ struct usb_tt;
* @wusb_dev: if this is a Wireless USB device, link to the WUSB
* specific data for the device.
* @slot_id: Slot ID assigned by xHCI
* @removable: Device can be physically removed from this port
*
* Notes:
* Usbcore drivers should not set usbdev->state directly. Instead use
Expand Down Expand Up @@ -509,6 +516,7 @@ struct usb_device {
#endif
struct wusb_dev *wusb_dev;
int slot_id;
enum usb_device_removable removable;
};
#define to_usb_device(d) container_of(d, struct usb_device, dev)

Expand Down

0 comments on commit fedd7ed

Please sign in to comment.