All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Clément Stenac" <zorglub@diwi.org>
To: kernel-janitors@vger.kernel.org
Subject: [KJ] [PATCH] Use standard min/max macros [3/3]
Date: Mon, 31 Jul 2006 22:26:01 +0000	[thread overview]
Message-ID: <20060731222601.GA1663@diwi.org> (raw)
In-Reply-To: <20060731221329.GA31140@diwi.org>

Remove some custom type-unsafe MIN/MAX macros in favor of type-checking
min/max from kernel.h

Signed-off-by: Clément Stenac <zorglub@diwi.org>
---

diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c
index 40f0bee..ea8c8a5 100644
--- a/drivers/acpi/executer/exfldio.c
+++ b/drivers/acpi/executer/exfldio.c
@@ -752,7 +752,7 @@ acpi_ex_extract_from_field(union acpi_op
 		/* Write merged datum to target buffer */
 
 		ACPI_MEMCPY(((char *)buffer) + buffer_offset, &merged_datum,
-			    ACPI_MIN(obj_desc->common_field.access_byte_width,
+			         min(obj_desc->common_field.access_byte_width,
 				     buffer_length - buffer_offset));
 
 		buffer_offset += obj_desc->common_field.access_byte_width;
@@ -771,7 +771,7 @@ acpi_ex_extract_from_field(union acpi_op
 	/* Write the last datum to the buffer */
 
 	ACPI_MEMCPY(((char *)buffer) + buffer_offset, &merged_datum,
-		    ACPI_MIN(obj_desc->common_field.access_byte_width,
+		         min(obj_desc->common_field.access_byte_width,
 			     buffer_length - buffer_offset));
 
 	return_ACPI_STATUS(AE_OK);
@@ -850,7 +850,7 @@ acpi_ex_insert_into_field(union acpi_ope
 	/* Get initial Datum from the input buffer */
 
 	ACPI_MEMCPY(&raw_datum, buffer,
-		    ACPI_MIN(obj_desc->common_field.access_byte_width,
+		         min(obj_desc->common_field.access_byte_width,
 			     buffer_length - buffer_offset));
 
 	merged_datum @@ -903,7 +903,7 @@ acpi_ex_insert_into_field(union acpi_ope
 
 		buffer_offset += obj_desc->common_field.access_byte_width;
 		ACPI_MEMCPY(&raw_datum, ((char *)buffer) + buffer_offset,
-			    ACPI_MIN(obj_desc->common_field.access_byte_width,
+			         min(obj_desc->common_field.access_byte_width,
 				     buffer_length - buffer_offset));
 		merged_datum | 		    raw_datum << obj_desc->common_field.start_field_bit_offset;
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 84dfc42..15cd662 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -627,8 +627,6 @@ static unsigned int	stli_baudrates[] = {
 /*
  *	Define some handy local macros...
  */
-#undef MIN
-#define	MIN(a,b)	(((a) <= (b)) ? (a) : (b))
 
 #undef	TOLOWER
 #define	TOLOWER(x)	((((x) >= 'A') && ((x) <= 'Z')) ? ((x) + 0x20) : (x))
@@ -1455,12 +1453,12 @@ static int stli_write(struct tty_struct 
 		stlen = len;
 	}
 
-	len = MIN(len, count);
+	len = min(len, count);
 	count = 0;
 	shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->txoffset);
 
 	while (len > 0) {
-		stlen = MIN(len, stlen);
+		stlen = min(len, stlen);
 		memcpy_toio(shbuf + head, chbuf, stlen);
 		chbuf += stlen;
 		len -= stlen;
@@ -1574,13 +1572,13 @@ static void stli_flushchars(struct tty_s
 		stlen = len;
 	}
 
-	len = MIN(len, cooksize);
+	len = min(len, cooksize);
 	count = 0;
 	shbuf = (char *) EBRDGETMEMPTR(brdp, portp->txoffset);
 	buf = stli_txcookbuf;
 
 	while (len > 0) {
-		stlen = MIN(len, stlen);
+		stlen = min(len, stlen);
 		memcpy_toio(shbuf + head, buf, stlen);
 		buf += stlen;
 		len -= stlen;
@@ -2416,7 +2414,7 @@ static void stli_read(stlibrd_t *brdp, s
 	while (len > 0) {
 		unsigned char *cptr;
 
-		stlen = MIN(len, stlen);
+		stlen = min(len, stlen);
 		tty_prepare_flip_string(tty, &cptr, stlen);
 		memcpy_fromio(cptr, shbuf + tail, stlen);
 		len -= stlen;
@@ -4219,7 +4217,7 @@ static ssize_t stli_memread(struct file 
 	if (off >= brdp->memsize || off + count < off)
 		return 0;
 
-	size = MIN(count, (brdp->memsize - off));
+	size = min(count, (brdp->memsize - off));
 
 	/*
 	 *	Copy the data a page at a time
@@ -4233,8 +4231,8 @@ static ssize_t stli_memread(struct file 
 		spin_lock_irqsave(&brd_lock, flags);
 		EBRDENABLE(brdp);
 		memptr = (void *) EBRDGETMEMPTR(brdp, off);
-		n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
-		n = MIN(n, PAGE_SIZE);
+		n = min(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
+		n = min(n, PAGE_SIZE);
 		memcpy_fromio(p, memptr, n);
 		EBRDDISABLE(brdp);
 		spin_unlock_irqrestore(&brd_lock, flags);
@@ -4285,7 +4283,7 @@ static ssize_t stli_memwrite(struct file
 		return 0;
 
 	chbuf = (char __user *) buf;
-	size = MIN(count, (brdp->memsize - off));
+	size = min(count, (brdp->memsize - off));
 
 	/*
 	 *	Copy the data a page at a time
@@ -4296,8 +4294,8 @@ static ssize_t stli_memwrite(struct file
 		return -ENOMEM;
 
 	while (size > 0) {
-		n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
-		n = MIN(n, PAGE_SIZE);
+		n = min(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
+		n = min(n, PAGE_SIZE);
 		if (copy_from_user(p, chbuf, n)) {
 			if (count = 0)
 				count = -EFAULT;
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 3beb220..2e3a326 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -445,9 +445,6 @@ static unsigned int	stl_baudrates[] = {
 /*
  *	Define some handy local macros...
  */
-#undef	MIN
-#define	MIN(a,b)	(((a) <= (b)) ? (a) : (b))
-
 #undef	TOLOWER
 #define	TOLOWER(x)	((((x) >= 'A') && ((x) <= 'Z')) ? ((x) + 0x20) : (x))
 
@@ -1201,10 +1198,10 @@ #endif
 		stlen = len;
 	}
 
-	len = MIN(len, count);
+	len = min(len, count);
 	count = 0;
 	while (len > 0) {
-		stlen = MIN(len, stlen);
+		stlen = min(len, stlen);
 		memcpy(head, chbuf, stlen);
 		len -= stlen;
 		chbuf += stlen;
@@ -3936,9 +3933,9 @@ #endif
 		}
 		outb(srer, (ioaddr + EREG_DATA));
 	} else {
-		len = MIN(len, CD1400_TXFIFOSIZE);
+		len = min(len, CD1400_TXFIFOSIZE);
 		portp->stats.txtotal += len;
-		stlen = MIN(len, ((portp->tx.buf + STL_TXBUFSIZE) - tail));
+		stlen = min(len, ((portp->tx.buf + STL_TXBUFSIZE) - tail));
 		outb((TDR + portp->uartaddr), ioaddr);
 		outsb((ioaddr + EREG_DATA), tail, stlen);
 		len -= stlen;
@@ -3993,13 +3990,13 @@ #endif
 		outb((RDCR + portp->uartaddr), ioaddr);
 		len = inb(ioaddr + EREG_DATA);
 		if (tty = NULL || (buflen = tty_buffer_request_room(tty, len)) = 0) {
-			len = MIN(len, sizeof(stl_unwanted));
+			len = min(len, sizeof(stl_unwanted));
 			outb((RDSR + portp->uartaddr), ioaddr);
 			insb((ioaddr + EREG_DATA), &stl_unwanted[0], len);
 			portp->stats.rxlost += len;
 			portp->stats.rxtotal += len;
 		} else {
-			len = MIN(len, buflen);
+			len = min(len, buflen);
 			if (len > 0) {
 				unsigned char *ptr;
 				outb((RDSR + portp->uartaddr), ioaddr);
@@ -4897,9 +4894,9 @@ #endif
 			outb(mr0, (ioaddr + XP_DATA));
 		}
 	} else {
-		len = MIN(len, SC26198_TXFIFOSIZE);
+		len = min(len, SC26198_TXFIFOSIZE);
 		portp->stats.txtotal += len;
-		stlen = MIN(len, ((portp->tx.buf + STL_TXBUFSIZE) - tail));
+		stlen = min(len, ((portp->tx.buf + STL_TXBUFSIZE) - tail));
 		outb(GTXFIFO, (ioaddr + XP_ADDR));
 		outsb((ioaddr + XP_DATA), tail, stlen);
 		len -= stlen;
@@ -4942,13 +4939,13 @@ #endif
 
 	if ((iack & IVR_TYPEMASK) = IVR_RXDATA) {
 		if (tty = NULL || (buflen = tty_buffer_request_room(tty, len)) = 0) {
-			len = MIN(len, sizeof(stl_unwanted));
+			len = min(len, sizeof(stl_unwanted));
 			outb(GRXFIFO, (ioaddr + XP_ADDR));
 			insb((ioaddr + XP_DATA), &stl_unwanted[0], len);
 			portp->stats.rxlost += len;
 			portp->stats.rxtotal += len;
 		} else {
-			len = MIN(len, buflen);
+			len = min(len, buflen);
 			if (len > 0) {
 				unsigned char *ptr;
 				outb(GRXFIFO, (ioaddr + XP_ADDR));
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 912c03e..c585c6f 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -590,8 +590,6 @@ EXPORT_SYMBOL(pccard_get_next_tuple);
 
 /*==================================*/
 
-#define _MIN(a, b)		(((a) < (b)) ? (a) : (b))
-
 int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple)
 {
     u_int len;
@@ -607,7 +605,7 @@ int pccard_get_tuple_data(struct pcmcia_
 	return CS_SUCCESS;
     read_cis_cache(s, SPACE(tuple->Flags),
 		   tuple->CISOffset + tuple->TupleOffset,
-		   _MIN(len, tuple->TupleDataMax), tuple->TupleData);
+		   min(len, tuple->TupleDataMax), tuple->TupleData);
     return CS_SUCCESS;
 }
 EXPORT_SYMBOL(pccard_get_tuple_data);
diff --git a/drivers/s390/crypto/z90common.h b/drivers/s390/crypto/z90common.h
index dbbcda3..569120e 100644
--- a/drivers/s390/crypto/z90common.h
+++ b/drivers/s390/crypto/z90common.h
@@ -160,7 +160,6 @@ #else
 #define PDEBUG(fmt, args...) do {} while (0)
 #endif
 
-#define UMIN(a,b) ((a) < (b) ? (a) : (b))
 #define IS_EVEN(x) ((x) = (2 * ((x) / 2)))
 
 #endif
diff --git a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c
index b2f20ab..c347995 100644
--- a/drivers/s390/crypto/z90main.c
+++ b/drivers/s390/crypto/z90main.c
@@ -2119,7 +2119,7 @@ #define LBUFSIZE 1200
 	if (count <= 0)
 		return 0;
 
-	local_count = UMIN((unsigned int)count, LBUFSIZE-1);
+	local_count = min((unsigned int)count, LBUFSIZE-1);
 
 	if (copy_from_user(lbuf, buffer, local_count) != 0) {
 		kfree(lbuf);
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h
index 192fa09..3caf144 100644
--- a/include/acpi/acmacros.h
+++ b/include/acpi/acmacros.h
@@ -54,7 +54,6 @@ #define ACPI_HIBYTE(l)                  
 
 #define ACPI_SET_BIT(target,bit)        ((target) |= (bit))
 #define ACPI_CLEAR_BIT(target,bit)      ((target) &= ~(bit))
-#define ACPI_MIN(a,b)                   (((a)<(b))?(a):(b))
 
 /* Size calculation */
 

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

  parent reply	other threads:[~2006-07-31 22:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-31 22:13 [KJ] [PATCH] Use standard min/max macros [1/3] Clément Stenac
2006-07-31 22:25 ` [KJ] [PATCH] Use standard min/max macros [2/3] Clément Stenac
2006-07-31 22:26 ` Clément Stenac [this message]
2006-08-01  1:55 ` [KJ] [PATCH] Use standard min/max macros [3/3] Alexey Dobriyan
2006-08-02 19:57 ` Clément Stenac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060731222601.GA1663@diwi.org \
    --to=zorglub@diwi.org \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.