aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/core/sysfs.c')
-rw-r--r--drivers/usb/core/sysfs.c98
1 files changed, 49 insertions, 49 deletions
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 55d8f575206d..4eaa0ee8e72f 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -16,16 +16,16 @@
16 16
17/* Active configuration fields */ 17/* Active configuration fields */
18#define usb_actconfig_show(field, multiplier, format_string) \ 18#define usb_actconfig_show(field, multiplier, format_string) \
19static ssize_t show_##field (struct device *dev, \ 19static ssize_t show_##field(struct device *dev, \
20 struct device_attribute *attr, char *buf) \ 20 struct device_attribute *attr, char *buf) \
21{ \ 21{ \
22 struct usb_device *udev; \ 22 struct usb_device *udev; \
23 struct usb_host_config *actconfig; \ 23 struct usb_host_config *actconfig; \
24 \ 24 \
25 udev = to_usb_device (dev); \ 25 udev = to_usb_device(dev); \
26 actconfig = udev->actconfig; \ 26 actconfig = udev->actconfig; \
27 if (actconfig) \ 27 if (actconfig) \
28 return sprintf (buf, format_string, \ 28 return sprintf(buf, format_string, \
29 actconfig->desc.field * multiplier); \ 29 actconfig->desc.field * multiplier); \
30 else \ 30 else \
31 return 0; \ 31 return 0; \
@@ -35,9 +35,9 @@ static ssize_t show_##field (struct device *dev, \
35usb_actconfig_show(field, multiplier, format_string) \ 35usb_actconfig_show(field, multiplier, format_string) \
36static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); 36static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
37 37
38usb_actconfig_attr (bNumInterfaces, 1, "%2d\n") 38usb_actconfig_attr(bNumInterfaces, 1, "%2d\n")
39usb_actconfig_attr (bmAttributes, 1, "%2x\n") 39usb_actconfig_attr(bmAttributes, 1, "%2x\n")
40usb_actconfig_attr (bMaxPower, 2, "%3dmA\n") 40usb_actconfig_attr(bMaxPower, 2, "%3dmA\n")
41 41
42static ssize_t show_configuration_string(struct device *dev, 42static ssize_t show_configuration_string(struct device *dev,
43 struct device_attribute *attr, char *buf) 43 struct device_attribute *attr, char *buf)
@@ -45,7 +45,7 @@ static ssize_t show_configuration_string(struct device *dev,
45 struct usb_device *udev; 45 struct usb_device *udev;
46 struct usb_host_config *actconfig; 46 struct usb_host_config *actconfig;
47 47
48 udev = to_usb_device (dev); 48 udev = to_usb_device(dev);
49 actconfig = udev->actconfig; 49 actconfig = udev->actconfig;
50 if ((!actconfig) || (!actconfig->string)) 50 if ((!actconfig) || (!actconfig->string))
51 return 0; 51 return 0;
@@ -57,16 +57,16 @@ static DEVICE_ATTR(configuration, S_IRUGO, show_configuration_string, NULL);
57usb_actconfig_show(bConfigurationValue, 1, "%u\n"); 57usb_actconfig_show(bConfigurationValue, 1, "%u\n");
58 58
59static ssize_t 59static ssize_t
60set_bConfigurationValue (struct device *dev, struct device_attribute *attr, 60set_bConfigurationValue(struct device *dev, struct device_attribute *attr,
61 const char *buf, size_t count) 61 const char *buf, size_t count)
62{ 62{
63 struct usb_device *udev = to_usb_device (dev); 63 struct usb_device *udev = to_usb_device(dev);
64 int config, value; 64 int config, value;
65 65
66 if (sscanf (buf, "%u", &config) != 1 || config > 255) 66 if (sscanf(buf, "%u", &config) != 1 || config > 255)
67 return -EINVAL; 67 return -EINVAL;
68 usb_lock_device(udev); 68 usb_lock_device(udev);
69 value = usb_set_configuration (udev, config); 69 value = usb_set_configuration(udev, config);
70 usb_unlock_device(udev); 70 usb_unlock_device(udev);
71 return (value < 0) ? value : count; 71 return (value < 0) ? value : count;
72} 72}
@@ -81,7 +81,7 @@ static ssize_t show_##name(struct device *dev, \
81{ \ 81{ \
82 struct usb_device *udev; \ 82 struct usb_device *udev; \
83 \ 83 \
84 udev = to_usb_device (dev); \ 84 udev = to_usb_device(dev); \
85 return sprintf(buf, "%s\n", udev->name); \ 85 return sprintf(buf, "%s\n", udev->name); \
86} \ 86} \
87static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); 87static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
@@ -91,12 +91,12 @@ usb_string_attr(manufacturer);
91usb_string_attr(serial); 91usb_string_attr(serial);
92 92
93static ssize_t 93static ssize_t
94show_speed (struct device *dev, struct device_attribute *attr, char *buf) 94show_speed(struct device *dev, struct device_attribute *attr, char *buf)
95{ 95{
96 struct usb_device *udev; 96 struct usb_device *udev;
97 char *speed; 97 char *speed;
98 98
99 udev = to_usb_device (dev); 99 udev = to_usb_device(dev);
100 100
101 switch (udev->speed) { 101 switch (udev->speed) {
102 case USB_SPEED_LOW: 102 case USB_SPEED_LOW:
@@ -112,22 +112,22 @@ show_speed (struct device *dev, struct device_attribute *attr, char *buf)
112 default: 112 default:
113 speed = "unknown"; 113 speed = "unknown";
114 } 114 }
115 return sprintf (buf, "%s\n", speed); 115 return sprintf(buf, "%s\n", speed);
116} 116}
117static DEVICE_ATTR(speed, S_IRUGO, show_speed, NULL); 117static DEVICE_ATTR(speed, S_IRUGO, show_speed, NULL);
118 118
119static ssize_t 119static ssize_t
120show_devnum (struct device *dev, struct device_attribute *attr, char *buf) 120show_devnum(struct device *dev, struct device_attribute *attr, char *buf)
121{ 121{
122 struct usb_device *udev; 122 struct usb_device *udev;
123 123
124 udev = to_usb_device (dev); 124 udev = to_usb_device(dev);
125 return sprintf (buf, "%d\n", udev->devnum); 125 return sprintf(buf, "%d\n", udev->devnum);
126} 126}
127static DEVICE_ATTR(devnum, S_IRUGO, show_devnum, NULL); 127static DEVICE_ATTR(devnum, S_IRUGO, show_devnum, NULL);
128 128
129static ssize_t 129static ssize_t
130show_version (struct device *dev, struct device_attribute *attr, char *buf) 130show_version(struct device *dev, struct device_attribute *attr, char *buf)
131{ 131{
132 struct usb_device *udev; 132 struct usb_device *udev;
133 u16 bcdUSB; 133 u16 bcdUSB;
@@ -139,25 +139,25 @@ show_version (struct device *dev, struct device_attribute *attr, char *buf)
139static DEVICE_ATTR(version, S_IRUGO, show_version, NULL); 139static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
140 140
141static ssize_t 141static ssize_t
142show_maxchild (struct device *dev, struct device_attribute *attr, char *buf) 142show_maxchild(struct device *dev, struct device_attribute *attr, char *buf)
143{ 143{
144 struct usb_device *udev; 144 struct usb_device *udev;
145 145
146 udev = to_usb_device (dev); 146 udev = to_usb_device(dev);
147 return sprintf (buf, "%d\n", udev->maxchild); 147 return sprintf(buf, "%d\n", udev->maxchild);
148} 148}
149static DEVICE_ATTR(maxchild, S_IRUGO, show_maxchild, NULL); 149static DEVICE_ATTR(maxchild, S_IRUGO, show_maxchild, NULL);
150 150
151/* Descriptor fields */ 151/* Descriptor fields */
152#define usb_descriptor_attr_le16(field, format_string) \ 152#define usb_descriptor_attr_le16(field, format_string) \
153static ssize_t \ 153static ssize_t \
154show_##field (struct device *dev, struct device_attribute *attr, \ 154show_##field(struct device *dev, struct device_attribute *attr, \
155 char *buf) \ 155 char *buf) \
156{ \ 156{ \
157 struct usb_device *udev; \ 157 struct usb_device *udev; \
158 \ 158 \
159 udev = to_usb_device (dev); \ 159 udev = to_usb_device(dev); \
160 return sprintf (buf, format_string, \ 160 return sprintf(buf, format_string, \
161 le16_to_cpu(udev->descriptor.field)); \ 161 le16_to_cpu(udev->descriptor.field)); \
162} \ 162} \
163static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); 163static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
@@ -168,21 +168,21 @@ usb_descriptor_attr_le16(bcdDevice, "%04x\n")
168 168
169#define usb_descriptor_attr(field, format_string) \ 169#define usb_descriptor_attr(field, format_string) \
170static ssize_t \ 170static ssize_t \
171show_##field (struct device *dev, struct device_attribute *attr, \ 171show_##field(struct device *dev, struct device_attribute *attr, \
172 char *buf) \ 172 char *buf) \
173{ \ 173{ \
174 struct usb_device *udev; \ 174 struct usb_device *udev; \
175 \ 175 \
176 udev = to_usb_device (dev); \ 176 udev = to_usb_device(dev); \
177 return sprintf (buf, format_string, udev->descriptor.field); \ 177 return sprintf(buf, format_string, udev->descriptor.field); \
178} \ 178} \
179static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); 179static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
180 180
181usb_descriptor_attr (bDeviceClass, "%02x\n") 181usb_descriptor_attr(bDeviceClass, "%02x\n")
182usb_descriptor_attr (bDeviceSubClass, "%02x\n") 182usb_descriptor_attr(bDeviceSubClass, "%02x\n")
183usb_descriptor_attr (bDeviceProtocol, "%02x\n") 183usb_descriptor_attr(bDeviceProtocol, "%02x\n")
184usb_descriptor_attr (bNumConfigurations, "%d\n") 184usb_descriptor_attr(bNumConfigurations, "%d\n")
185usb_descriptor_attr (bMaxPacketSize0, "%d\n") 185usb_descriptor_attr(bMaxPacketSize0, "%d\n")
186 186
187static struct attribute *dev_attrs[] = { 187static struct attribute *dev_attrs[] = {
188 /* current configuration's attributes */ 188 /* current configuration's attributes */
@@ -220,17 +220,17 @@ int usb_create_sysfs_dev_files(struct usb_device *udev)
220 return retval; 220 return retval;
221 221
222 if (udev->manufacturer) { 222 if (udev->manufacturer) {
223 retval = device_create_file (dev, &dev_attr_manufacturer); 223 retval = device_create_file(dev, &dev_attr_manufacturer);
224 if (retval) 224 if (retval)
225 goto error; 225 goto error;
226 } 226 }
227 if (udev->product) { 227 if (udev->product) {
228 retval = device_create_file (dev, &dev_attr_product); 228 retval = device_create_file(dev, &dev_attr_product);
229 if (retval) 229 if (retval)
230 goto error; 230 goto error;
231 } 231 }
232 if (udev->serial) { 232 if (udev->serial) {
233 retval = device_create_file (dev, &dev_attr_serial); 233 retval = device_create_file(dev, &dev_attr_serial);
234 if (retval) 234 if (retval)
235 goto error; 235 goto error;
236 } 236 }
@@ -246,7 +246,7 @@ error:
246 return retval; 246 return retval;
247} 247}
248 248
249void usb_remove_sysfs_dev_files (struct usb_device *udev) 249void usb_remove_sysfs_dev_files(struct usb_device *udev)
250{ 250{
251 struct device *dev = &udev->dev; 251 struct device *dev = &udev->dev;
252 252
@@ -264,22 +264,22 @@ void usb_remove_sysfs_dev_files (struct usb_device *udev)
264/* Interface fields */ 264/* Interface fields */
265#define usb_intf_attr(field, format_string) \ 265#define usb_intf_attr(field, format_string) \
266static ssize_t \ 266static ssize_t \
267show_##field (struct device *dev, struct device_attribute *attr, \ 267show_##field(struct device *dev, struct device_attribute *attr, \
268 char *buf) \ 268 char *buf) \
269{ \ 269{ \
270 struct usb_interface *intf = to_usb_interface (dev); \ 270 struct usb_interface *intf = to_usb_interface(dev); \
271 \ 271 \
272 return sprintf (buf, format_string, \ 272 return sprintf(buf, format_string, \
273 intf->cur_altsetting->desc.field); \ 273 intf->cur_altsetting->desc.field); \
274} \ 274} \
275static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); 275static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
276 276
277usb_intf_attr (bInterfaceNumber, "%02x\n") 277usb_intf_attr(bInterfaceNumber, "%02x\n")
278usb_intf_attr (bAlternateSetting, "%2d\n") 278usb_intf_attr(bAlternateSetting, "%2d\n")
279usb_intf_attr (bNumEndpoints, "%02x\n") 279usb_intf_attr(bNumEndpoints, "%02x\n")
280usb_intf_attr (bInterfaceClass, "%02x\n") 280usb_intf_attr(bInterfaceClass, "%02x\n")
281usb_intf_attr (bInterfaceSubClass, "%02x\n") 281usb_intf_attr(bInterfaceSubClass, "%02x\n")
282usb_intf_attr (bInterfaceProtocol, "%02x\n") 282usb_intf_attr(bInterfaceProtocol, "%02x\n")
283 283
284static ssize_t show_interface_string(struct device *dev, 284static ssize_t show_interface_string(struct device *dev,
285 struct device_attribute *attr, char *buf) 285 struct device_attribute *attr, char *buf)
@@ -288,8 +288,8 @@ static ssize_t show_interface_string(struct device *dev,
288 struct usb_device *udev; 288 struct usb_device *udev;
289 int len; 289 int len;
290 290
291 intf = to_usb_interface (dev); 291 intf = to_usb_interface(dev);
292 udev = interface_to_usbdev (intf); 292 udev = interface_to_usbdev(intf);
293 len = snprintf(buf, 256, "%s", intf->cur_altsetting->string); 293 len = snprintf(buf, 256, "%s", intf->cur_altsetting->string);
294 if (len < 0) 294 if (len < 0)
295 return 0; 295 return 0;
@@ -384,7 +384,7 @@ error:
384 return retval; 384 return retval;
385} 385}
386 386
387void usb_remove_sysfs_intf_files (struct usb_interface *intf) 387void usb_remove_sysfs_intf_files(struct usb_interface *intf)
388{ 388{
389 usb_remove_intf_ep_files(intf); 389 usb_remove_intf_ep_files(intf);
390 sysfs_remove_group(&intf->dev.kobj, &intf_attr_grp); 390 sysfs_remove_group(&intf->dev.kobj, &intf_attr_grp);