Commit 6391a113 authored by Tobias Klauser's avatar Tobias Klauser Committed by James Bottomley

[SCSI] drivers/scsi: Use ARRAY_SIZE macro

Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]) and remove
duplicates of the macro.
Signed-off-by: default avatarTobias Klauser <tklauser@nuerscht.ch>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 9dc399de
...@@ -405,7 +405,7 @@ static int tw_decode_sense(TW_Device_Extension *tw_dev, int request_id, int fill ...@@ -405,7 +405,7 @@ static int tw_decode_sense(TW_Device_Extension *tw_dev, int request_id, int fill
/* Attempt to return intelligent sense information */ /* Attempt to return intelligent sense information */
if (fill_sense) { if (fill_sense) {
if ((command->status == 0xc7) || (command->status == 0xcb)) { if ((command->status == 0xc7) || (command->status == 0xcb)) {
for (i=0;i<(sizeof(tw_sense_table)/sizeof(tw_sense_table[0]));i++) { for (i = 0; i < ARRAY_SIZE(tw_sense_table); i++) {
if (command->flags == tw_sense_table[i][0]) { if (command->flags == tw_sense_table[i][0]) {
/* Valid bit and 'current errors' */ /* Valid bit and 'current errors' */
...@@ -625,7 +625,7 @@ static int tw_aen_complete(TW_Device_Extension *tw_dev, int request_id) ...@@ -625,7 +625,7 @@ static int tw_aen_complete(TW_Device_Extension *tw_dev, int request_id)
if (aen == 0x0ff) { if (aen == 0x0ff) {
printk(KERN_WARNING "3w-xxxx: scsi%d: AEN: INFO: AEN queue overflow.\n", tw_dev->host->host_no); printk(KERN_WARNING "3w-xxxx: scsi%d: AEN: INFO: AEN queue overflow.\n", tw_dev->host->host_no);
} else { } else {
table_max = sizeof(tw_aen_string)/sizeof(char *); table_max = ARRAY_SIZE(tw_aen_string);
if ((aen & 0x0ff) < table_max) { if ((aen & 0x0ff) < table_max) {
if ((tw_aen_string[aen & 0xff][strlen(tw_aen_string[aen & 0xff])-1]) == '#') { if ((tw_aen_string[aen & 0xff][strlen(tw_aen_string[aen & 0xff])-1]) == '#') {
printk(KERN_WARNING "3w-xxxx: scsi%d: AEN: %s%d.\n", tw_dev->host->host_no, tw_aen_string[aen & 0xff], aen >> 8); printk(KERN_WARNING "3w-xxxx: scsi%d: AEN: %s%d.\n", tw_dev->host->host_no, tw_aen_string[aen & 0xff], aen >> 8);
...@@ -786,7 +786,7 @@ static int tw_aen_drain_queue(TW_Device_Extension *tw_dev) ...@@ -786,7 +786,7 @@ static int tw_aen_drain_queue(TW_Device_Extension *tw_dev)
if (aen == 0x0ff) { if (aen == 0x0ff) {
printk(KERN_WARNING "3w-xxxx: AEN: INFO: AEN queue overflow.\n"); printk(KERN_WARNING "3w-xxxx: AEN: INFO: AEN queue overflow.\n");
} else { } else {
table_max = sizeof(tw_aen_string)/sizeof(char *); table_max = ARRAY_SIZE(tw_aen_string);
if ((aen & 0x0ff) < table_max) { if ((aen & 0x0ff) < table_max) {
if ((tw_aen_string[aen & 0xff][strlen(tw_aen_string[aen & 0xff])-1]) == '#') { if ((tw_aen_string[aen & 0xff][strlen(tw_aen_string[aen & 0xff])-1]) == '#') {
printk(KERN_WARNING "3w-xxxx: AEN: %s%d.\n", tw_aen_string[aen & 0xff], aen >> 8); printk(KERN_WARNING "3w-xxxx: AEN: %s%d.\n", tw_aen_string[aen & 0xff], aen >> 8);
......
...@@ -316,7 +316,7 @@ NCR_700_detect(struct scsi_host_template *tpnt, ...@@ -316,7 +316,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,
BUG_ON(!dma_is_consistent(pScript) && L1_CACHE_BYTES < dma_get_cache_alignment()); BUG_ON(!dma_is_consistent(pScript) && L1_CACHE_BYTES < dma_get_cache_alignment());
hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET); hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET);
hostdata->dev = dev; hostdata->dev = dev;
pSlots = pScript + SLOTS_OFFSET; pSlots = pScript + SLOTS_OFFSET;
/* Fill in the missing routines from the host template */ /* Fill in the missing routines from the host template */
...@@ -332,19 +332,18 @@ NCR_700_detect(struct scsi_host_template *tpnt, ...@@ -332,19 +332,18 @@ NCR_700_detect(struct scsi_host_template *tpnt,
tpnt->slave_destroy = NCR_700_slave_destroy; tpnt->slave_destroy = NCR_700_slave_destroy;
tpnt->change_queue_depth = NCR_700_change_queue_depth; tpnt->change_queue_depth = NCR_700_change_queue_depth;
tpnt->change_queue_type = NCR_700_change_queue_type; tpnt->change_queue_type = NCR_700_change_queue_type;
if(tpnt->name == NULL) if(tpnt->name == NULL)
tpnt->name = "53c700"; tpnt->name = "53c700";
if(tpnt->proc_name == NULL) if(tpnt->proc_name == NULL)
tpnt->proc_name = "53c700"; tpnt->proc_name = "53c700";
host = scsi_host_alloc(tpnt, 4); host = scsi_host_alloc(tpnt, 4);
if (!host) if (!host)
return NULL; return NULL;
memset(hostdata->slots, 0, sizeof(struct NCR_700_command_slot) memset(hostdata->slots, 0, sizeof(struct NCR_700_command_slot)
* NCR_700_COMMAND_SLOTS_PER_HOST); * NCR_700_COMMAND_SLOTS_PER_HOST);
for(j = 0; j < NCR_700_COMMAND_SLOTS_PER_HOST; j++) { for (j = 0; j < NCR_700_COMMAND_SLOTS_PER_HOST; j++) {
dma_addr_t offset = (dma_addr_t)((unsigned long)&hostdata->slots[j].SG[0] dma_addr_t offset = (dma_addr_t)((unsigned long)&hostdata->slots[j].SG[0]
- (unsigned long)&hostdata->slots[0].SG[0]); - (unsigned long)&hostdata->slots[0].SG[0]);
hostdata->slots[j].pSG = (struct NCR_700_SG_List *)((unsigned long)(pSlots + offset)); hostdata->slots[j].pSG = (struct NCR_700_SG_List *)((unsigned long)(pSlots + offset));
...@@ -355,14 +354,12 @@ NCR_700_detect(struct scsi_host_template *tpnt, ...@@ -355,14 +354,12 @@ NCR_700_detect(struct scsi_host_template *tpnt,
hostdata->slots[j].state = NCR_700_SLOT_FREE; hostdata->slots[j].state = NCR_700_SLOT_FREE;
} }
for(j = 0; j < sizeof(SCRIPT)/sizeof(SCRIPT[0]); j++) { for (j = 0; j < ARRAY_SIZE(SCRIPT); j++)
script[j] = bS_to_host(SCRIPT[j]); script[j] = bS_to_host(SCRIPT[j]);
}
/* adjust all labels to be bus physical */ /* adjust all labels to be bus physical */
for(j = 0; j < PATCHES; j++) { for (j = 0; j < PATCHES; j++)
script[LABELPATCHES[j]] = bS_to_host(pScript + SCRIPT[LABELPATCHES[j]]); script[LABELPATCHES[j]] = bS_to_host(pScript + SCRIPT[LABELPATCHES[j]]);
}
/* now patch up fixed addresses. */ /* now patch up fixed addresses. */
script_patch_32(script, MessageLocation, script_patch_32(script, MessageLocation,
pScript + MSGOUT_OFFSET); pScript + MSGOUT_OFFSET);
...@@ -385,17 +382,17 @@ NCR_700_detect(struct scsi_host_template *tpnt, ...@@ -385,17 +382,17 @@ NCR_700_detect(struct scsi_host_template *tpnt,
host->hostdata[0] = (unsigned long)hostdata; host->hostdata[0] = (unsigned long)hostdata;
/* kick the chip */ /* kick the chip */
NCR_700_writeb(0xff, host, CTEST9_REG); NCR_700_writeb(0xff, host, CTEST9_REG);
if(hostdata->chip710) if (hostdata->chip710)
hostdata->rev = (NCR_700_readb(host, CTEST8_REG)>>4) & 0x0f; hostdata->rev = (NCR_700_readb(host, CTEST8_REG)>>4) & 0x0f;
else else
hostdata->rev = (NCR_700_readb(host, CTEST7_REG)>>4) & 0x0f; hostdata->rev = (NCR_700_readb(host, CTEST7_REG)>>4) & 0x0f;
hostdata->fast = (NCR_700_readb(host, CTEST9_REG) == 0); hostdata->fast = (NCR_700_readb(host, CTEST9_REG) == 0);
if(banner == 0) { if (banner == 0) {
printk(KERN_NOTICE "53c700: Version " NCR_700_VERSION " By James.Bottomley@HansenPartnership.com\n"); printk(KERN_NOTICE "53c700: Version " NCR_700_VERSION " By James.Bottomley@HansenPartnership.com\n");
banner = 1; banner = 1;
} }
printk(KERN_NOTICE "scsi%d: %s rev %d %s\n", host->host_no, printk(KERN_NOTICE "scsi%d: %s rev %d %s\n", host->host_no,
hostdata->chip710 ? "53c710" : hostdata->chip710 ? "53c710" :
(hostdata->fast ? "53c700-66" : "53c700"), (hostdata->fast ? "53c700-66" : "53c700"),
hostdata->rev, hostdata->differential ? hostdata->rev, hostdata->differential ?
"(Differential)" : ""); "(Differential)" : "");
......
...@@ -361,7 +361,7 @@ int CmdPageStart = (0 - Ent_dsa_zero - sizeof(struct NCR53c7x0_cmd)) & 0xff; ...@@ -361,7 +361,7 @@ int CmdPageStart = (0 - Ent_dsa_zero - sizeof(struct NCR53c7x0_cmd)) & 0xff;
static char *setup_strings[] = static char *setup_strings[] =
{"","","","","","","",""}; {"","","","","","","",""};
#define MAX_SETUP_STRINGS (sizeof(setup_strings) / sizeof(char *)) #define MAX_SETUP_STRINGS ARRAY_SIZE(setup_strings)
#define SETUP_BUFFER_SIZE 200 #define SETUP_BUFFER_SIZE 200
static char setup_buffer[SETUP_BUFFER_SIZE]; static char setup_buffer[SETUP_BUFFER_SIZE];
static char setup_used[MAX_SETUP_STRINGS]; static char setup_used[MAX_SETUP_STRINGS];
...@@ -2190,15 +2190,15 @@ static const struct { ...@@ -2190,15 +2190,15 @@ static const struct {
*/ */
static void static void
synchronous (struct Scsi_Host *host, int target, char *msg) { synchronous (struct Scsi_Host *host, int target, char *msg) {
struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *) struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
host->hostdata[0]; host->hostdata[0];
int desire, divisor, i, limit; int desire, divisor, i, limit;
unsigned char scntl3, sxfer; unsigned char scntl3, sxfer;
/* The diagnostic message fits on one line, even with max. width integers */ /* The diagnostic message fits on one line, even with max. width integers */
char buf[80]; char buf[80];
/* Desired transfer clock in Hz */ /* Desired transfer clock in Hz */
desire = 1000000000L / (msg[3] * 4); desire = 1000000000L / (msg[3] * 4);
/* Scale the available SCSI clock by 10 so we get tenths */ /* Scale the available SCSI clock by 10 so we get tenths */
...@@ -2209,14 +2209,14 @@ synchronous (struct Scsi_Host *host, int target, char *msg) { ...@@ -2209,14 +2209,14 @@ synchronous (struct Scsi_Host *host, int target, char *msg) {
msg[4] = 8; msg[4] = 8;
if (hostdata->options & OPTION_DEBUG_SDTR) if (hostdata->options & OPTION_DEBUG_SDTR)
printk("scsi%d : optimal synchronous divisor of %d.%01d\n", printk("scsi%d : optimal synchronous divisor of %d.%01d\n",
host->host_no, divisor / 10, divisor % 10); host->host_no, divisor / 10, divisor % 10);
limit = (sizeof(syncs) / sizeof(syncs[0]) -1); limit = ARRAY_SIZE(syncs) - 1;
for (i = 0; (i < limit) && (divisor > syncs[i].div); ++i); for (i = 0; (i < limit) && (divisor > syncs[i].div); ++i);
if (hostdata->options & OPTION_DEBUG_SDTR) if (hostdata->options & OPTION_DEBUG_SDTR)
printk("scsi%d : selected synchronous divisor of %d.%01d\n", printk("scsi%d : selected synchronous divisor of %d.%01d\n",
host->host_no, syncs[i].div / 10, syncs[i].div % 10); host->host_no, syncs[i].div / 10, syncs[i].div % 10);
msg[3] = ((1000000000L / hostdata->scsi_clock) * syncs[i].div / 10 / 4); msg[3] = ((1000000000L / hostdata->scsi_clock) * syncs[i].div / 10 / 4);
......
...@@ -213,16 +213,16 @@ static void *addresses[] = { ...@@ -213,16 +213,16 @@ static void *addresses[] = {
(void *) 0xd8000, (void *) 0xd8000,
(void *) 0xc8000 (void *) 0xc8000
}; };
#define ADDRESS_COUNT (sizeof( addresses ) / sizeof( unsigned )) #define ADDRESS_COUNT ARRAY_SIZE(addresses)
#endif /* USE_BIOS */ #endif /* USE_BIOS */
/* possible i/o port addresses */ /* possible i/o port addresses */
static unsigned short ports[] = { 0x230, 0x330, 0x280, 0x290, 0x330, 0x340, 0x300, 0x310, 0x348, 0x350 }; static unsigned short ports[] = { 0x230, 0x330, 0x280, 0x290, 0x330, 0x340, 0x300, 0x310, 0x348, 0x350 };
#define PORT_COUNT (sizeof( ports ) / sizeof( unsigned short )) #define PORT_COUNT ARRAY_SIZE(ports)
/* possible interrupt channels */ /* possible interrupt channels */
static unsigned short intrs[] = { 10, 11, 12, 15 }; static unsigned short intrs[] = { 10, 11, 12, 15 };
#define INTR_COUNT (sizeof( intrs ) / sizeof( unsigned short )) #define INTR_COUNT ARRAY_SIZE(intrs)
/* signatures for NCR 53c406a based controllers */ /* signatures for NCR 53c406a based controllers */
#if USE_BIOS #if USE_BIOS
...@@ -236,7 +236,7 @@ struct signature { ...@@ -236,7 +236,7 @@ struct signature {
{ {
"Copyright (C) Acculogic, Inc.\r\n2.8M Diskette Extension Bios ver 4.04.03 03/01/1993", 61, 82},}; "Copyright (C) Acculogic, Inc.\r\n2.8M Diskette Extension Bios ver 4.04.03 03/01/1993", 61, 82},};
#define SIGNATURE_COUNT (sizeof( signatures ) / sizeof( struct signature )) #define SIGNATURE_COUNT ARRAY_SIZE(signatures)
#endif /* USE_BIOS */ #endif /* USE_BIOS */
/* ============================================================ */ /* ============================================================ */
......
...@@ -641,13 +641,13 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) ...@@ -641,13 +641,13 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex)
cp[sizeof(str->pid)] = c; cp[sizeof(str->pid)] = c;
} else { } else {
struct aac_driver_ident *mp = aac_get_driver_ident(dev->cardtype); struct aac_driver_ident *mp = aac_get_driver_ident(dev->cardtype);
inqstrcpy (mp->vname, str->vid); inqstrcpy (mp->vname, str->vid);
/* last six chars reserved for vol type */ /* last six chars reserved for vol type */
inqstrcpy (mp->model, str->pid); inqstrcpy (mp->model, str->pid);
} }
if (tindex < (sizeof(container_types)/sizeof(char *))){ if (tindex < ARRAY_SIZE(container_types)){
char *findit = str->pid; char *findit = str->pid;
for ( ; *findit != ' '; findit++); /* walk till we find a space */ for ( ; *findit != ' '; findit++); /* walk till we find a space */
...@@ -1576,7 +1576,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) ...@@ -1576,7 +1576,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
* see: <vendor>.c i.e. aac.c * see: <vendor>.c i.e. aac.c
*/ */
if (scmd_id(scsicmd) == host->this_id) { if (scmd_id(scsicmd) == host->this_id) {
setinqstr(dev, (void *) (inq_data.inqd_vid), (sizeof(container_types)/sizeof(char *))); setinqstr(dev, (void *) (inq_data.inqd_vid), ARRAY_SIZE(container_types));
inq_data.inqd_pdt = INQD_PDT_PROC; /* Processor device */ inq_data.inqd_pdt = INQD_PDT_PROC; /* Processor device */
aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data)); aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));
scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
...@@ -2381,7 +2381,7 @@ static struct aac_srb_status_info srb_status_info[] = { ...@@ -2381,7 +2381,7 @@ static struct aac_srb_status_info srb_status_info[] = {
{ SRB_STATUS_SUCCESS, "Success"}, { SRB_STATUS_SUCCESS, "Success"},
{ SRB_STATUS_ABORTED, "Aborted Command"}, { SRB_STATUS_ABORTED, "Aborted Command"},
{ SRB_STATUS_ABORT_FAILED, "Abort Failed"}, { SRB_STATUS_ABORT_FAILED, "Abort Failed"},
{ SRB_STATUS_ERROR, "Error Event"}, { SRB_STATUS_ERROR, "Error Event"},
{ SRB_STATUS_BUSY, "Device Busy"}, { SRB_STATUS_BUSY, "Device Busy"},
{ SRB_STATUS_INVALID_REQUEST, "Invalid Request"}, { SRB_STATUS_INVALID_REQUEST, "Invalid Request"},
{ SRB_STATUS_INVALID_PATH_ID, "Invalid Path ID"}, { SRB_STATUS_INVALID_PATH_ID, "Invalid Path ID"},
...@@ -2400,7 +2400,7 @@ static struct aac_srb_status_info srb_status_info[] = { ...@@ -2400,7 +2400,7 @@ static struct aac_srb_status_info srb_status_info[] = {
{ SRB_STATUS_BAD_SRB_BLOCK_LENGTH,"Bad Srb Block Length"}, { SRB_STATUS_BAD_SRB_BLOCK_LENGTH,"Bad Srb Block Length"},
{ SRB_STATUS_REQUEST_FLUSHED, "Request Flushed"}, { SRB_STATUS_REQUEST_FLUSHED, "Request Flushed"},
{ SRB_STATUS_DELAYED_RETRY, "Delayed Retry"}, { SRB_STATUS_DELAYED_RETRY, "Delayed Retry"},
{ SRB_STATUS_INVALID_LUN, "Invalid LUN"}, { SRB_STATUS_INVALID_LUN, "Invalid LUN"},
{ SRB_STATUS_INVALID_TARGET_ID, "Invalid TARGET ID"}, { SRB_STATUS_INVALID_TARGET_ID, "Invalid TARGET ID"},
{ SRB_STATUS_BAD_FUNCTION, "Bad Function"}, { SRB_STATUS_BAD_FUNCTION, "Bad Function"},
{ SRB_STATUS_ERROR_RECOVERY, "Error Recovery"}, { SRB_STATUS_ERROR_RECOVERY, "Error Recovery"},
...@@ -2415,11 +2415,9 @@ char *aac_get_status_string(u32 status) ...@@ -2415,11 +2415,9 @@ char *aac_get_status_string(u32 status)
{ {
int i; int i;
for(i=0; i < (sizeof(srb_status_info)/sizeof(struct aac_srb_status_info)); i++ ){ for (i = 0; i < ARRAY_SIZE(srb_status_info); i++)
if(srb_status_info[i].status == status){ if (srb_status_info[i].status == status)
return srb_status_info[i].str; return srb_status_info[i].str;
}
}
return "Bad Status Code"; return "Bad Status Code";
} }
......
...@@ -535,7 +535,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) ...@@ -535,7 +535,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
default: default:
data_dir = DMA_NONE; data_dir = DMA_NONE;
} }
if (user_srbcmd->sg.count > (sizeof(sg_list)/sizeof(sg_list[0]))) { if (user_srbcmd->sg.count > ARRAY_SIZE(sg_list)) {
dprintk((KERN_DEBUG"aacraid: too many sg entries %d\n", dprintk((KERN_DEBUG"aacraid: too many sg entries %d\n",
le32_to_cpu(srbcmd->sg.count))); le32_to_cpu(srbcmd->sg.count)));
rcode = -EINVAL; rcode = -EINVAL;
......
...@@ -1011,7 +1011,7 @@ static int __init do_setup(char *str) ...@@ -1011,7 +1011,7 @@ static int __init do_setup(char *str)
int count=setup_idx; int count=setup_idx;
get_options(str, sizeof(ints)/sizeof(int), ints); get_options(str, ARRAY_SIZE(ints), ints);
aha1542_setup(str,ints); aha1542_setup(str,ints);
return count<setup_idx; return count<setup_idx;
...@@ -1072,8 +1072,7 @@ static int __init aha1542_detect(struct scsi_host_template * tpnt) ...@@ -1072,8 +1072,7 @@ static int __init aha1542_detect(struct scsi_host_template * tpnt)
int slot = 0; int slot = 0;
int pos = 0; int pos = 0;
for (indx = 0; (slot != MCA_NOTFOUND) && for (indx = 0; (slot != MCA_NOTFOUND) && (indx < ARRAY_SIZE(bases)); indx++) {
(indx < sizeof(bases)/sizeof(bases[0])); indx++) {
if (bases[indx]) if (bases[indx])
continue; continue;
...@@ -1083,10 +1082,9 @@ static int __init aha1542_detect(struct scsi_host_template * tpnt) ...@@ -1083,10 +1082,9 @@ static int __init aha1542_detect(struct scsi_host_template * tpnt)
if (slot == MCA_NOTFOUND) if (slot == MCA_NOTFOUND)
break; break;
/* Found one */ /* Found one */
pos = mca_read_stored_pos(slot, 3); pos = mca_read_stored_pos(slot, 3);
/* Decode address */ /* Decode address */
if (pos & 0x80) { if (pos & 0x80) {
if (pos & 0x02) { if (pos & 0x02) {
...@@ -1118,23 +1116,22 @@ static int __init aha1542_detect(struct scsi_host_template * tpnt) ...@@ -1118,23 +1116,22 @@ static int __init aha1542_detect(struct scsi_host_template * tpnt)
mca_set_adapter_name(slot, "Adapter AHA-1640"); mca_set_adapter_name(slot, "Adapter AHA-1640");
mca_set_adapter_procfn(slot, NULL, NULL); mca_set_adapter_procfn(slot, NULL, NULL);
mca_mark_as_used(slot); mca_mark_as_used(slot);
/* Go on */ /* Go on */
slot++; slot++;
} }
} }
#endif #endif
/* /*
* Hunt for ISA Plug'n'Pray Adaptecs (AHA1535) * Hunt for ISA Plug'n'Pray Adaptecs (AHA1535)
*/ */
if(isapnp) if(isapnp)
{ {
struct pnp_dev *pdev = NULL; struct pnp_dev *pdev = NULL;
for(indx = 0; indx <sizeof(bases)/sizeof(bases[0]);indx++) for(indx = 0; indx < ARRAY_SIZE(bases); indx++) {
{
if(bases[indx]) if(bases[indx])
continue; continue;
pdev = pnp_find_dev(NULL, ISAPNP_VENDOR('A', 'D', 'P'), pdev = pnp_find_dev(NULL, ISAPNP_VENDOR('A', 'D', 'P'),
...@@ -1144,29 +1141,29 @@ static int __init aha1542_detect(struct scsi_host_template * tpnt) ...@@ -1144,29 +1141,29 @@ static int __init aha1542_detect(struct scsi_host_template * tpnt)
/* /*
* Activate the PnP card * Activate the PnP card
*/ */
if(pnp_device_attach(pdev)<0) if(pnp_device_attach(pdev)<0)
continue; continue;
if(pnp_activate_dev(pdev)<0) { if(pnp_activate_dev(pdev)<0) {
pnp_device_detach(pdev); pnp_device_detach(pdev);
continue; continue;
} }
if(!pnp_port_valid(pdev, 0)) { if(!pnp_port_valid(pdev, 0)) {
pnp_device_detach(pdev); pnp_device_detach(pdev);
continue; continue;
} }
bases[indx] = pnp_port_start(pdev, 0); bases[indx] = pnp_port_start(pdev, 0);
/* The card can be queried for its DMA, we have /* The card can be queried for its DMA, we have
the DMA set up that is enough */ the DMA set up that is enough */
printk(KERN_INFO "ISAPnP found an AHA1535 at I/O 0x%03X\n", bases[indx]); printk(KERN_INFO "ISAPnP found an AHA1535 at I/O 0x%03X\n", bases[indx]);
} }
} }
for (indx = 0; indx < sizeof(bases) / sizeof(bases[0]); indx++) for (indx = 0; indx < ARRAY_SIZE(bases); indx++)
if (bases[indx] != 0 && request_region(bases[indx], 4, "aha1542")) { if (bases[indx] != 0 && request_region(bases[indx], 4, "aha1542")) {
shpnt = scsi_register(tpnt, shpnt = scsi_register(tpnt,
sizeof(struct aha1542_hostdata)); sizeof(struct aha1542_hostdata));
......
...@@ -107,7 +107,7 @@ struct aic7770_identity aic7770_ident_table[] = ...@@ -107,7 +107,7 @@ struct aic7770_identity aic7770_ident_table[] =
ahc_aic7770_EISA_setup ahc_aic7770_EISA_setup
} }
}; };
const int ahc_num_aic7770_devs = NUM_ELEMENTS(aic7770_ident_table); const int ahc_num_aic7770_devs = ARRAY_SIZE(aic7770_ident_table);
struct aic7770_identity * struct aic7770_identity *
aic7770_find_device(uint32_t id) aic7770_find_device(uint32_t id)
......
...@@ -68,8 +68,6 @@ struct scb_platform_data; ...@@ -68,8 +68,6 @@ struct scb_platform_data;
#define FALSE 0 #define FALSE 0
#endif #endif
#define NUM_ELEMENTS(array) (sizeof(array) / sizeof(*array))
#define ALL_CHANNELS '\0' #define ALL_CHANNELS '\0'
#define ALL_TARGETS_MASK 0xFFFF #define ALL_TARGETS_MASK 0xFFFF
#define INITIATOR_WILDCARD (~0) #define INITIATOR_WILDCARD (~0)
......
...@@ -59,7 +59,7 @@ char *ahd_chip_names[] = ...@@ -59,7 +59,7 @@ char *ahd_chip_names[] =
"aic7902", "aic7902",
"aic7901A" "aic7901A"
}; };
static const u_int num_chip_names = NUM_ELEMENTS(ahd_chip_names); static const u_int num_chip_names = ARRAY_SIZE(ahd_chip_names);
/* /*
* Hardware error codes. * Hardware error codes.
...@@ -77,7 +77,7 @@ static struct ahd_hard_error_entry ahd_hard_errors[] = { ...@@ -77,7 +77,7 @@ static struct ahd_hard_error_entry ahd_hard_errors[] = {
{ MPARERR, "Scratch or SCB Memory Parity Error" }, { MPARERR, "Scratch or SCB Memory Parity Error" },
{ CIOPARERR, "CIOBUS Parity Error" }, { CIOPARERR, "CIOBUS Parity Error" },
}; };
static const u_int num_errors = NUM_ELEMENTS(ahd_hard_errors); static const u_int num_errors = ARRAY_SIZE(ahd_hard_errors);
static struct ahd_phase_table_entry ahd_phase_table[] = static struct ahd_phase_table_entry ahd_phase_table[] =
{ {
...@@ -97,7 +97,7 @@ static struct ahd_phase_table_entry ahd_phase_table[] = ...@@ -97,7 +97,7 @@ static struct ahd_phase_table_entry ahd_phase_table[] =
* In most cases we only wish to itterate over real phases, so * In most cases we only wish to itterate over real phases, so
* exclude the last element from the count. * exclude the last element from the count.
*/ */
static const u_int num_phases = NUM_ELEMENTS(ahd_phase_table) - 1; static const u_int num_phases = ARRAY_SIZE(ahd_phase_table) - 1;
/* Our Sequencer Program */ /* Our Sequencer Program */
#include "aic79xx_seq.h" #include "aic79xx_seq.h"
...@@ -7259,7 +7259,7 @@ ahd_qinfifo_count(struct ahd_softc *ahd) ...@@ -7259,7 +7259,7 @@ ahd_qinfifo_count(struct ahd_softc *ahd)
return (wrap_qinfifonext - wrap_qinpos); return (wrap_qinfifonext - wrap_qinpos);
else else
return (wrap_qinfifonext return (wrap_qinfifonext
+ NUM_ELEMENTS(ahd->qinfifo) - wrap_qinpos); + ARRAY_SIZE(ahd->qinfifo) - wrap_qinpos);
} }
void void
...@@ -8619,7 +8619,7 @@ ahd_check_patch(struct ahd_softc *ahd, struct patch **start_patch, ...@@ -8619,7 +8619,7 @@ ahd_check_patch(struct ahd_softc *ahd, struct patch **start_patch,
struct patch *last_patch; struct patch *last_patch;
u_int num_patches; u_int num_patches;