X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fscsi%2Faic7xxx_old.c;h=a6e7bb0d53f4a7becb3b6bbbb897af5ab8e20f79;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=993e2d6900a5d5e4df4fcf7538fe06d323f8d1ee;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c index 993e2d690..a6e7bb0d5 100644 --- a/drivers/scsi/aic7xxx_old.c +++ b/drivers/scsi/aic7xxx_old.c @@ -224,7 +224,6 @@ #include #include #include -#include #include #include #include @@ -239,7 +238,7 @@ #include #include #include "scsi.h" -#include "hosts.h" +#include #include "aic7xxx_old/aic7xxx.h" #include "aic7xxx_old/sequencer.h" @@ -254,9 +253,6 @@ #define AIC7XXX_C_VERSION "5.2.6" -#define NUMBER(arr) (sizeof(arr) / sizeof(arr[0])) -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#define MAX(a,b) (((a) > (b)) ? (a) : (b)) #define ALL_TARGETS -1 #define ALL_CHANNELS -1 #define ALL_LUNS -1 @@ -927,7 +923,7 @@ struct aic7xxx_host { volatile long flags; ahc_feature features; /* chip features */ unsigned long base; /* card base address */ - volatile unsigned char *maddr; /* memory mapped address */ + volatile unsigned char __iomem *maddr; /* memory mapped address */ unsigned long isr_count; /* Interrupt count */ unsigned long spurious_int; scb_data_type *scb_data; @@ -1236,7 +1232,7 @@ static int aic7xxx_seltime = 0x10; */ #ifdef MODULE static char * aic7xxx = NULL; -MODULE_PARM(aic7xxx, "s"); +module_param(aic7xxx, charp, 0); #endif #define VERBOSE_NORMAL 0x0000 @@ -1376,7 +1372,7 @@ aic7xxx_setup(char *s) while ((p = strsep(&s, ",.")) != NULL) { - for (i = 0; i < NUMBER(options); i++) + for (i = 0; i < ARRAY_SIZE(options); i++) { n = strlen(options[i].name); if (!strncmp(options[i].name, p, n)) @@ -1423,7 +1419,7 @@ aic7xxx_setup(char *s) else if (instance >= 0) instance++; if ( (device >= MAX_TARGETS) || - (instance >= NUMBER(aic7xxx_tag_info)) ) + (instance >= ARRAY_SIZE(aic7xxx_tag_info)) ) done = TRUE; tok++; if (!done) @@ -1447,7 +1443,7 @@ aic7xxx_setup(char *s) } } if ( (instance >= 0) && (device >= 0) && - (instance < NUMBER(aic7xxx_tag_info)) && + (instance < ARRAY_SIZE(aic7xxx_tag_info)) && (device < MAX_TARGETS) ) aic7xxx_tag_info[instance].tag_commands[device] = simple_strtoul(tok, NULL, 0) & 0xff; @@ -1658,7 +1654,7 @@ aic7xxx_download_instr(struct aic7xxx_host *p, int instrptr, { int end_addr; - end_addr = MIN(address, skip_addr); + end_addr = min_t(int, address, skip_addr); address_offset += end_addr - i; i = skip_addr; } @@ -1841,7 +1837,7 @@ aic7xxx_print_sequencer(struct aic7xxx_host *p, int downloaded) * Description: * Return a string describing the driver. *-F*************************************************************************/ -const char * +static const char * aic7xxx_info(struct Scsi_Host *dooh) { static char buffer[256]; @@ -1884,7 +1880,7 @@ aic7xxx_find_syncrate(struct aic7xxx_host *p, unsigned int *period, if(!(p->features & AHC_ULTRA3)) { *options = 0; - maxsync = MAX(maxsync, AHC_SYNCRATE_ULTRA2); + maxsync = max_t(unsigned int, maxsync, AHC_SYNCRATE_ULTRA2); } break; case MSG_EXT_PPR_OPTION_DT_CRC_QUICK: @@ -1892,7 +1888,7 @@ aic7xxx_find_syncrate(struct aic7xxx_host *p, unsigned int *period, if(!(p->features & AHC_ULTRA3)) { *options = 0; - maxsync = MAX(maxsync, AHC_SYNCRATE_ULTRA2); + maxsync = max_t(unsigned int, maxsync, AHC_SYNCRATE_ULTRA2); } else { @@ -1916,7 +1912,7 @@ aic7xxx_find_syncrate(struct aic7xxx_host *p, unsigned int *period, break; default: *options = 0; - maxsync = MAX(maxsync, AHC_SYNCRATE_ULTRA2); + maxsync = max_t(unsigned int, maxsync, AHC_SYNCRATE_ULTRA2); break; } syncrate = &aic7xxx_syncrates[maxsync]; @@ -2057,7 +2053,7 @@ aic7xxx_validate_offset(struct aic7xxx_host *p, else maxoffset = MAX_OFFSET_8BIT; } - *offset = MIN(*offset, maxoffset); + *offset = min(*offset, maxoffset); } /*+F************************************************************************* @@ -2570,7 +2566,7 @@ aic7xxx_allocate_scb(struct aic7xxx_host *p) break; } } - scb_count = MIN( (i-1), p->scb_data->maxscbs - p->scb_data->numscbs); + scb_count = min( (i-1), p->scb_data->maxscbs - p->scb_data->numscbs); scb_ap = (struct aic7xxx_scb *)kmalloc(sizeof (struct aic7xxx_scb) * scb_count + sizeof(struct aic7xxx_scb_dma), GFP_ATOMIC); if (scb_ap == NULL) @@ -4884,7 +4880,7 @@ aic7xxx_handle_seqint(struct aic7xxx_host *p, unsigned char intstat) } break; -#if AIC7XXX_NOT_YET +#ifdef AIC7XXX_NOT_YET case TRACEPOINT2: { printk(INFO_LEAD "Tracepoint #2 reached.\n", p->host_no, @@ -5042,7 +5038,7 @@ aic7xxx_parse_msg(struct aic7xxx_host *p, struct aic7xxx_scb *scb) if(p->user[tindex].offset) { aic_dev->needsdtr_copy = 1; - aic_dev->goal.period = MAX(10,p->user[tindex].period); + aic_dev->goal.period = max_t(unsigned char, 10,p->user[tindex].period); if(p->features & AHC_ULTRA2) { aic_dev->goal.offset = MAX_OFFSET_ULTRA2; @@ -5086,8 +5082,8 @@ aic7xxx_parse_msg(struct aic7xxx_host *p, struct aic7xxx_scb *scb) * the device isn't allowed to send values greater than the ones * we first sent to it. */ - new_period = MAX(period, aic_dev->goal.period); - new_offset = MIN(offset, aic_dev->goal.offset); + new_period = max_t(unsigned int, period, aic_dev->goal.period); + new_offset = min_t(unsigned int, offset, aic_dev->goal.offset); } /* @@ -5208,7 +5204,7 @@ aic7xxx_parse_msg(struct aic7xxx_host *p, struct aic7xxx_scb *scb) if(p->user[tindex].offset) { aic_dev->needsdtr_copy = 1; - aic_dev->goal.period = MAX(10,p->user[tindex].period); + aic_dev->goal.period = max_t(unsigned char, 10, p->user[tindex].period); if(p->features & AHC_ULTRA2) { aic_dev->goal.offset = MAX_OFFSET_ULTRA2; @@ -6413,7 +6409,7 @@ aic7xxx_isr(int irq, void *dev_id, struct pt_regs *regs) unsigned char errno = aic_inb(p, ERROR); printk(KERN_ERR "(scsi%d) BRKADRINT error(0x%x):\n", p->host_no, errno); - for (i = 0; i < NUMBER(hard_error); i++) + for (i = 0; i < ARRAY_SIZE(hard_error); i++) { if (errno & hard_error[i].errno) { @@ -6562,7 +6558,7 @@ aic7xxx_init_transinfo(struct aic7xxx_host *p, struct aic_dev_data *aic_dev) else { aic_dev->needsdtr = aic_dev->needsdtr_copy = 1; - aic_dev->goal.period = MAX(10, aic_dev->goal.period); + aic_dev->goal.period = max_t(unsigned char, 10, aic_dev->goal.period); aic_dev->goal.options = 0; } } @@ -6673,7 +6669,7 @@ aic7xxx_device_queue_depth(struct aic7xxx_host *p, Scsi_Device *device) } else { - if (p->instance >= NUMBER(aic7xxx_tag_info)) + if (p->instance >= ARRAY_SIZE(aic7xxx_tag_info)) { static int print_warning = TRUE; if(print_warning) @@ -6850,7 +6846,7 @@ aic7xxx_probe(int slot, int base, ahc_flag_type *flags) buf[i] = inb(base + i); } - for (i = 0; i < NUMBER(AIC7xxx); i++) + for (i = 0; i < ARRAY_SIZE(AIC7xxx); i++) { /* * Signature match on enabled card? @@ -7970,8 +7966,8 @@ aic7xxx_register(Scsi_Host_Template *template, struct aic7xxx_host *p, printk(KERN_INFO "(scsi%d) BIOS %sabled, IO Port 0x%lx, IRQ %d\n", p->host_no, (p->flags & AHC_BIOS_ENABLED) ? "en" : "dis", p->base, p->irq); - printk(KERN_INFO "(scsi%d) IO Memory at 0x%lx, MMAP Memory at 0x%lx\n", - p->host_no, p->mbase, (unsigned long)p->maddr); + printk(KERN_INFO "(scsi%d) IO Memory at 0x%lx, MMAP Memory at %p\n", + p->host_no, p->mbase, p->maddr); } #ifdef CONFIG_PCI @@ -9199,7 +9195,7 @@ aic7xxx_detect(Scsi_Host_Template *template) unsigned int devconfig, i, oldverbose; struct pci_dev *pdev = NULL; - for (i = 0; i < NUMBER(aic_pdevs); i++) + for (i = 0; i < ARRAY_SIZE(aic_pdevs); i++) { pdev = NULL; while ((pdev = pci_find_device(aic_pdevs[i].vendor_id, @@ -9246,6 +9242,7 @@ aic7xxx_detect(Scsi_Host_Template *template) { /* duplicate PCI entry, skip it */ kfree(temp_p); + temp_p = NULL; continue; } current_p = current_p->next; @@ -9313,14 +9310,9 @@ aic7xxx_detect(Scsi_Host_Template *template) ((temp_p->chip != (AHC_AIC7870 | AHC_PCI)) && (temp_p->chip != (AHC_AIC7880 | AHC_PCI))) ) { - unsigned long page_offset, base; - - base = temp_p->mbase & PAGE_MASK; - page_offset = temp_p->mbase - base; - temp_p->maddr = ioremap_nocache(base, page_offset + 256); + temp_p->maddr = ioremap_nocache(temp_p->mbase, 256); if(temp_p->maddr) { - temp_p->maddr += page_offset; /* * We need to check the I/O with the MMAPed address. Some machines * simply fail to work with MMAPed I/O and certain controllers. @@ -9337,8 +9329,8 @@ aic7xxx_detect(Scsi_Host_Template *template) PCI_FUNC(temp_p->pci_device_fn)); printk(KERN_INFO "aic7xxx: MMAPed I/O failed, reverting to " "Programmed I/O.\n"); - iounmap((void *) (((unsigned long) temp_p->maddr) & PAGE_MASK)); - temp_p->maddr = 0; + iounmap(temp_p->maddr); + temp_p->maddr = NULL; if(temp_p->base == 0) { printk("aic7xxx: <%s> at PCI %d/%d/%d\n", @@ -9678,7 +9670,9 @@ aic7xxx_detect(Scsi_Host_Template *template) found++; continue; skip_pci_controller: +#ifdef CONFIG_PCI pci_release_regions(temp_p->pdev); +#endif kfree(temp_p); } /* Found an Adaptec PCI device. */ else /* Well, we found one, but we couldn't get any memory */ @@ -9698,7 +9692,7 @@ skip_pci_controller: * EISA/VL-bus card signature probe. */ slot = MINSLOT; - while ( (slot <= MAXSLOT) && + while ( (slot <= MAXSLOT) && !(aic7xxx_no_probe) ) { base = SLOTBASE(slot) + MINREG; @@ -9744,7 +9738,7 @@ skip_pci_controller: temp_p->pause = hcntrl | PAUSE | INTEN; temp_p->base = base; temp_p->mbase = 0; - temp_p->maddr = 0; + temp_p->maddr = NULL; temp_p->pci_bus = 0; temp_p->pci_device_fn = slot; aic_outb(temp_p, hcntrl | PAUSE, HCNTRL); @@ -10097,7 +10091,7 @@ skip_pci_controller: int i; left = found; - for (i=0; ihost->host_lock); - scsi_sleep(HZ); + ssleep(1); spin_lock_irq(p->host->host_lock); if(aic_dev->flags & BUS_DEVICE_RESET_PENDING) return FAILED; @@ -10549,7 +10543,7 @@ aic7xxx_bus_device_reset(Scsi_Cmnd *cmd) aic_outb(p, saved_scbptr, SCBPTR); unpause_sequencer(p, FALSE); spin_unlock_irq(p->host->host_lock); - scsi_sleep(HZ/4); + msleep(1000/4); spin_lock_irq(p->host->host_lock); if(aic_dev->flags & BUS_DEVICE_RESET_PENDING) return FAILED; @@ -10569,8 +10563,7 @@ static void aic7xxx_panic_abort(struct aic7xxx_host *p, Scsi_Cmnd *cmd) { - printk("aic7xxx driver version %s/%s\n", AIC7XXX_C_VERSION, - UTS_RELEASE); + printk("aic7xxx driver version %s\n", AIC7XXX_C_VERSION); printk("Controller type:\n %s\n", board_names[p->board_name_index]); printk("p->flags=0x%lx, p->chip=0x%x, p->features=0x%x, " "sequencer %s paused\n", @@ -10787,7 +10780,7 @@ aic7xxx_abort(Scsi_Cmnd *cmd) } unpause_sequencer(p, FALSE); spin_unlock_irq(p->host->host_lock); - scsi_sleep(HZ/4); + msleep(1000/4); spin_lock_irq(p->host->host_lock); if (p->flags & AHC_ABORT_PENDING) { @@ -10888,7 +10881,7 @@ aic7xxx_reset(Scsi_Cmnd *cmd) aic7xxx_run_done_queue(p, TRUE); unpause_sequencer(p, FALSE); spin_unlock_irq(p->host->host_lock); - scsi_sleep(2 * HZ); + ssleep(2); spin_lock_irq(p->host->host_lock); return SUCCESS; } @@ -10965,13 +10958,15 @@ aic7xxx_release(struct Scsi_Host *host) #ifdef MMAPIO if(p->maddr) { - iounmap((void *) (((unsigned long) p->maddr) & PAGE_MASK)); + iounmap(p->maddr); } #endif /* MMAPIO */ if(!p->pdev) release_region(p->base, MAXREG - MINREG); +#ifdef CONFIG_PCI else pci_release_regions(p->pdev); +#endif prev = NULL; next = first_aic7xxx; while(next != NULL) @@ -11138,6 +11133,7 @@ aic7xxx_print_scratch_ram(struct aic7xxx_host *p) #include "aic7xxx_old/aic7xxx_proc.c" MODULE_LICENSE("Dual BSD/GPL"); +MODULE_VERSION(AIC7XXX_H_VERSION); static Scsi_Host_Template driver_template = {