summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usb_util.c
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2013-02-10 10:56:13 +0000
committerhselasky <hselasky@FreeBSD.org>2013-02-10 10:56:13 +0000
commit07c18e4e92170f42c04651098b0a5e506e8f1efe (patch)
tree98239bf65cd74264d2ba911ccbce4a4b729fa56b /sys/dev/usb/usb_util.c
parent34ac6c9a18f820e4a7bbf72e956f09cf5c153a8b (diff)
downloadFreeBSD-src-07c18e4e92170f42c04651098b0a5e506e8f1efe.zip
FreeBSD-src-07c18e4e92170f42c04651098b0a5e506e8f1efe.tar.gz
- Move scratch data from the USB bus structure to the USB device structure
so that simultaneous access cannot happen. Protect scratch area using the enumeration lock. Also reduce stack usage in usbd_transfer_setup() by moving some big stack members to the scratch area. This saves around 200 bytes of stack. - Fix a whitespace. MFC after: 1 week
Diffstat (limited to 'sys/dev/usb/usb_util.c')
-rw-r--r--sys/dev/usb/usb_util.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/sys/dev/usb/usb_util.c b/sys/dev/usb/usb_util.c
index f9fec76..ffd005b 100644
--- a/sys/dev/usb/usb_util.c
+++ b/sys/dev/usb/usb_util.c
@@ -75,6 +75,7 @@ device_set_usb_desc(device_t dev)
struct usb_interface *iface;
char *temp_p;
usb_error_t err;
+ uint8_t do_unlock;
if (dev == NULL) {
/* should not happen */
@@ -96,19 +97,26 @@ device_set_usb_desc(device_t dev)
err = 0;
}
- temp_p = (char *)udev->bus->scratch[0].data;
+ /* Protect scratch area */
+ do_unlock = usbd_enum_lock(udev);
- if (!err) {
+ temp_p = (char *)udev->scratch.data;
+
+ if (err == 0) {
/* try to get the interface string ! */
- err = usbd_req_get_string_any
- (udev, NULL, temp_p,
- sizeof(udev->bus->scratch), iface->idesc->iInterface);
+ err = usbd_req_get_string_any(udev, NULL, temp_p,
+ sizeof(udev->scratch.data),
+ iface->idesc->iInterface);
}
- if (err) {
+ if (err != 0) {
/* use default description */
usb_devinfo(udev, temp_p,
- sizeof(udev->bus->scratch));
+ sizeof(udev->scratch.data));
}
+
+ if (do_unlock)
+ usbd_enum_unlock(udev);
+
device_set_desc_copy(dev, temp_p);
device_printf(dev, "<%s> on %s\n", temp_p,
device_get_nameunit(udev->bus->bdev));
OpenPOWER on IntegriCloud