All of lore.kernel.org
 help / color / mirror / Atom feed
* [Kernel-janitors] [PATCH] drivers/scsi/aic7xxx_old MIN/MAX/NUMBER
@ 2004-04-22 22:15 Michael Veeck
  2004-04-22 22:16 ` [Kernel-janitors] [PATCH] drivers/scsi/aic7xxxx MIN/MAX/NUM_ELEMENTS Michael Veeck
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Veeck @ 2004-04-22 22:15 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 156 bytes --]

Patch (against 2.6.6-rc1) removes unnecessary min/max/number macros and 
changes calls to use kernel.h macros instead.

Feedback is always welcome
Michael


[-- Attachment #2: minmax_drivers_scsi_aisold.patch --]
[-- Type: text/plain, Size: 7414 bytes --]

diff -Naur -X dontdiff-osdl linux-2.6.5.org/drivers/scsi/aic7xxx_old/aic7xxx_proc.c linux-2.6.5.new/drivers/scsi/aic7xxx_old/aic7xxx_proc.c
--- linux-2.6.5.org/drivers/scsi/aic7xxx_old/aic7xxx_proc.c	2004-04-04 05:38:14.000000000 +0200
+++ linux-2.6.5.new/drivers/scsi/aic7xxx_old/aic7xxx_proc.c	2004-04-22 23:47:18.000000000 +0200
@@ -319,13 +319,13 @@
         aic_dev->r_total+aic_dev->w_total, aic_dev->r_total, aic_dev->w_total);
     size += sprintf(BLS, "%s\n", HDRB);
     size += sprintf(BLS, "   Reads:");
-    for (i = 0; i < NUMBER(aic_dev->r_bins); i++)
+    for (i = 0; i < ARRAY_SIZE(aic_dev->r_bins); i++)
     {
       size += sprintf(BLS, " %10ld", aic_dev->r_bins[i]);
     }
     size += sprintf(BLS, "\n");
     size += sprintf(BLS, "  Writes:");
-    for (i = 0; i < NUMBER(aic_dev->w_bins); i++)
+    for (i = 0; i < ARRAY_SIZE(aic_dev->w_bins); i++)
     {
       size += sprintf(BLS, " %10ld", aic_dev->w_bins[i]);
     }
@@ -347,7 +347,7 @@
   else
   {
     *start = buffer;
-    length = MIN(length, size - offset);
+    length = min_t(int, length, size - offset);
     memcpy(buffer, &aic7xxx_buffer[offset], length);
   }
 
diff -Naur -X dontdiff-osdl linux-2.6.5.org/drivers/scsi/aic7xxx_old.c linux-2.6.5.new/drivers/scsi/aic7xxx_old.c
--- linux-2.6.5.org/drivers/scsi/aic7xxx_old.c	2004-04-22 19:04:33.000000000 +0200
+++ linux-2.6.5.new/drivers/scsi/aic7xxx_old.c	2004-04-22 23:46:47.000000000 +0200
@@ -254,9 +254,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
@@ -1376,7 +1373,7 @@
 
   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 +1420,7 @@
                   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 +1444,7 @@
                     }
                   }
                   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 +1655,7 @@
         {
           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;
         }
@@ -1884,7 +1881,7 @@
       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 +1889,7 @@
       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 +1913,7 @@
       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 +2054,7 @@
     else
       maxoffset = MAX_OFFSET_8BIT;
   }
-  *offset = MIN(*offset, maxoffset);
+  *offset = min(*offset, maxoffset);
 }
 
 /*+F*************************************************************************
@@ -2570,7 +2567,7 @@
         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)
@@ -5042,7 +5039,7 @@
             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 +5083,8 @@
            * 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 +5205,7 @@
             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 +6410,7 @@
     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 +6559,7 @@
       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 +6670,7 @@
     }
     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 +6847,7 @@
     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?
@@ -9199,7 +9196,7 @@
     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,
@@ -9698,7 +9695,7 @@
    * EISA/VL-bus card signature probe.
    */
   slot = MINSLOT;
-  while ( (slot <= MAXSLOT) && 
+  while ( (slot <= MAXSLOT) &&
          !(aic7xxx_no_probe) )
   {
     base = SLOTBASE(slot) + MINREG;
@@ -10097,7 +10094,7 @@
       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)

[-- Attachment #3: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Kernel-janitors] [PATCH] drivers/scsi/aic7xxxx MIN/MAX/NUM_ELEMENTS
  2004-04-22 22:15 [Kernel-janitors] [PATCH] drivers/scsi/aic7xxx_old MIN/MAX/NUMBER Michael Veeck
@ 2004-04-22 22:16 ` Michael Veeck
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Veeck @ 2004-04-22 22:16 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 162 bytes --]

