aboutsummaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usb_generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb/usb_generic.c')
-rw-r--r--sys/dev/usb/usb_generic.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c
index dc796dc09a99..f5014f61b667 100644
--- a/sys/dev/usb/usb_generic.c
+++ b/sys/dev/usb/usb_generic.c
@@ -706,16 +706,16 @@ ugen_get_cdesc(struct usb_fifo *f, struct usb_gen_descriptor *ugd)
return (error);
}
-/*
- * This function is called having the enumeration SX locked which
- * protects the scratch area used.
- */
static int
ugen_get_sdesc(struct usb_fifo *f, struct usb_gen_descriptor *ugd)
{
void *ptr;
uint16_t size;
int error;
+ uint8_t do_unlock;
+
+ /* Protect scratch area */
+ do_unlock = usbd_ctrl_lock(f->udev);
ptr = f->udev->scratch.data;
size = sizeof(f->udev->scratch.data);
@@ -736,6 +736,9 @@ ugen_get_sdesc(struct usb_fifo *f, struct usb_gen_descriptor *ugd)
error = copyout(ptr, ugd->ugd_data, size);
}
+ if (do_unlock)
+ usbd_ctrl_unlock(f->udev);
+
return (error);
}