#include <asm/io.h>
#include <asm/irq.h>
#include <asm/byteorder.h>
-#include <linux/version.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/smp.h>
#include <linux/interrupt.h>
#include "scsi.h"
-#include "hosts.h"
+#include <scsi/scsi_host.h>
#include "aic7xxx_old/aic7xxx.h"
#include "aic7xxx_old/sequencer.h"
#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
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;
*/
#ifdef MODULE
static char * aic7xxx = NULL;
-MODULE_PARM(aic7xxx, "s");
+module_param(aic7xxx, charp, 0);
#endif
#define VERBOSE_NORMAL 0x0000
*
***************************************************************************/
-static inline unsigned char
+static unsigned char
aic_inb(struct aic7xxx_host *p, long port)
{
#ifdef MMAPIO
#endif
}
-static inline void
+static void
aic_outb(struct aic7xxx_host *p, unsigned char val, long port)
{
#ifdef MMAPIO
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))
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)
}
}
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;
{
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;
}
* Description:
* Return a string describing the driver.
*-F*************************************************************************/
-const char *
+static const char *
aic7xxx_info(struct Scsi_Host *dooh)
{
static char buffer[256];
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:
if(!(p->features & AHC_ULTRA3))
{
*options = 0;
- maxsync = MAX(maxsync, AHC_SYNCRATE_ULTRA2);
+ maxsync = max_t(unsigned int, maxsync, AHC_SYNCRATE_ULTRA2);
}
else
{
break;
default:
*options = 0;
- maxsync = MAX(maxsync, AHC_SYNCRATE_ULTRA2);
+ maxsync = max_t(unsigned int, maxsync, AHC_SYNCRATE_ULTRA2);
break;
}
syncrate = &aic7xxx_syncrates[maxsync];
else
maxoffset = MAX_OFFSET_8BIT;
}
- *offset = MIN(*offset, maxoffset);
+ *offset = min(*offset, maxoffset);
}
/*+F*************************************************************************
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)
struct scatterlist *sg;
sg = (struct scatterlist *)cmd->request_buffer;
- pci_unmap_sg(p->pdev, sg, cmd->use_sg, scsi_to_pci_dma_dir(cmd->sc_data_direction));
+ pci_unmap_sg(p->pdev, sg, cmd->use_sg, cmd->sc_data_direction);
}
else if (cmd->request_bufflen)
pci_unmap_single(p->pdev, aic7xxx_mapping(cmd),
cmd->request_bufflen,
- scsi_to_pci_dma_dir(cmd->sc_data_direction));
+ cmd->sc_data_direction);
if (scb->flags & SCB_SENSE)
{
pci_unmap_single(p->pdev,
}
break;
-#if AIC7XXX_NOT_YET
+#ifdef AIC7XXX_NOT_YET
case TRACEPOINT2:
{
printk(INFO_LEAD "Tracepoint #2 reached.\n", p->host_no,
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;
* 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);
}
/*
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;
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)
{
static void
aic7xxx_init_transinfo(struct aic7xxx_host *p, struct aic_dev_data *aic_dev)
{
- Scsi_Device *sdpnt = aic_dev->SDptr;
+ struct scsi_device *sdpnt = aic_dev->SDptr;
unsigned char tindex;
tindex = sdpnt->id | (sdpnt->channel << 3);
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;
}
}
* Set up the initial aic_dev struct pointers
*-F*************************************************************************/
static int
-aic7xxx_slave_alloc(Scsi_Device *SDptr)
+aic7xxx_slave_alloc(struct scsi_device *SDptr)
{
struct aic7xxx_host *p = (struct aic7xxx_host *)SDptr->host->hostdata;
struct aic_dev_data *aic_dev;
* queueing to be [en|dis]abled for a specific adapter.
*-F*************************************************************************/
static void
-aic7xxx_device_queue_depth(struct aic7xxx_host *p, Scsi_Device *device)
+aic7xxx_device_queue_depth(struct aic7xxx_host *p, struct scsi_device *device)
{
int tag_enabled = FALSE;
struct aic_dev_data *aic_dev = device->hostdata;
}
else
{
- if (p->instance >= NUMBER(aic7xxx_tag_info))
+ if (p->instance >= ARRAY_SIZE(aic7xxx_tag_info))
{
static int print_warning = TRUE;
if(print_warning)
* prepare for this device to go away
*-F*************************************************************************/
static void
-aic7xxx_slave_destroy(Scsi_Device *SDptr)
+aic7xxx_slave_destroy(struct scsi_device *SDptr)
{
struct aic_dev_data *aic_dev = SDptr->hostdata;
* depths, allocate command structs, etc.
*-F*************************************************************************/
static int
-aic7xxx_slave_configure(Scsi_Device *SDptr)
+aic7xxx_slave_configure(struct scsi_device *SDptr)
{
struct aic7xxx_host *p = (struct aic7xxx_host *) SDptr->host->hostdata;
struct aic_dev_data *aic_dev;
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?
* Register a Adaptec aic7xxx chip SCSI controller with the kernel.
*-F*************************************************************************/
static int
-aic7xxx_register(Scsi_Host_Template *template, struct aic7xxx_host *p,
+aic7xxx_register(struct scsi_host_template *template, struct aic7xxx_host *p,
int reset_delay)
{
int i, result;
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
* and a pointer to a aic7xxx_host struct upon success.
*-F*************************************************************************/
static struct aic7xxx_host *
-aic7xxx_alloc(Scsi_Host_Template *sht, struct aic7xxx_host *temp)
+aic7xxx_alloc(struct scsi_host_template *sht, struct aic7xxx_host *temp)
{
struct aic7xxx_host *p = NULL;
struct Scsi_Host *host;
}
p->host_no = host->host_no;
}
- scsi_set_device(host, &p->pdev->dev);
return (p);
}
- scb_dma->dma_offset),
scb_dma->dma_address);
}
- if (p->scb_data->scb_array[i]->kmalloc_ptr != NULL)
- kfree(p->scb_data->scb_array[i]->kmalloc_ptr);
+ kfree(p->scb_data->scb_array[i]->kmalloc_ptr);
p->scb_data->scb_array[i] = NULL;
}
* mid-level SCSI code is overhauled.
*-F*************************************************************************/
static int
-aic7xxx_detect(Scsi_Host_Template *template)
+aic7xxx_detect(struct scsi_host_template *template)
{
struct aic7xxx_host *temp_p = NULL;
struct aic7xxx_host *current_p = NULL;
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,
{
/* duplicate PCI entry, skip it */
kfree(temp_p);
+ temp_p = NULL;
continue;
}
current_p = current_p->next;
((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.
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",
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 */
* EISA/VL-bus card signature probe.
*/
slot = MINSLOT;
- while ( (slot <= MAXSLOT) &&
+ while ( (slot <= MAXSLOT) &&
!(aic7xxx_no_probe) )
{
base = SLOTBASE(slot) + MINREG;
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);
int i;
left = found;
- for (i=0; i<NUMBER(sort_list); i++)
+ for (i=0; i<ARRAY_SIZE(sort_list); i++)
{
temp_p = sort_list[i];
while(temp_p != NULL)
sg = (struct scatterlist *)cmd->request_buffer;
scb->sg_length = 0;
- use_sg = pci_map_sg(p->pdev, sg, cmd->use_sg, scsi_to_pci_dma_dir(cmd->sc_data_direction));
+ use_sg = pci_map_sg(p->pdev, sg, cmd->use_sg, cmd->sc_data_direction);
/*
* Copy the segments into the SG array. NOTE!!! - We used to
* have the first entry both in the data_pointer area and the first
{
unsigned int address = pci_map_single(p->pdev, cmd->request_buffer,
cmd->request_bufflen,
- scsi_to_pci_dma_dir(cmd->sc_data_direction));
+ cmd->sc_data_direction);
aic7xxx_mapping(cmd) = address;
scb->sg_list[0].address = cpu_to_le32(address);
scb->sg_list[0].length = cpu_to_le32(cmd->request_bufflen);
* Returns an enumerated type that indicates the status of the operation.
*-F*************************************************************************/
static int
-aic7xxx_bus_device_reset(Scsi_Cmnd *cmd)
+__aic7xxx_bus_device_reset(Scsi_Cmnd *cmd)
{
struct aic7xxx_host *p;
struct aic7xxx_scb *scb;
aic_outb(p, lastphase | ATNO, SCSISIGO);
unpause_sequencer(p, FALSE);
spin_unlock_irq(p->host->host_lock);
- scsi_sleep(HZ);
+ ssleep(1);
spin_lock_irq(p->host->host_lock);
if(aic_dev->flags & BUS_DEVICE_RESET_PENDING)
return FAILED;
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;
return SUCCESS;
}
+static int
+aic7xxx_bus_device_reset(Scsi_Cmnd *cmd)
+{
+ int rc;
+
+ spin_lock_irq(cmd->device->host->host_lock);
+ rc = __aic7xxx_bus_device_reset(cmd);
+ spin_unlock_irq(cmd->device->host->host_lock);
+
+ return rc;
+}
+
/*+F*************************************************************************
* Function:
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",
* Abort the current SCSI command(s).
*-F*************************************************************************/
static int
-aic7xxx_abort(Scsi_Cmnd *cmd)
+__aic7xxx_abort(Scsi_Cmnd *cmd)
{
struct aic7xxx_scb *scb = NULL;
struct aic7xxx_host *p;
}
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)
{
return SUCCESS;
}
+static int
+aic7xxx_abort(Scsi_Cmnd *cmd)
+{
+ int rc;
+
+ spin_lock_irq(cmd->device->host->host_lock);
+ rc = __aic7xxx_abort(cmd);
+ spin_unlock_irq(cmd->device->host->host_lock);
+
+ return rc;
+}
+
+
/*+F*************************************************************************
* Function:
* aic7xxx_reset
struct aic_dev_data *aic_dev;
p = (struct aic7xxx_host *) cmd->device->host->hostdata;
+ spin_lock_irq(p->host->host_lock);
+
aic_dev = AIC_DEV(cmd);
if(aic7xxx_position(cmd) < p->scb_data->numscbs)
{
* longer have it.
*/
unpause_sequencer(p, FALSE);
+ spin_unlock_irq(p->host->host_lock);
return SUCCESS;
}
aic7xxx_run_done_queue(p, TRUE);
unpause_sequencer(p, FALSE);
spin_unlock_irq(p->host->host_lock);
- scsi_sleep(2 * HZ);
- spin_lock_irq(p->host->host_lock);
+ ssleep(2);
return SUCCESS;
}
#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)
#include "aic7xxx_old/aic7xxx_proc.c"
MODULE_LICENSE("Dual BSD/GPL");
+MODULE_VERSION(AIC7XXX_H_VERSION);
-static Scsi_Host_Template driver_template = {
+static struct scsi_host_template driver_template = {
.proc_info = aic7xxx_proc_info,
.detect = aic7xxx_detect,
.release = aic7xxx_release,