diff options
Diffstat (limited to 'drivers/usb/core/sysfs.c')
-rw-r--r-- | drivers/usb/core/sysfs.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 818e4a024d0d..3f81a3dc6867 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include "usb.h" | 17 | #include "usb.h" |
18 | 18 | ||
19 | /* Active configuration fields */ | 19 | /* Active configuration fields */ |
20 | #define usb_actconfig_show(field, multiplier, format_string) \ | 20 | #define usb_actconfig_show(field, format_string) \ |
21 | static ssize_t show_##field(struct device *dev, \ | 21 | static ssize_t show_##field(struct device *dev, \ |
22 | struct device_attribute *attr, char *buf) \ | 22 | struct device_attribute *attr, char *buf) \ |
23 | { \ | 23 | { \ |
@@ -28,18 +28,31 @@ static ssize_t show_##field(struct device *dev, \ | |||
28 | actconfig = udev->actconfig; \ | 28 | actconfig = udev->actconfig; \ |
29 | if (actconfig) \ | 29 | if (actconfig) \ |
30 | return sprintf(buf, format_string, \ | 30 | return sprintf(buf, format_string, \ |
31 | actconfig->desc.field * multiplier); \ | 31 | actconfig->desc.field); \ |
32 | else \ | 32 | else \ |
33 | return 0; \ | 33 | return 0; \ |
34 | } \ | 34 | } \ |
35 | 35 | ||
36 | #define usb_actconfig_attr(field, multiplier, format_string) \ | 36 | #define usb_actconfig_attr(field, format_string) \ |
37 | usb_actconfig_show(field, multiplier, format_string) \ | 37 | usb_actconfig_show(field, format_string) \ |
38 | static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); | 38 | static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); |
39 | |||
40 | usb_actconfig_attr(bNumInterfaces, "%2d\n") | ||
41 | usb_actconfig_attr(bmAttributes, "%2x\n") | ||
39 | 42 | ||
40 | usb_actconfig_attr(bNumInterfaces, 1, "%2d\n") | 43 | static ssize_t show_bMaxPower(struct device *dev, |
41 | usb_actconfig_attr(bmAttributes, 1, "%2x\n") | 44 | struct device_attribute *attr, char *buf) |
42 | usb_actconfig_attr(bMaxPower, 2, "%3dmA\n") | 45 | { |
46 | struct usb_device *udev; | ||
47 | struct usb_host_config *actconfig; | ||
48 | |||
49 | udev = to_usb_device(dev); | ||
50 | actconfig = udev->actconfig; | ||
51 | if (!actconfig) | ||
52 | return 0; | ||
53 | return sprintf(buf, "%dmA\n", usb_get_max_power(udev, actconfig)); | ||
54 | } | ||
55 | static DEVICE_ATTR(bMaxPower, S_IRUGO, show_bMaxPower, NULL); | ||
43 | 56 | ||
44 | static ssize_t show_configuration_string(struct device *dev, | 57 | static ssize_t show_configuration_string(struct device *dev, |
45 | struct device_attribute *attr, char *buf) | 58 | struct device_attribute *attr, char *buf) |
@@ -56,7 +69,7 @@ static ssize_t show_configuration_string(struct device *dev, | |||
56 | static DEVICE_ATTR(configuration, S_IRUGO, show_configuration_string, NULL); | 69 | static DEVICE_ATTR(configuration, S_IRUGO, show_configuration_string, NULL); |
57 | 70 | ||
58 | /* configuration value is always present, and r/w */ | 71 | /* configuration value is always present, and r/w */ |
59 | usb_actconfig_show(bConfigurationValue, 1, "%u\n"); | 72 | usb_actconfig_show(bConfigurationValue, "%u\n"); |
60 | 73 | ||
61 | static ssize_t | 74 | static ssize_t |
62 | set_bConfigurationValue(struct device *dev, struct device_attribute *attr, | 75 | set_bConfigurationValue(struct device *dev, struct device_attribute *attr, |