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.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index c783cb11184..5e1f5d55bf0 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -588,35 +588,33 @@ read_descriptors(struct kobject *kobj, struct bin_attribute *attr,
588 container_of(kobj, struct device, kobj)); 588 container_of(kobj, struct device, kobj));
589 size_t nleft = count; 589 size_t nleft = count;
590 size_t srclen, n; 590 size_t srclen, n;
591 int cfgno;
592 void *src;
591 593
592 usb_lock_device(udev); 594 /* The binary attribute begins with the device descriptor.
593 595 * Following that are the raw descriptor entries for all the
594 /* The binary attribute begins with the device descriptor */ 596 * configurations (config plus subsidiary descriptors).
595 srclen = sizeof(struct usb_device_descriptor);
596 if (off < srclen) {
597 n = min_t(size_t, nleft, srclen - off);
598 memcpy(buf, off + (char *) &udev->descriptor, n);
599 nleft -= n;
600 buf += n;
601 off = 0;
602 } else {
603 off -= srclen;
604 }
605
606 /* Then follows the raw descriptor entry for the current
607 * configuration (config plus subsidiary descriptors).
608 */ 597 */
609 if (udev->actconfig) { 598 for (cfgno = -1; cfgno < udev->descriptor.bNumConfigurations &&
610 int cfgno = udev->actconfig - udev->config; 599 nleft > 0; ++cfgno) {
611 600 if (cfgno < 0) {
612 srclen = __le16_to_cpu(udev->actconfig->desc.wTotalLength); 601 src = &udev->descriptor;
602 srclen = sizeof(struct usb_device_descriptor);
603 } else {
604 src = udev->rawdescriptors[cfgno];
605 srclen = __le16_to_cpu(udev->config[cfgno].desc.
606 wTotalLength);
607 }
613 if (off < srclen) { 608 if (off < srclen) {
614 n = min_t(size_t, nleft, srclen - off); 609 n = min(nleft, srclen - (size_t) off);
615 memcpy(buf, off + udev->rawdescriptors[cfgno], n); 610 memcpy(buf, src + off, n);
616 nleft -= n; 611 nleft -= n;
612 buf += n;
613 off = 0;
614 } else {
615 off -= srclen;
617 } 616 }
618 } 617 }
619 usb_unlock_device(udev);
620 return count - nleft; 618 return count - nleft;
621} 619}
622 620