Patch (against 2.6.6-rc1) removes unnecessary min/max/num_elements 
macros and changes calls to use kernel.h macros instead.

Feedback is always welcome
Michael


[-- Attachment #2: minmax_drivers_scsi_aic7.patch --]
[-- Type: text/plain, Size: 17945 bytes --]

diff -Naur -X /data/temp/dontdiff-osdl linux-2.6.5.org/drivers/scsi/aic7xxx/aic7770.c linux-2.6.5.new/drivers/scsi/aic7xxx/aic7770.c
--- linux-2.6.5.org/drivers/scsi/aic7xxx/aic7770.c	2004-04-04 05:38:23.000000000 +0200
+++ linux-2.6.5.new/drivers/scsi/aic7xxx/aic7770.c	2004-04-22 19:22:40.000000000 +0200
@@ -107,7 +107,7 @@
 		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)
diff -Naur -X /data/temp/dontdiff-osdl linux-2.6.5.org/drivers/scsi/aic7xxx/aic79xx.h linux-2.6.5.new/drivers/scsi/aic7xxx/aic79xx.h
--- linux-2.6.5.org/drivers/scsi/aic7xxx/aic79xx.h	2004-04-04 05:37:36.000000000 +0200
+++ linux-2.6.5.new/drivers/scsi/aic7xxx/aic79xx.h	2004-04-22 19:22:40.000000000 +0200
@@ -53,14 +53,6 @@
 struct scb_platform_data;
 
 /****************************** Useful Macros *********************************/
-#ifndef MAX
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
 #ifndef TRUE
 #define TRUE 1
 #endif
@@ -68,8 +60,6 @@
 #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)
diff -Naur -X /data/temp/dontdiff-osdl linux-2.6.5.org/drivers/scsi/aic7xxx/aic79xx_core.c linux-2.6.5.new/drivers/scsi/aic7xxx/aic79xx_core.c
--- linux-2.6.5.org/drivers/scsi/aic7xxx/aic79xx_core.c	2004-04-04 05:36:12.000000000 +0200
+++ linux-2.6.5.new/drivers/scsi/aic7xxx/aic79xx_core.c	2004-04-22 20:04:01.000000000 +0200
@@ -63,7 +63,7 @@
 	"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.
@@ -81,7 +81,7 @@
 	{ 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[] =
 {
@@ -101,7 +101,7 @@
  * 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"
@@ -2769,14 +2769,14 @@
 		transinfo = &tinfo->goal;
 	*ppr_options &= (transinfo->ppr_options|MSG_EXT_PPR_PCOMP_EN);
 	if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) {
-		maxsync = MAX(maxsync, AHD_SYNCRATE_ULTRA2);
+		maxsync = max_t(u_int, maxsync, AHD_SYNCRATE_ULTRA2);
 		*ppr_options &= ~MSG_EXT_PPR_DT_REQ;
 	}
 	if (transinfo->period == 0) {
 		*period = 0;
 		*ppr_options = 0;
 	} else {
-		*period = MAX(*period, transinfo->period);
+		*period = max_t(u_int, *period, transinfo->period);
 		ahd_find_syncrate(ahd, period, ppr_options, maxsync);
 	}
 }
