Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

[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
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -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)
	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)
					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);
+8 −11
Original line number Original line Diff line number Diff line
@@ -338,7 +338,6 @@ NCR_700_detect(struct scsi_host_template *tpnt,
	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;
@@ -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);
+7 −7
Original line number Original line Diff line number Diff line
@@ -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];
@@ -2212,7 +2212,7 @@ synchronous (struct Scsi_Host *host, int target, char *msg) {
    	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)
+4 −4
Original line number Original line Diff line number Diff line
@@ -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 {
	{
	{
"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 */


/* ============================================================ */
/* ============================================================ */
+8 −10
Original line number Original line Diff line number Diff line
@@ -647,7 +647,7 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex)
		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)
		 *	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;
@@ -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";
}
}
Loading