diff options
author | ed <ed@FreeBSD.org> | 2009-06-28 20:52:11 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-06-28 20:52:11 +0000 |
commit | 66973f6d466a972e501c27cd4da24634b5f87f3e (patch) | |
tree | f3c26775eda9f8f7853ae44f2eac279d917e6da2 | |
parent | fda6c6ecf488a5884ac01ca2fae490c4f804319d (diff) | |
download | FreeBSD-src-66973f6d466a972e501c27cd4da24634b5f87f3e.zip FreeBSD-src-66973f6d466a972e501c27cd4da24634b5f87f3e.tar.gz |
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)
-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 e1b68d6..f3e3e91 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); } /* |