@@ -2843,12 +2843,12 @@
 			maxoffset = MAX_OFFSET_PACED;
 	} else
 		maxoffset = MAX_OFFSET_NON_PACED;
-	*offset = MIN(*offset, maxoffset);
+	*offset = min(*offset, maxoffset);
 	if (tinfo != NULL) {
 		if (role == ROLE_TARGET)
-			*offset = MIN(*offset, tinfo->user.offset);
+			*offset = min_t(u_int, *offset, tinfo->user.offset);
 		else
-			*offset = MIN(*offset, tinfo->goal.offset);
+			*offset = min_t(u_int, *offset, tinfo->goal.offset);
 	}
 }
 
@@ -2874,9 +2874,9 @@
 	}
 	if (tinfo != NULL) {
 		if (role == ROLE_TARGET)
-			*bus_width = MIN(tinfo->user.width, *bus_width);
+			*bus_width = min_t(u_int, tinfo->user.width, *bus_width);
 		else
-			*bus_width = MIN(tinfo->goal.width, *bus_width);
+			*bus_width = min_t(u_int, tinfo->goal.width, *bus_width);
 	}
 }
 
@@ -6043,9 +6043,9 @@
 #endif
 	}
 
-	newcount = MIN(scb_data->sense_left, scb_data->scbs_left);
-	newcount = MIN(newcount, scb_data->sgs_left);
-	newcount = MIN(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs));
+	newcount = min(scb_data->sense_left, scb_data->scbs_left);
+	newcount = min(newcount, scb_data->sgs_left);
+	newcount = min(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs));
 	scb_data->sense_left -= newcount;
 	scb_data->scbs_left -= newcount;
 	scb_data->sgs_left -= newcount;
@@ -7256,7 +7256,7 @@
 		return (wrap_qinfifonext - wrap_qinpos);
 	else
 		return (wrap_qinfifonext
-		      + NUM_ELEMENTS(ahd->qinfifo) - wrap_qinpos);
+		      + ARRAY_SIZE(ahd->qinfifo) - wrap_qinpos);
 }
 
 void
