You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
[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: Tobias Klauser <tklauser@nuerscht.ch> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
committed by
James Bottomley
parent
9dc399de08
commit
6391a11375
@@ -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 */
|
||||
if (fill_sense) {
|
||||
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]) {
|
||||
|
||||
/* Valid bit and 'current errors' */
|
||||
@@ -625,7 +625,7 @@ static int tw_aen_complete(TW_Device_Extension *tw_dev, int request_id)
|
||||
if (aen == 0x0ff) {
|
||||
printk(KERN_WARNING "3w-xxxx: scsi%d: AEN: INFO: AEN queue overflow.\n", tw_dev->host->host_no);
|
||||
} else {
|
||||
table_max = sizeof(tw_aen_string)/sizeof(char *);
|
||||
table_max = ARRAY_SIZE(tw_aen_string);
|
||||
if ((aen & 0x0ff) < table_max) {
|
||||
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);
|
||||
@@ -786,7 +786,7 @@ static int tw_aen_drain_queue(TW_Device_Extension *tw_dev)
|
||||
if (aen == 0x0ff) {
|
||||
printk(KERN_WARNING "3w-xxxx: AEN: INFO: AEN queue overflow.\n");
|
||||
} else {
|
||||
table_max = sizeof(tw_aen_string)/sizeof(char *);
|
||||
table_max = ARRAY_SIZE(tw_aen_string);
|
||||
if ((aen & 0x0ff) < table_max) {
|
||||
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);
|
||||
|
||||
+8
-11
@@ -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());
|
||||
hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET);
|
||||
hostdata->dev = dev;
|
||||
|
||||
|
||||
pSlots = pScript + SLOTS_OFFSET;
|
||||
|
||||
/* Fill in the missing routines from the host template */
|
||||
@@ -332,19 +332,18 @@ NCR_700_detect(struct scsi_host_template *tpnt,
|
||||
tpnt->slave_destroy = NCR_700_slave_destroy;
|
||||
tpnt->change_queue_depth = NCR_700_change_queue_depth;
|
||||
tpnt->change_queue_type = NCR_700_change_queue_type;
|
||||
|
||||
|
||||
if(tpnt->name == NULL)
|
||||
tpnt->name = "53c700";
|
||||
if(tpnt->proc_name == NULL)
|
||||
tpnt->proc_name = "53c700";
|
||||
|
||||
|
||||
host = scsi_host_alloc(tpnt, 4);
|
||||
if (!host)
|
||||
return NULL;
|
||||
memset(hostdata->slots, 0, sizeof(struct NCR_700_command_slot)
|
||||
* 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]
|
||||
- (unsigned long)&hostdata->slots[0].SG[0]);
|
||||
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,
|
||||
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]);
|
||||
}
|
||||
|
||||
/* 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]]);
|
||||
}
|
||||
/* now patch up fixed addresses. */
|
||||
script_patch_32(script, MessageLocation,
|
||||
pScript + MSGOUT_OFFSET);
|
||||
@@ -385,17 +382,17 @@ NCR_700_detect(struct scsi_host_template *tpnt,
|
||||
host->hostdata[0] = (unsigned long)hostdata;
|
||||
/* kick the chip */
|
||||
NCR_700_writeb(0xff, host, CTEST9_REG);
|
||||
if(hostdata->chip710)
|
||||
if (hostdata->chip710)
|
||||
hostdata->rev = (NCR_700_readb(host, CTEST8_REG)>>4) & 0x0f;
|
||||
else
|
||||
hostdata->rev = (NCR_700_readb(host, CTEST7_REG)>>4) & 0x0f;
|
||||
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");
|
||||
banner = 1;
|
||||
}
|
||||
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->rev, hostdata->differential ?
|
||||
"(Differential)" : "");
|
||||
|
||||
@@ -361,7 +361,7 @@ int CmdPageStart = (0 - Ent_dsa_zero - sizeof(struct NCR53c7x0_cmd)) & 0xff;
|
||||
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
|
||||
static char setup_buffer[SETUP_BUFFER_SIZE];
|
||||
static char setup_used[MAX_SETUP_STRINGS];
|
||||
@@ -2190,15 +2190,15 @@ static const struct {
|
||||
*/
|
||||
|
||||
|
||||
static void
|
||||
static void
|
||||
synchronous (struct Scsi_Host *host, int target, char *msg) {
|
||||
struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
|
||||
host->hostdata[0];
|
||||
int desire, divisor, i, limit;
|
||||
unsigned char scntl3, sxfer;
|
||||
/* The diagnostic message fits on one line, even with max. width integers */
|
||||
char buf[80];
|
||||
|
||||
char buf[80];
|
||||
|
||||
/* Desired transfer clock in Hz */
|
||||
desire = 1000000000L / (msg[3] * 4);
|
||||
/* Scale the available SCSI clock by 10 so we get tenths */
|
||||
@@ -2209,14 +2209,14 @@ synchronous (struct Scsi_Host *host, int target, char *msg) {
|
||||
msg[4] = 8;
|
||||
|
||||
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);
|
||||
|
||||
limit = (sizeof(syncs) / sizeof(syncs[0]) -1);
|
||||
limit = ARRAY_SIZE(syncs) - 1;
|
||||
for (i = 0; (i < limit) && (divisor > syncs[i].div); ++i);
|
||||
|
||||
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);
|
||||
|
||||
msg[3] = ((1000000000L / hostdata->scsi_clock) * syncs[i].div / 10 / 4);
|
||||
|
||||
@@ -213,16 +213,16 @@ static void *addresses[] = {
|
||||
(void *) 0xd8000,
|
||||
(void *) 0xc8000
|
||||
};
|
||||
#define ADDRESS_COUNT (sizeof( addresses ) / sizeof( unsigned ))
|
||||
#define ADDRESS_COUNT ARRAY_SIZE(addresses)
|
||||
#endif /* USE_BIOS */
|
||||
|
||||
/* possible i/o port addresses */
|
||||
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 */
|
||||
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 */
|
||||
#if USE_BIOS
|
||||
@@ -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},};
|
||||
|
||||
#define SIGNATURE_COUNT (sizeof( signatures ) / sizeof( struct signature ))
|
||||
#define SIGNATURE_COUNT ARRAY_SIZE(signatures)
|
||||
#endif /* USE_BIOS */
|
||||
|
||||
/* ============================================================ */
|
||||
|
||||
@@ -641,13 +641,13 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex)
|
||||
cp[sizeof(str->pid)] = c;
|
||||
} else {
|
||||
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 */
|
||||
inqstrcpy (mp->model, str->pid);
|
||||
}
|
||||
|
||||
if (tindex < (sizeof(container_types)/sizeof(char *))){
|
||||
if (tindex < ARRAY_SIZE(container_types)){
|
||||
char *findit = str->pid;
|
||||
|
||||
for ( ; *findit != ' '; findit++); /* walk till we find a space */
|
||||
@@ -1576,7 +1576,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
|
||||
* see: <vendor>.c i.e. aac.c
|
||||
*/
|
||||
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 */
|
||||
aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));
|
||||
scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
|
||||
@@ -2381,7 +2381,7 @@ static struct aac_srb_status_info srb_status_info[] = {
|
||||
{ SRB_STATUS_SUCCESS, "Success"},
|
||||
{ SRB_STATUS_ABORTED, "Aborted Command"},
|
||||
{ SRB_STATUS_ABORT_FAILED, "Abort Failed"},
|
||||
{ SRB_STATUS_ERROR, "Error Event"},
|
||||
{ SRB_STATUS_ERROR, "Error Event"},
|
||||
{ SRB_STATUS_BUSY, "Device Busy"},
|
||||
{ SRB_STATUS_INVALID_REQUEST, "Invalid Request"},
|
||||
{ SRB_STATUS_INVALID_PATH_ID, "Invalid Path ID"},
|
||||
@@ -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_REQUEST_FLUSHED, "Request Flushed"},
|
||||
{ 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_BAD_FUNCTION, "Bad Function"},
|
||||
{ SRB_STATUS_ERROR_RECOVERY, "Error Recovery"},
|
||||
@@ -2415,11 +2415,9 @@ char *aac_get_status_string(u32 status)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i < (sizeof(srb_status_info)/sizeof(struct aac_srb_status_info)); i++ ){
|
||||
if(srb_status_info[i].status == status){
|
||||
for (i = 0; i < ARRAY_SIZE(srb_status_info); i++)
|
||||
if (srb_status_info[i].status == status)
|
||||
return srb_status_info[i].str;
|
||||
}
|
||||
}
|
||||
|
||||
return "Bad Status Code";
|
||||
}
|
||||
|
||||
@@ -535,7 +535,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
|
||||
default:
|
||||
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",
|
||||
le32_to_cpu(srbcmd->sg.count)));
|
||||
rcode = -EINVAL;
|
||||
|
||||
+14
-17
@@ -1011,7 +1011,7 @@ static int __init do_setup(char *str)
|
||||
|
||||
int count=setup_idx;
|
||||
|
||||
get_options(str, sizeof(ints)/sizeof(int), ints);
|
||||
get_options(str, ARRAY_SIZE(ints), ints);
|
||||
aha1542_setup(str,ints);
|
||||
|
||||
return count<setup_idx;
|
||||
@@ -1072,8 +1072,7 @@ static int __init aha1542_detect(struct scsi_host_template * tpnt)
|
||||
int slot = 0;
|
||||
int pos = 0;
|
||||
|
||||
for (indx = 0; (slot != MCA_NOTFOUND) &&
|
||||
(indx < sizeof(bases)/sizeof(bases[0])); indx++) {
|
||||
for (indx = 0; (slot != MCA_NOTFOUND) && (indx < ARRAY_SIZE(bases)); indx++) {
|
||||
|
||||
if (bases[indx])
|
||||
continue;
|
||||
@@ -1083,10 +1082,9 @@ static int __init aha1542_detect(struct scsi_host_template * tpnt)
|
||||
if (slot == MCA_NOTFOUND)
|
||||
break;
|
||||
|
||||
|
||||
/* Found one */
|
||||
pos = mca_read_stored_pos(slot, 3);
|
||||
|
||||
|
||||
/* Decode address */
|
||||
if (pos & 0x80) {
|
||||
if (pos & 0x02) {
|
||||
@@ -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_procfn(slot, NULL, NULL);
|
||||
mca_mark_as_used(slot);
|
||||
|
||||
|
||||
/* Go on */
|
||||
slot++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hunt for ISA Plug'n'Pray Adaptecs (AHA1535)
|
||||
*/
|
||||
|
||||
|
||||
if(isapnp)
|
||||
{
|
||||
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])
|
||||
continue;
|
||||
pdev = pnp_find_dev(NULL, ISAPNP_VENDOR('A', 'D', 'P'),
|
||||
@@ -1144,29 +1141,29 @@ static int __init aha1542_detect(struct scsi_host_template * tpnt)
|
||||
/*
|
||||
* Activate the PnP card
|
||||
*/
|
||||
|
||||
|
||||
if(pnp_device_attach(pdev)<0)
|
||||
continue;
|
||||
|
||||
|
||||
if(pnp_activate_dev(pdev)<0) {
|
||||
pnp_device_detach(pdev);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(!pnp_port_valid(pdev, 0)) {
|
||||
pnp_device_detach(pdev);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
bases[indx] = pnp_port_start(pdev, 0);
|
||||
|
||||
|
||||
/* The card can be queried for its DMA, we have
|
||||
the DMA set up that is enough */
|
||||
|
||||
|
||||
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")) {
|
||||
shpnt = scsi_register(tpnt,
|
||||
sizeof(struct aha1542_hostdata));
|
||||
|
||||
@@ -107,7 +107,7 @@ struct aic7770_identity aic7770_ident_table[] =
|
||||
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 *
|
||||
aic7770_find_device(uint32_t id)
|
||||
|
||||
@@ -68,8 +68,6 @@ struct scb_platform_data;
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#define NUM_ELEMENTS(array) (sizeof(array) / sizeof(*array))
|
||||
|
||||
#define ALL_CHANNELS '\0'
|
||||
#define ALL_TARGETS_MASK 0xFFFF
|
||||
#define INITIATOR_WILDCARD (~0)
|
||||
|
||||
@@ -59,7 +59,7 @@ char *ahd_chip_names[] =
|
||||
"aic7902",
|
||||
"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.
|
||||
@@ -77,7 +77,7 @@ static struct ahd_hard_error_entry ahd_hard_errors[] = {
|
||||
{ MPARERR, "Scratch or SCB Memory 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[] =
|
||||
{
|
||||
@@ -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
|
||||
* 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 */
|
||||
#include "aic79xx_seq.h"
|
||||
@@ -7259,7 +7259,7 @@ ahd_qinfifo_count(struct ahd_softc *ahd)
|
||||
return (wrap_qinfifonext - wrap_qinpos);
|
||||
else
|
||||
return (wrap_qinfifonext
|
||||
+ NUM_ELEMENTS(ahd->qinfifo) - wrap_qinpos);
|
||||
+ ARRAY_SIZE(ahd->qinfifo) - wrap_qinpos);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -8619,7 +8619,7 @@ ahd_check_patch(struct ahd_softc *ahd, struct patch **start_patch,
|
||||
struct patch *last_patch;
|
||||
u_int num_patches;
|
||||
|
||||
num_patches = sizeof(patches)/sizeof(struct patch);
|
||||
num_patches = ARRAY_SIZE(patches);
|
||||
last_patch = &patches[num_patches];
|
||||
cur_patch = *start_patch;
|
||||
|
||||
|
||||
@@ -916,7 +916,7 @@ ahd_linux_setup_iocell_info(u_long index, int instance, int targ, int32_t value)
|
||||
{
|
||||
|
||||
if ((instance >= 0)
|
||||
&& (instance < NUM_ELEMENTS(aic79xx_iocell_info))) {
|
||||
&& (instance < ARRAY_SIZE(aic79xx_iocell_info))) {
|
||||
uint8_t *iocell_info;
|
||||
|
||||
iocell_info = (uint8_t*)&aic79xx_iocell_info[instance];
|
||||
@@ -934,7 +934,7 @@ ahd_linux_setup_tag_info_global(char *p)
|
||||
tags = simple_strtoul(p + 1, NULL, 0) & 0xff;
|
||||
printf("Setting Global Tags= %d\n", tags);
|
||||
|
||||
for (i = 0; i < NUM_ELEMENTS(aic79xx_tag_info); i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(aic79xx_tag_info); i++) {
|
||||
for (j = 0; j < AHD_NUM_TARGETS; j++) {
|
||||
aic79xx_tag_info[i].tag_commands[j] = tags;
|
||||
}
|
||||
@@ -946,7 +946,7 @@ ahd_linux_setup_tag_info(u_long arg, int instance, int targ, int32_t value)
|
||||
{
|
||||
|
||||
if ((instance >= 0) && (targ >= 0)
|
||||
&& (instance < NUM_ELEMENTS(aic79xx_tag_info))
|
||||
&& (instance < ARRAY_SIZE(aic79xx_tag_info))
|
||||
&& (targ < AHD_NUM_TARGETS)) {
|
||||
aic79xx_tag_info[instance].tag_commands[targ] = value & 0x1FF;
|
||||
if (bootverbose)
|
||||
@@ -1072,21 +1072,21 @@ aic79xx_setup(char *s)
|
||||
end = strchr(s, '\0');
|
||||
|
||||
/*
|
||||
* XXX ia64 gcc isn't smart enough to know that NUM_ELEMENTS
|
||||
* XXX ia64 gcc isn't smart enough to know that ARRAY_SIZE
|
||||
* will never be 0 in this case.
|
||||
*/
|
||||
n = 0;
|
||||
*/
|
||||
n = 0;
|
||||
|
||||
while ((p = strsep(&s, ",.")) != NULL) {
|
||||
if (*p == '\0')
|
||||
continue;
|
||||
for (i = 0; i < NUM_ELEMENTS(options); i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(options); i++) {
|
||||
|
||||
n = strlen(options[i].name);
|
||||
if (strncmp(options[i].name, p, n) == 0)
|
||||
break;
|
||||
}
|
||||
if (i == NUM_ELEMENTS(options))
|
||||
if (i == ARRAY_SIZE(options))
|
||||
continue;
|
||||
|
||||
if (strncmp(p, "global_tag_depth", n) == 0) {
|
||||
@@ -1294,7 +1294,7 @@ ahd_platform_init(struct ahd_softc *ahd)
|
||||
/*
|
||||
* Lookup and commit any modified IO Cell options.
|
||||
*/
|
||||
if (ahd->unit < NUM_ELEMENTS(aic79xx_iocell_info)) {
|
||||
if (ahd->unit < ARRAY_SIZE(aic79xx_iocell_info)) {
|
||||
struct ahd_linux_iocell_opts *iocell_opts;
|
||||
|
||||
iocell_opts = &aic79xx_iocell_info[ahd->unit];
|
||||
@@ -1426,7 +1426,7 @@ ahd_linux_user_tagdepth(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
|
||||
|
||||
tags = 0;
|
||||
if ((ahd->user_discenable & devinfo->target_mask) != 0) {
|
||||
if (ahd->unit >= NUM_ELEMENTS(aic79xx_tag_info)) {
|
||||
if (ahd->unit >= ARRAY_SIZE(aic79xx_tag_info)) {
|
||||
|
||||
if (warned_user == 0) {
|
||||
printf(KERN_WARNING
|
||||
|
||||
@@ -201,7 +201,7 @@ struct ahd_pci_identity ahd_pci_ident_table [] =
|
||||
}
|
||||
};
|
||||
|
||||
const u_int ahd_num_pci_devs = NUM_ELEMENTS(ahd_pci_ident_table);
|
||||
const u_int ahd_num_pci_devs = ARRAY_SIZE(ahd_pci_ident_table);
|
||||
|
||||
#define DEVCONFIG 0x40
|
||||
#define PCIXINITPAT 0x0000E000ul
|
||||
|
||||
@@ -76,11 +76,9 @@ static u_int
|
||||
ahd_calc_syncsrate(u_int period_factor)
|
||||
{
|
||||
int i;
|
||||
int num_syncrates;
|
||||
|
||||
num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]);
|
||||
/* See if the period is in the "exception" table */
|
||||
for (i = 0; i < num_syncrates; i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(scsi_syncrates); i++) {
|
||||
|
||||
if (period_factor == scsi_syncrates[i].period_factor) {
|
||||
/* Period in kHz */
|
||||
|
||||
@@ -69,8 +69,6 @@ struct seeprom_descriptor;
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#define NUM_ELEMENTS(array) (sizeof(array) / sizeof(*array))
|
||||
|
||||
#define ALL_CHANNELS '\0'
|
||||
#define ALL_TARGETS_MASK 0xFFFF
|
||||
#define INITIATOR_WILDCARD (~0)
|
||||
|
||||
@@ -68,7 +68,7 @@ char *ahc_chip_names[] =
|
||||
"aic7892",
|
||||
"aic7899"
|
||||
};
|
||||
static const u_int num_chip_names = NUM_ELEMENTS(ahc_chip_names);
|
||||
static const u_int num_chip_names = ARRAY_SIZE(ahc_chip_names);
|
||||
|
||||
/*
|
||||
* Hardware error codes.
|
||||
@@ -88,7 +88,7 @@ static struct ahc_hard_error_entry ahc_hard_errors[] = {
|
||||
{ PCIERRSTAT, "PCI Error detected" },
|
||||
{ CIOPARERR, "CIOBUS Parity Error" },
|
||||
};
|
||||
static const u_int num_errors = NUM_ELEMENTS(ahc_hard_errors);
|
||||
static const u_int num_errors = ARRAY_SIZE(ahc_hard_errors);
|
||||
|
||||
static struct ahc_phase_table_entry ahc_phase_table[] =
|
||||
{
|
||||
@@ -108,7 +108,7 @@ static struct ahc_phase_table_entry ahc_phase_table[] =
|
||||
* In most cases we only wish to itterate over real phases, so
|
||||
* exclude the last element from the count.
|
||||
*/
|
||||
static const u_int num_phases = NUM_ELEMENTS(ahc_phase_table) - 1;
|
||||
static const u_int num_phases = ARRAY_SIZE(ahc_phase_table) - 1;
|
||||
|
||||
/*
|
||||
* Valid SCSIRATE values. (p. 3-17)
|
||||
@@ -6367,7 +6367,7 @@ ahc_check_patch(struct ahc_softc *ahc, struct patch **start_patch,
|
||||
struct patch *last_patch;
|
||||
u_int num_patches;
|
||||
|
||||
num_patches = sizeof(patches)/sizeof(struct patch);
|
||||
num_patches = ARRAY_SIZE(patches);
|
||||
last_patch = &patches[num_patches];
|
||||
cur_patch = *start_patch;
|
||||
|
||||
|
||||
@@ -886,7 +886,7 @@ ahc_linux_setup_tag_info_global(char *p)
|
||||
tags = simple_strtoul(p + 1, NULL, 0) & 0xff;
|
||||
printf("Setting Global Tags= %d\n", tags);
|
||||
|
||||
for (i = 0; i < NUM_ELEMENTS(aic7xxx_tag_info); i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(aic7xxx_tag_info); i++) {
|
||||
for (j = 0; j < AHC_NUM_TARGETS; j++) {
|
||||
aic7xxx_tag_info[i].tag_commands[j] = tags;
|
||||
}
|
||||
@@ -898,7 +898,7 @@ ahc_linux_setup_tag_info(u_long arg, int instance, int targ, int32_t value)
|
||||
{
|
||||
|
||||
if ((instance >= 0) && (targ >= 0)
|
||||
&& (instance < NUM_ELEMENTS(aic7xxx_tag_info))
|
||||
&& (instance < ARRAY_SIZE(aic7xxx_tag_info))
|
||||
&& (targ < AHC_NUM_TARGETS)) {
|
||||
aic7xxx_tag_info[instance].tag_commands[targ] = value & 0xff;
|
||||
if (bootverbose)
|
||||
@@ -1020,7 +1020,7 @@ aic7xxx_setup(char *s)
|
||||
end = strchr(s, '\0');
|
||||
|
||||
/*
|
||||
* XXX ia64 gcc isn't smart enough to know that NUM_ELEMENTS
|
||||
* XXX ia64 gcc isn't smart enough to know that ARRAY_SIZE
|
||||
* will never be 0 in this case.
|
||||
*/
|
||||
n = 0;
|
||||
@@ -1028,13 +1028,13 @@ aic7xxx_setup(char *s)
|
||||
while ((p = strsep(&s, ",.")) != NULL) {
|
||||
if (*p == '\0')
|
||||
continue;
|
||||
for (i = 0; i < NUM_ELEMENTS(options); i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(options); i++) {
|
||||
|
||||
n = strlen(options[i].name);
|
||||
if (strncmp(options[i].name, p, n) == 0)
|
||||
break;
|
||||
}
|
||||
if (i == NUM_ELEMENTS(options))
|
||||
if (i == ARRAY_SIZE(options))
|
||||
continue;
|
||||
|
||||
if (strncmp(p, "global_tag_depth", n) == 0) {
|
||||
@@ -1360,7 +1360,7 @@ ahc_linux_user_tagdepth(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
|
||||
|
||||
tags = 0;
|
||||
if ((ahc->user_discenable & devinfo->target_mask) != 0) {
|
||||
if (ahc->unit >= NUM_ELEMENTS(aic7xxx_tag_info)) {
|
||||
if (ahc->unit >= ARRAY_SIZE(aic7xxx_tag_info)) {
|
||||
if (warned_user == 0) {
|
||||
|
||||
printf(KERN_WARNING
|
||||
|
||||
@@ -553,7 +553,7 @@ struct ahc_pci_identity ahc_pci_ident_table [] =
|
||||
}
|
||||
};
|
||||
|
||||
const u_int ahc_num_pci_devs = NUM_ELEMENTS(ahc_pci_ident_table);
|
||||
const u_int ahc_num_pci_devs = ARRAY_SIZE(ahc_pci_ident_table);
|
||||
|
||||
#define AHC_394X_SLOT_CHANNEL_A 4
|
||||
#define AHC_394X_SLOT_CHANNEL_B 5
|
||||
|
||||
@@ -77,11 +77,9 @@ static u_int
|
||||
ahc_calc_syncsrate(u_int period_factor)
|
||||
{
|
||||
int i;
|
||||
int num_syncrates;
|
||||
|
||||
num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]);
|
||||
/* See if the period is in the "exception" table */
|
||||
for (i = 0; i < num_syncrates; i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(scsi_syncrates); i++) {
|
||||
|
||||
if (period_factor == scsi_syncrates[i].period_factor) {
|
||||
/* Period in kHz */
|
||||
|
||||
@@ -1565,7 +1565,7 @@ aic7xxx_check_patch(struct aic7xxx_host *p,
|
||||
struct sequencer_patch *last_patch;
|
||||
int num_patches;
|
||||
|
||||
num_patches = sizeof(sequencer_patches)/sizeof(struct sequencer_patch);
|
||||
num_patches = ARRAY_SIZE(sequencer_patches);
|
||||
last_patch = &sequencer_patches[num_patches];
|
||||
cur_patch = *start_patch;
|
||||
|
||||
|
||||
+13
-20
@@ -114,8 +114,7 @@ static const struct value_name_pair maint_in_arr[] = {
|
||||
{0xd, "Report supported task management functions"},
|
||||
{0xe, "Report priority"},
|
||||
};
|
||||
#define MAINT_IN_SZ \
|
||||
(int)(sizeof(maint_in_arr) / sizeof(maint_in_arr[0]))
|
||||
#define MAINT_IN_SZ ARRAY_SIZE(maint_in_arr)
|
||||
|
||||
static const struct value_name_pair maint_out_arr[] = {
|
||||
{0x6, "Set device identifier"},
|
||||
@@ -123,34 +122,29 @@ static const struct value_name_pair maint_out_arr[] = {
|
||||
{0xb, "Change aliases"},
|
||||
{0xe, "Set priority"},
|
||||
};
|
||||
#define MAINT_OUT_SZ \
|
||||
(int)(sizeof(maint_out_arr) / sizeof(maint_out_arr[0]))
|
||||
#define MAINT_OUT_SZ ARRAY_SIZE(maint_out_arr)
|
||||
|
||||
static const struct value_name_pair serv_in12_arr[] = {
|
||||
{0x1, "Read media serial number"},
|
||||
};
|
||||
#define SERV_IN12_SZ \
|
||||
(int)(sizeof(serv_in12_arr) / sizeof(serv_in12_arr[0]))
|
||||
#define SERV_IN12_SZ ARRAY_SIZE(serv_in12_arr)
|
||||
|
||||
static const struct value_name_pair serv_out12_arr[] = {
|
||||
{-1, "dummy entry"},
|
||||
};
|
||||
#define SERV_OUT12_SZ \
|
||||
(int)(sizeof(serv_out12_arr) / sizeof(serv_in12_arr[0]))
|
||||
#define SERV_OUT12_SZ ARRAY_SIZE(serv_out12_arr)
|
||||
|
||||
static const struct value_name_pair serv_in16_arr[] = {
|
||||
{0x10, "Read capacity(16)"},
|
||||
{0x11, "Read long(16)"},
|
||||
};
|
||||
#define SERV_IN16_SZ \
|
||||
(int)(sizeof(serv_in16_arr) / sizeof(serv_in16_arr[0]))
|
||||
#define SERV_IN16_SZ ARRAY_SIZE(serv_in16_arr)
|
||||
|
||||
static const struct value_name_pair serv_out16_arr[] = {
|
||||
{0x11, "Write long(16)"},
|
||||
{0x1f, "Notify data transfer device(16)"},
|
||||
};
|
||||
#define SERV_OUT16_SZ \
|
||||
(int)(sizeof(serv_out16_arr) / sizeof(serv_in16_arr[0]))
|
||||
#define SERV_OUT16_SZ ARRAY_SIZE(serv_out16_arr)
|
||||
|
||||
static const struct value_name_pair variable_length_arr[] = {
|
||||
{0x1, "Rebuild(32)"},
|
||||
@@ -190,8 +184,7 @@ static const struct value_name_pair variable_length_arr[] = {
|
||||
{0x8f7e, "Perform SCSI command (osd)"},
|
||||
{0x8f7f, "Perform task management function (osd)"},
|
||||
};
|
||||
#define VARIABLE_LENGTH_SZ \
|
||||
(int)(sizeof(variable_length_arr) / sizeof(variable_length_arr[0]))
|
||||
#define VARIABLE_LENGTH_SZ ARRAY_SIZE(variable_length_arr)
|
||||
|
||||
static const char * get_sa_name(const struct value_name_pair * arr,
|
||||
int arr_sz, int service_action)
|
||||
@@ -1290,10 +1283,10 @@ EXPORT_SYMBOL(scsi_print_command);
|
||||
#ifdef CONFIG_SCSI_CONSTANTS
|
||||
|
||||
static const char * const hostbyte_table[]={
|
||||
"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
|
||||
"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
|
||||
"DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",
|
||||
"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"};
|
||||
#define NUM_HOSTBYTE_STRS (sizeof(hostbyte_table) / sizeof(const char *))
|
||||
#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table)
|
||||
|
||||
void scsi_print_hostbyte(int scsiresult)
|
||||
{
|
||||
@@ -1303,7 +1296,7 @@ void scsi_print_hostbyte(int scsiresult)
|
||||
if (hb < NUM_HOSTBYTE_STRS)
|
||||
printk("(%s) ", hostbyte_table[hb]);
|
||||
else
|
||||
printk("is invalid ");
|
||||
printk("is invalid ");
|
||||
}
|
||||
#else
|
||||
void scsi_print_hostbyte(int scsiresult)
|
||||
@@ -1315,14 +1308,14 @@ void scsi_print_hostbyte(int scsiresult)
|
||||
#ifdef CONFIG_SCSI_CONSTANTS
|
||||
|
||||
static const char * const driverbyte_table[]={
|
||||
"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR",
|
||||
"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR",
|
||||
"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
|
||||
#define NUM_DRIVERBYTE_STRS (sizeof(driverbyte_table) / sizeof(const char *))
|
||||
#define NUM_DRIVERBYTE_STRS ARRAY_SIZE(driverbyte_table)
|
||||
|
||||
static const char * const driversuggest_table[]={"SUGGEST_OK",
|
||||
"SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE",
|
||||
"SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"};
|
||||
#define NUM_SUGGEST_STRS (sizeof(driversuggest_table) / sizeof(const char *))
|
||||
#define NUM_SUGGEST_STRS ARRAY_SIZE(driversuggest_table)
|
||||
|
||||
void scsi_print_driverbyte(int scsiresult)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user