From 6f6d24004abb33e7084002ca3e9999ae74f16b51 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 23 Nov 2007 15:38:58 -0500 Subject: [PATCH] Linux 2.4.0-test9pre4 - continued SCSI cleanup - more USB updates --- arch/i386/kernel/bluesmoke.c | 4 +++- drivers/media/video/cpia_usb.c | 24 +++++++++++++++++------- drivers/pci/proc.c | 4 ++-- drivers/scsi/Makefile | 2 +- drivers/scsi/hosts.c | 8 ++++---- drivers/scsi/hosts.h | 1 - drivers/scsi/scsi.c | 42 ++++++++++++++++-------------------------- drivers/usb/hid.c | 6 ++++-- drivers/usb/microtek.c | 31 ++++++++++++++++++++++++++----- 9 files changed, 73 insertions(+), 49 deletions(-) diff --git a/arch/i386/kernel/bluesmoke.c b/arch/i386/kernel/bluesmoke.c index e81da405e..35738c5a0 100644 --- a/arch/i386/kernel/bluesmoke.c +++ b/arch/i386/kernel/bluesmoke.c @@ -37,7 +37,7 @@ void mcheck_fault(void) high&=~(1<<31); if(high&(1<<27)) { - rdmsr(0x402+i*4, alow, ahigh); + rdmsr(0x403+i*4, alow, ahigh); printk("[%08x%08x]", alow, ahigh); } if(high&(1<<26)) @@ -47,6 +47,8 @@ void mcheck_fault(void) high, low); } wrmsr(0x401+i*4, low, high); + /* Serialize */ + mb(); } } diff --git a/drivers/media/video/cpia_usb.c b/drivers/media/video/cpia_usb.c index fd216af2d..79687ebba 100644 --- a/drivers/media/video/cpia_usb.c +++ b/drivers/media/video/cpia_usb.c @@ -187,7 +187,7 @@ static int cpia_usb_open(void *privdata) if (ret < 0) { printk(KERN_ERR "cpia_usb_open: usb_set_interface error (ret = %d)\n", ret); retval = -EBUSY; - goto error_all; + goto error_1; } ucpia->buffers[0]->status = FRAME_EMPTY; @@ -204,7 +204,7 @@ static int cpia_usb_open(void *privdata) if (!urb) { printk(KERN_ERR "cpia_init_isoc: usb_alloc_urb 0\n"); retval = -ENOMEM; - goto error_all; + goto error_1; } ucpia->sbuf[0].urb = urb; @@ -223,9 +223,9 @@ static int cpia_usb_open(void *privdata) urb = usb_alloc_urb(FRAMES_PER_DESC); if (!urb) { - printk(KERN_ERR "cpia_init_isoc: usb_alloc_urb 0\n"); + printk(KERN_ERR "cpia_init_isoc: usb_alloc_urb 1\n"); retval = -ENOMEM; - goto error_all; + goto error_urb0; } ucpia->sbuf[1].urb = urb; @@ -246,20 +246,30 @@ static int cpia_usb_open(void *privdata) ucpia->sbuf[0].urb->next = ucpia->sbuf[1].urb; err = usb_submit_urb(ucpia->sbuf[0].urb); - if (err) + if (err) { printk(KERN_ERR "cpia_init_isoc: usb_submit_urb 0 ret %d\n", err); + goto error_urb1; + } err = usb_submit_urb(ucpia->sbuf[1].urb); - if (err) + if (err) { printk(KERN_ERR "cpia_init_isoc: usb_submit_urb 1 ret %d\n", err); + goto error_urb1; + } ucpia->streaming = 1; ucpia->open = 1; return 0; -error_all: +error_urb1: /* free urb 1 */ + usb_free_urb(ucpia->sbuf[1].urb); + +error_urb0: /* free urb 0 */ + usb_free_urb(ucpia->sbuf[0].urb); + +error_1: kfree (ucpia->sbuf[1].data); error_0: kfree (ucpia->sbuf[0].data); diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 2a517f7d6..81902c572 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -46,8 +46,8 @@ proc_bus_pci_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos) const struct inode *ino = file->f_dentry->d_inode; const struct proc_dir_entry *dp = ino->u.generic_ip; struct pci_dev *dev = dp->data; - int pos = *ppos; - int cnt, size; + unsigned int pos = *ppos; + unsigned int cnt, size; /* * Normal users can read only the standardized portion of the diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 1095843c0..586da6169 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -137,7 +137,7 @@ obj-m := $(filter-out $(obj-y), $(obj-m)) int-m := $(filter-out $(int-y), $(int-m)) # Take multi-part drivers out of obj-y and put components in. -# obj-y := $(filter-out $(list-multi), $(obj-y)) $(int-y) +obj-y := $(filter-out $(list-multi), $(obj-y)) $(int-y) O_OBJS := $(filter-out $(export-objs), $(obj-y)) OX_OBJS := $(filter $(export-objs), $(obj-y)) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index c9a1b691e..1d0678714 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -147,12 +147,12 @@ struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){ hname = (tpnt->proc_name) ? tpnt->proc_name : ""; hname_len = strlen(hname); for (shn = scsi_host_no_list;shn;shn = shn->next) { - if (!(shn->host_registered) && shn->loaded_as_module && + if (!(shn->host_registered) && (hname_len > 0) && (0 == strncmp(hname, shn->name, hname_len))) { flag_new = 0; retval->host_no = shn->host_no; shn->host_registered = 1; - shn->loaded_as_module = scsi_loadable_module_flag; + shn->loaded_as_module = 1; break; } } @@ -161,7 +161,7 @@ struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){ retval->host_failed = 0; if(j > 0xffff) panic("Too many extra bytes requested\n"); retval->extra_bytes = j; - retval->loaded_as_module = scsi_loadable_module_flag; + retval->loaded_as_module = 1; if (flag_new) { shn = (Scsi_Host_Name *) kmalloc(sizeof(Scsi_Host_Name), GFP_ATOMIC); shn->name = kmalloc(hname_len + 1, GFP_ATOMIC); @@ -170,7 +170,7 @@ struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){ shn->name[hname_len] = 0; shn->host_no = max_scsi_hosts++; shn->host_registered = 1; - shn->loaded_as_module = scsi_loadable_module_flag; + shn->loaded_as_module = 1; shn->next = NULL; if (scsi_host_no_list) { for (shn2 = scsi_host_no_list;shn2->next;shn2 = shn2->next) diff --git a/drivers/scsi/hosts.h b/drivers/scsi/hosts.h index 8fa4b4711..7d107541e 100644 --- a/drivers/scsi/hosts.h +++ b/drivers/scsi/hosts.h @@ -459,7 +459,6 @@ extern void build_proc_dir_entries(Scsi_Host_Template *); extern int next_scsi_host; -extern int scsi_loadable_module_flag; unsigned int scsi_init(void); extern struct Scsi_Host * scsi_register(Scsi_Host_Template *, int j); extern void scsi_unregister(struct Scsi_Host * i); diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index e1ad9084f..c7b9c37b1 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -1375,8 +1375,6 @@ void scsi_finish_command(Scsi_Cmnd * SCpnt) static int scsi_register_host(Scsi_Host_Template *); static void scsi_unregister_host(Scsi_Host_Template *); -int scsi_loadable_module_flag; /* Set after we scan builtin drivers */ - /* * Function: scsi_release_commandblocks() * @@ -1440,10 +1438,9 @@ void scsi_build_commandblocks(Scsi_Device * SDpnt) kmalloc(sizeof(Scsi_Cmnd), GFP_ATOMIC | (host->unchecked_isa_dma ? GFP_DMA : 0)); - memset(SCpnt, 0, sizeof(Scsi_Cmnd)); if (NULL == SCpnt) break; /* If not, the next line will oops ... */ - memset(&SCpnt->eh_timeout, 0, sizeof(SCpnt->eh_timeout)); + memset(SCpnt, 0, sizeof(Scsi_Cmnd)); SCpnt->host = host; SCpnt->device = SDpnt; SCpnt->target = SDpnt->id; @@ -1978,8 +1975,6 @@ static void scsi_unregister_host(Scsi_Host_Template * tpnt) struct Scsi_Device_Template *sdtpnt; struct Scsi_Host *sh1; struct Scsi_Host *shpnt; - Scsi_Host_Template *SHT; - Scsi_Host_Template *SHTp; char name[10]; /* host_no>=10^9? I don't think so. */ /* @@ -2115,7 +2110,7 @@ static void scsi_unregister_host(Scsi_Host_Template * tpnt) for (shpnt = scsi_hostlist; shpnt; shpnt = sh1) { sh1 = shpnt->next; - if (shpnt->hostt != tpnt || !shpnt->loaded_as_module) + if (shpnt->hostt != tpnt) continue; pcount = next_scsi_host; /* Remove the /proc/scsi directory entry */ @@ -2129,7 +2124,7 @@ static void scsi_unregister_host(Scsi_Host_Template * tpnt) * written host adapters. */ if (shpnt->irq) - free_irq(shpnt->irq, NULL); + free_irq(shpnt->irq, NULL); if (shpnt->dma_channel != 0xff) free_dma(shpnt->dma_channel); if (shpnt->io_port && shpnt->n_io_port) @@ -2158,24 +2153,21 @@ static void scsi_unregister_host(Scsi_Host_Template * tpnt) (scsi_memory_upper_value - scsi_init_memory_start) / 1024); #endif - /* There were some hosts that were loaded at boot time, so we cannot - do any more than this */ - if (tpnt->present) - return; + /* Remove it from the linked list and /proc */ + if (tpnt->present) { + Scsi_Host_Template **SHTp = &scsi_hosts; + Scsi_Host_Template *SHT; - /* OK, this is the very last step. Remove this host adapter from the - linked list. */ - for (SHTp = NULL, SHT = scsi_hosts; SHT; SHTp = SHT, SHT = SHT->next) - if (SHT == tpnt) { - if (SHTp) - SHTp->next = SHT->next; - else - scsi_hosts = SHT->next; - SHT->next = NULL; - break; + while ((SHT = *SHTp) != NULL) { + if (SHT == tpnt) { + *SHTp = SHT->next; + break; + } + SHTp = &SHT->next; } - /* Rebuild the /proc/scsi directory entries */ - remove_proc_entry(tpnt->proc_name, proc_scsi); + /* Rebuild the /proc/scsi directory entries */ + remove_proc_entry(tpnt->proc_name, proc_scsi); + } MOD_DEC_USE_COUNT; } @@ -2514,8 +2506,6 @@ static int __init init_scsi(void) generic->write_proc = proc_scsi_gen_write; #endif - scsi_loadable_module_flag = 1; - scsi_devfs_handle = devfs_mk_dir (NULL, "scsi", NULL); scsi_host_no_init (scsihosts); /* diff --git a/drivers/usb/hid.c b/drivers/usb/hid.c index 189cbbdfc..6339ba6f1 100644 --- a/drivers/usb/hid.c +++ b/drivers/usb/hid.c @@ -1,5 +1,5 @@ /* - * $Id: hid.c,v 1.14 2000/08/14 21:05:26 vojtech Exp $ + * $Id: hid.c,v 1.16 2000/09/18 21:38:55 vojtech Exp $ * * Copyright (c) 1999 Andreas Gal * Copyright (c) 2000 Vojtech Pavlik @@ -924,6 +924,8 @@ static void hid_configure_usage(struct hid_device *device, struct hid_field *fie usage->code = find_next_zero_bit(bit, max + 1, usage->code); } + if (usage->code > max) return; + if (usage->type == EV_ABS) { int a = field->logical_minimum; int b = field->logical_maximum; @@ -936,7 +938,7 @@ static void hid_configure_usage(struct hid_device *device, struct hid_field *fie if (usage->hat) { int i; - for (i = usage->code; i < usage->code + 2; i++) { + for (i = usage->code; i < usage->code + 2 && i <= max; i++) { input->absmax[i] = 1; input->absmin[i] = -1; input->absfuzz[i] = 0; diff --git a/drivers/usb/microtek.c b/drivers/usb/microtek.c index fdfe5f379..ab37860cd 100644 --- a/drivers/usb/microtek.c +++ b/drivers/usb/microtek.c @@ -98,10 +98,12 @@ * 20000603 Version 0.2.1 * 20000620 minor cosmetic changes * 20000620 Version 0.2.2 - * 20000822 Hopefully fixed deadlock in mts_remove_nolock() - * 20000822 Fixed minor race in mts_transfer_cleanup() - * 20000822 Fixed deadlock on submission error in queuecommand - * 20000822 Version 0.2.3 + * 20000822 Hopefully fixed deadlock in mts_remove_nolock() + * 20000822 Fixed minor race in mts_transfer_cleanup() + * 20000822 Fixed deadlock on submission error in queuecommand + * 20000822 Version 0.2.3 + * 20000913 Reduced module size if debugging is off + * 20000913 Version 0.2.4 */ #include @@ -151,7 +153,7 @@ static struct usb_driver mts_usb_driver = { /* Internal driver stuff */ -#define MTS_VERSION "0.2.3" +#define MTS_VERSION "0.2.4" #define MTS_NAME "microtek usb (rev " MTS_VERSION "): " #define MTS_WARNING(x...) \ @@ -198,6 +200,8 @@ static struct usb_driver mts_usb_driver = { MTS_DEBUG_INT();\ } while (0) +#ifdef MTS_DO_DEBUG + static inline void mts_debug_dump(struct mts_desc* desc) { MTS_DEBUG("desc at 0x%x: halted = %x%x, toggle = %x%x\n", (int)desc,(int)desc->usb_dev->halted[1],(int)desc->usb_dev->halted[0], @@ -293,6 +297,23 @@ static inline void mts_show_command(Scsi_Cmnd *srb) srb->cmnd[6], srb->cmnd[7], srb->cmnd[8], srb->cmnd[9]); } +#else + +static inline void mts_show_command(Scsi_Cmnd *srb) +{ + while (0) {} +} + +static inline void mts_debug_dump(struct mts_desc* desc) +{ + while (0) {} +} + +#endif + + + + static inline int mts_is_aborting(struct mts_desc* desc) { return (atomic_read(&desc->context.do_abort)); } -- 2.11.4.GIT