@@ -8632,7 +8632,7 @@
 		if (skip_addr > i) {
 			int end_addr;
 
-			end_addr = MIN(address, skip_addr);
+			end_addr = min(address, skip_addr);
 			address_offset += end_addr - i;
 			i = skip_addr;
 		} else {
diff -Naur -X /data/temp/dontdiff-osdl linux-2.6.5.org/drivers/scsi/aic7xxx/aic79xx_osm.c linux-2.6.5.new/drivers/scsi/aic7xxx/aic79xx_osm.c
--- linux-2.6.5.org/drivers/scsi/aic7xxx/aic79xx_osm.c	2004-04-04 05:37:23.000000000 +0200
+++ linux-2.6.5.new/drivers/scsi/aic7xxx/aic79xx_osm.c	2004-04-22 20:08:49.998425648 +0200
@@ -1914,7 +1914,7 @@
 {
 
 	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)
@@ -1926,7 +1926,7 @@
 ahd_linux_setup_rd_strm_info(u_long arg, int instance, int targ, int32_t value)
 {
 	if ((instance >= 0)
-	 && (instance < NUM_ELEMENTS(aic79xx_rd_strm_info))) {
+	 && (instance < ARRAY_SIZE(aic79xx_rd_strm_info))) {
 		aic79xx_rd_strm_info[instance] = value & 0xFFFF;
 		if (bootverbose)
 			printf("rd_strm[%d] = 0x%x\n", instance, value);
@@ -1937,7 +1937,7 @@
 ahd_linux_setup_dv(u_long arg, int instance, int targ, int32_t value)
 {
 	if ((instance >= 0)
-	 && (instance < NUM_ELEMENTS(aic79xx_dv_settings))) {
+	 && (instance < ARRAY_SIZE(aic79xx_dv_settings))) {
 		aic79xx_dv_settings[instance] = value;
 		if (bootverbose)
 			printf("dv[%d] = %d\n", instance, value);
@@ -1949,7 +1949,7 @@
 {
 
 	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];
@@ -1967,7 +1967,7 @@
 	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;
 		}
@@ -2013,7 +2013,7 @@
 	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;  
@@ -2021,13 +2021,13 @@
 	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) {
@@ -2356,7 +2356,7 @@
 	/*
 	 * 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];
@@ -3597,7 +3597,7 @@
 	if (offset == 0)
 		period = AHD_ASYNC_XFER_PERIOD;
 	if (targ->dv_next_narrow_period == 0)
-		targ->dv_next_narrow_period = MAX(period, AHD_SYNCRATE_ULTRA2);
+		targ->dv_next_narrow_period = max_t(uint8_t, period, AHD_SYNCRATE_ULTRA2);
 	if (targ->dv_next_wide_period == 0)
 		targ->dv_next_wide_period = period;
 	if (targ->dv_max_width == 0)
@@ -3879,7 +3879,7 @@
 
 	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
@@ -3908,7 +3908,7 @@
 	static int warned_user;
 	int dv;
 
-	if (ahd->unit >= NUM_ELEMENTS(aic79xx_dv_settings)) {
+	if (ahd->unit >= ARRAY_SIZE(aic79xx_dv_settings)) {
 
 		if (warned_user == 0) {
 			printf(KERN_WARNING
@@ -3946,7 +3946,7 @@
 	 * If we have specific read streaming info for this controller,
 	 * apply it.  Otherwise use the defaults.
 	 */
-	 if (ahd->unit >= NUM_ELEMENTS(aic79xx_rd_strm_info)) {
+	 if (ahd->unit >= ARRAY_SIZE(aic79xx_rd_strm_info)) {
 
 		if (warned_user == 0) {
 
@@ -4582,7 +4582,7 @@
 			u_int sense_offset;
 
 			if (scb->flags & SCB_SENSE) {
-				sense_size = MIN(sizeof(struct scsi_sense_data)
+				sense_size = min_t(u_int, sizeof(struct scsi_sense_data)
 					       - ahd_get_sense_residual(scb),
 						 sizeof(cmd->sense_buffer));
 				sense_offset = 0;
@@ -4593,7 +4593,7 @@
 				 */
 				siu = (struct scsi_status_iu_header *)
 				    scb->sense_data;
-				sense_size = MIN(scsi_4btoul(siu->sense_length),
+				sense_size = min(scsi_4btoul(siu->sense_length),
 						sizeof(cmd->sense_buffer));
 				sense_offset = SIU_SENSE_OFFSET(siu);
 			}
@@ -4914,7 +4914,7 @@
 	offset = user->offset;
 	ppr_options = user->ppr_options;
 	trans_version = user->transport_version;
-	prot_version = MIN(user->protocol_version, SID_ANSI_REV(sid));
+	prot_version = min_t(u_int, user->protocol_version, SID_ANSI_REV(sid));
 
 	/*
 	 * Only attempt SPI3/4 once we've verified that
diff -Naur -X /data/temp/dontdiff-osdl linux-2.6.5.org/drivers/scsi/aic7xxx/aic79xx_pci.c linux-2.6.5.new/drivers/scsi/aic7xxx/aic79xx_pci.c
--- linux-2.6.5.org/drivers/scsi/aic7xxx/aic79xx_pci.c	2004-04-04 05:37:06.000000000 +0200
+++ linux-2.6.5.new/drivers/scsi/aic7xxx/aic79xx_pci.c	2004-04-22 19:22:40.000000000 +0200
@@ -229,7 +229,7 @@
 	}
 };
 
-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
diff -Naur -X /data/temp/dontdiff-osdl linux-2.6.5.org/drivers/scsi/aic7xxx/aic7xxx.h linux-2.6.5.new/drivers/scsi/aic7xxx/aic7xxx.h
--- linux-2.6.5.org/drivers/scsi/aic7xxx/aic7xxx.h	2004-04-04 05:37:07.000000000 +0200
+++ linux-2.6.5.new/drivers/scsi/aic7xxx/aic7xxx.h	2004-04-22 19:22:40.000000000 +0200
@@ -54,14 +54,6 @@
 struct seeprom_descriptor;
 
 /****************************** Useful Macros *********************************/
-#ifndef MAX
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
 #ifndef TRUE
 #define TRUE 1
 #endif
@@ -69,8 +61,6 @@
 #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)
diff -Naur -X /data/temp/dontdiff-osdl linux-2.6.5.org/drivers/scsi/aic7xxx/aic7xxx_core.c linux-2.6.5.new/drivers/scsi/aic7xxx/aic7xxx_core.c
--- linux-2.6.5.org/drivers/scsi/aic7xxx/aic7xxx_core.c	2004-04-04 05:37:06.000000000 +0200
+++ linux-2.6.5.new/drivers/scsi/aic7xxx/aic7xxx_core.c	2004-04-22 20:10:31.715962232 +0200
@@ -73,7 +73,7 @@
 	"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.
@@ -93,7 +93,7 @@
 	{ 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[] =
 {
@@ -113,7 +113,7 @@
  * 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)
@@ -1666,7 +1666,7 @@
 		transinfo = &tinfo->goal;
 	*ppr_options &= transinfo->ppr_options;
 	if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) {
-		maxsync = MAX(maxsync, AHC_SYNCRATE_ULTRA2);
+		maxsync = max_t(u_int, maxsync, AHC_SYNCRATE_ULTRA2);
 		*ppr_options &= ~MSG_EXT_PPR_DT_REQ;
 	}
 	if (transinfo->period == 0) {
@@ -1674,7 +1674,7 @@
 		*ppr_options = 0;
 		return (NULL);
 	}
-	*period = MAX(*period, transinfo->period);
+	*period = max_t(u_int, *period, transinfo->period);
 	return (ahc_find_syncrate(ahc, period, ppr_options, maxsync));
 }
 
@@ -1799,12 +1799,12 @@
 		else
 			maxoffset = MAX_OFFSET_8BIT;
 	}
-	*offset = MIN(*offset, maxoffset);
+	*offset = min(*offset, maxoffset);
 	if (tinfo != NULL) {
 		if (role == ROLE_TARGET)
-			*offset = MIN(*offset, tinfo->user.offset);
+			*offset = min_t(u_int, *offset, tinfo->user.offset);
 		else
-			*offset = MIN(*offset, tinfo->goal.offset);
+			*offset = min_t(u_int, *offset, tinfo->goal.offset);
 	}
 }
 
@@ -1830,9 +1830,9 @@
 	}
 	if (tinfo != NULL) {
 		if (role == ROLE_TARGET)
-			*bus_width = MIN(tinfo->user.width, *bus_width);
+			*bus_width = min_t(u_int, tinfo->user.width, *bus_width);
 		else
-			*bus_width = MIN(tinfo->goal.width, *bus_width);
+			*bus_width = min_t(u_int, tinfo->goal.width, *bus_width);
 	}
 }
 
@@ -4491,7 +4491,7 @@
 	physaddr = sg_map->sg_physaddr;
 
 	newcount = (PAGE_SIZE / (AHC_NSEG * sizeof(struct ahc_dma_seg)));
-	newcount = MIN(newcount, (AHC_SCB_MAX_ALLOC - scb_data->numscbs));
+	newcount = min(newcount, (AHC_SCB_MAX_ALLOC - scb_data->numscbs));
 	for (i = 0; i < newcount; i++) {
 		struct scb_platform_data *pdata;
 #ifndef __linux__
@@ -6518,7 +6518,7 @@
 			if (skip_addr > i) {
 				int end_addr;
 
-				end_addr = MIN(address, skip_addr);
+				end_addr = min(address, skip_addr);
 				address_offset += end_addr - i;
 				i = skip_addr;
 			} else {
diff -Naur -X /data/temp/dontdiff-osdl linux-2.6.5.org/drivers/scsi/aic7xxx/aic7xxx_osm.c linux-2.6.5.new/drivers/scsi/aic7xxx/aic7xxx_osm.c
--- linux-2.6.5.org/drivers/scsi/aic7xxx/aic7xxx_osm.c	2004-04-04 05:36:17.000000000 +0200
+++ linux-2.6.5.new/drivers/scsi/aic7xxx/aic7xxx_osm.c	2004-04-22 20:11:55.325251688 +0200
@@ -1589,7 +1589,7 @@
 	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;
 		}
@@ -1601,7 +1601,7 @@
 {
 
 	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)
@@ -1614,7 +1614,7 @@
 {
 
 	if ((instance >= 0)
-	 && (instance < NUM_ELEMENTS(aic7xxx_dv_settings))) {
+	 && (instance < ARRAY_SIZE(aic7xxx_dv_settings))) {
 		aic7xxx_dv_settings[instance] = value;
 		if (bootverbose)
 			printf("dv[%d] = %d\n", instance, value);
@@ -1658,7 +1658,7 @@
 	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;
@@ -1666,13 +1666,13 @@
 	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) {
@@ -3250,7 +3250,7 @@
 	if (offset == 0)
 		period = AHC_ASYNC_XFER_PERIOD;
 	if (targ->dv_next_narrow_period == 0)
-		targ->dv_next_narrow_period = MAX(period, AHC_SYNCRATE_ULTRA2);
+		targ->dv_next_narrow_period = max_t(uint8_t, period, AHC_SYNCRATE_ULTRA2);
 	if (targ->dv_next_wide_period == 0)
 		targ->dv_next_wide_period = period;
 	if (targ->dv_max_width == 0)
@@ -3536,7 +3536,7 @@
 
 	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
@@ -3565,7 +3565,7 @@
 	static int warned_user;
 	int dv;
 
-	if (ahc->unit >= NUM_ELEMENTS(aic7xxx_dv_settings)) {
+	if (ahc->unit >= ARRAY_SIZE(aic7xxx_dv_settings)) {
 		if (warned_user == 0) {
 
 			printf(KERN_WARNING
@@ -4278,7 +4278,7 @@
 		if (scb->flags & SCB_SENSE) {
 			u_int sense_size;
 
-			sense_size = MIN(sizeof(struct scsi_sense_data)
+			sense_size = min_t(u_int, sizeof(struct scsi_sense_data)
 				       - ahc_get_sense_residual(scb),
 					 sizeof(cmd->sense_buffer));
 			memcpy(cmd->sense_buffer,
@@ -4558,7 +4558,7 @@
 	offset = user->offset;
 	ppr_options = user->ppr_options;
 	trans_version = user->transport_version;
-	prot_version = MIN(user->protocol_version, SID_ANSI_REV(sid));
+	prot_version = min_t(u_int, user->protocol_version, SID_ANSI_REV(sid));
 
 	/*
 	 * Only attempt SPI3/4 once we've verified that
diff -Naur -X /data/temp/dontdiff-osdl linux-2.6.5.org/drivers/scsi/aic7xxx/aic7xxx_pci.c linux-2.6.5.new/drivers/scsi/aic7xxx/aic7xxx_pci.c
--- linux-2.6.5.org/drivers/scsi/aic7xxx/aic7xxx_pci.c	2004-04-04 05:36:16.000000000 +0200
+++ linux-2.6.5.new/drivers/scsi/aic7xxx/aic7xxx_pci.c	2004-04-22 19:22:40.000000000 +0200
@@ -626,7 +626,7 @@
 	}
 };
 
-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

[-- Attachment #3: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-04-22 22:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-22 22:15 [Kernel-janitors] [PATCH] drivers/scsi/aic7xxx_old MIN/MAX/NUMBER Michael Veeck
2004-04-22 22:16 ` [Kernel-janitors] [PATCH] drivers/scsi/aic7xxxx MIN/MAX/NUM_ELEMENTS Michael Veeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.