diff options
author | Ed Schouten <ed@FreeBSD.org> | 2009-06-28 20:52:11 +0000 |
---|---|---|
committer | Ed Schouten <ed@FreeBSD.org> | 2009-06-28 20:52:11 +0000 |
commit | f551adb0a94b0e9a6221b4c26b2e29e18321fc8c (patch) | |
tree | f3c26775eda9f8f7853ae44f2eac279d917e6da2 /sys/dev/usb | |
parent | f9bb1cf0100fcbf2c05e69f6648d9bbd10196ddc (diff) |
Don't pick up Giant inside ucom(4).
Giant was only used here to lock down a bit mask of allocated unit
numbers. Change the code to use its own mutex.
Reviewed by: hselasky
Approved by: re (kib)
Notes
Notes:
svn path=/head/; revision=195146
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/serial/usb_serial.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/dev/usb/serial/usb_serial.c b/sys/dev/usb/serial/usb_serial.c index e1b68d69d4f8..f3e3e91adde7 100644 --- a/sys/dev/usb/serial/usb_serial.c +++ b/sys/dev/usb/serial/usb_serial.c @@ -151,6 +151,8 @@ MODULE_VERSION(ucom, 1); #define UCOM_SUB_UNIT_MAX 0x100 /* exclusive */ static uint8_t ucom_bitmap[(UCOM_UNIT_MAX + 7) / 8]; +static struct mtx ucom_bitmap_mtx; +MTX_SYSINIT(ucom_bitmap_mtx, &ucom_bitmap_mtx, "ucom bitmap", MTX_DEF); static uint8_t ucom_units_alloc(uint32_t sub_units, uint32_t *p_root_unit) @@ -161,7 +163,7 @@ ucom_units_alloc(uint32_t sub_units, uint32_t *p_root_unit) uint32_t max = UCOM_UNIT_MAX - (UCOM_UNIT_MAX % sub_units); uint8_t error = 1; - mtx_lock(&Giant); + mtx_lock(&ucom_bitmap_mtx); for (n = 0; n < max; n += sub_units) { @@ -192,7 +194,7 @@ ucom_units_alloc(uint32_t sub_units, uint32_t *p_root_unit) skip: ; } - mtx_unlock(&Giant); + mtx_unlock(&ucom_bitmap_mtx); /* * Always set the variable pointed to by "p_root_unit" so that @@ -208,14 +210,14 @@ ucom_units_free(uint32_t root_unit, uint32_t sub_units) { uint32_t x; - mtx_lock(&Giant); + mtx_lock(&ucom_bitmap_mtx); while (sub_units--) { x = root_unit + sub_units; ucom_bitmap[x / 8] &= ~(1 << (x % 8)); } - mtx_unlock(&Giant); + mtx_unlock(&ucom_bitmap_mtx); } /* |