Hi,
This patch does:
- remove the semaphore from interrupt handler (semaphore are not allowed
under ints). And no locking is necessary currently.
- fixes a problem with MOD_INC_USE_COUNT / MOD_DEC_USE_COUNT in
open_scanner()
- fixes a race in probe_scanner()
- adds two missing "up(&scn_mutex)" in probe_scanner().
The patch has been tested.
Please consider and apply.
Regards,
Frank.
--- scanner.c.org Wed Nov 21 22:49:47 2001
+++ scanner.c Thu Nov 22 00:29:55 2001
@@ -324,17 +324,16 @@
struct scn_usb_data *scn;
unsigned char *data;
scn = urb->context;
- down(&(scn->sem));
+
data = &scn->button;
data += 0; /* Keep gcc from complaining about unused var */
if (urb->status) {
- up(&(scn->sem));
return;
}
dbg("irq_scanner(%d): data:%x", scn->scn_minor, *data);
- up(&(scn->sem));
+
return;
}
@@ -357,9 +356,9 @@
dbg("open_scanner: scn_minor:%d", scn_minor);
if (!p_scn_table[scn_minor]) {
- up(&scn_mutex);
err("open_scanner(%d): Unable to access minor data", scn_minor);
- return -ENODEV;
+ err = -ENODEV;
+ goto out_error;
}
scn = p_scn_table[scn_minor];
@@ -939,6 +938,7 @@
/* Check to make sure that the last slot isn't already taken */
if (p_scn_table[scn_minor]) {
err("probe_scanner: No more minor devices remaining.");
+ up(&scn_mutex);
return NULL;
}
@@ -946,6 +946,7 @@
if (!(scn = kmalloc (sizeof (struct scn_usb_data), GFP_KERNEL))) {
err("probe_scanner: Out of memory.");
+ up(&scn_mutex);
return NULL;
}
memset (scn, 0, sizeof(struct scn_usb_data));
@@ -1028,9 +1029,11 @@
if (scn->devfs == NULL)
dbg("scanner%d: device node registration failed", scn_minor);
+ p_scn_table[scn_minor] = scn;
+
up(&scn_mutex);
- return p_scn_table[scn_minor] = scn;
+ return scn;
}
static void