]> git.neil.brown.name Git - history.git/commitdiff
TTY: replace MIN and MAX macro usages with min() and max()
authorGreg Kroah-Hartman <greg@kroah.com>
Sun, 29 Dec 2002 15:59:37 +0000 (07:59 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Sun, 29 Dec 2002 15:59:37 +0000 (07:59 -0800)
drivers/char/n_tty.c
drivers/char/pty.c
drivers/char/tty_io.c

index dc050fbf9bafdbbaf5e32912678213a4f561d5d6..34304a4dcb7f2ed783963ade0d89b5ab3f1310a2 100644 (file)
 #define IS_CONSOLE_DEV(dev)    (kdev_val(dev) == __mkdev(TTY_MAJOR,0))
 #define IS_SYSCONS_DEV(dev)    (kdev_val(dev) == __mkdev(TTYAUX_MAJOR,1))
 
-#ifndef MIN
-#define MIN(a,b)       ((a) < (b) ? (a) : (b))
-#endif
-
 /* number of characters left in xmit buffer before select has we have room */
 #define WAKEUP_CHARS 256
 
@@ -725,16 +721,18 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 
        if (tty->real_raw) {
                spin_lock_irqsave(&tty->read_lock, cpuflags);
-               i = MIN(count, MIN(N_TTY_BUF_SIZE - tty->read_cnt,
-                                  N_TTY_BUF_SIZE - tty->read_head));
+               i = min(N_TTY_BUF_SIZE - tty->read_cnt,
+                       N_TTY_BUF_SIZE - tty->read_head);
+               i = min(count, i);
                memcpy(tty->read_buf + tty->read_head, cp, i);
                tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1);
                tty->read_cnt += i;
                cp += i;
                count -= i;
 
-               i = MIN(count, MIN(N_TTY_BUF_SIZE - tty->read_cnt,
-                              N_TTY_BUF_SIZE - tty->read_head));
+               i = min(N_TTY_BUF_SIZE - tty->read_cnt,
+                       N_TTY_BUF_SIZE - tty->read_head);
+               i = min(count, i);
                memcpy(tty->read_buf + tty->read_head, cp, i);
                tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1);
                tty->read_cnt += i;
@@ -915,7 +913,8 @@ static inline int copy_from_read_buf(struct tty_struct *tty,
 
        retval = 0;
        spin_lock_irqsave(&tty->read_lock, flags);
-       n = MIN(*nr, MIN(tty->read_cnt, N_TTY_BUF_SIZE - tty->read_tail));
+       n = min(tty->read_cnt, N_TTY_BUF_SIZE - tty->read_tail);
+       n = min((ssize_t)*nr, n);
        spin_unlock_irqrestore(&tty->read_lock, flags);
        if (n) {
                mb();
index b2bf8a1338bd1f36eeea7fda28711a4f1e360a91..5c23c6b2ec63c084562c2e8142b1a9e7721f8ec3 100644 (file)
@@ -64,8 +64,6 @@ static struct termios *pts_termios_locked[UNIX98_NR_MAJORS][NR_PTYS];
 static struct pty_struct ptm_state[UNIX98_NR_MAJORS][NR_PTYS];
 #endif
 
-#define MIN(a,b)       ((a) < (b) ? (a) : (b))
-
 static void pty_close(struct tty_struct * tty, struct file * filp)
 {
        if (!tty)
@@ -156,7 +154,7 @@ static int pty_write(struct tty_struct * tty, int from_user,
                                n = count;
                        if (!n) break;
 
-                       n  = MIN(n, PTY_BUF_SIZE);
+                       n  = min(n, PTY_BUF_SIZE);
                        n -= copy_from_user(temp_buffer, buf, n);
                        if (!n) {
                                if (!c)
index 240c470a4c24d15c2da537dfcc9bd6b74d8e3f06..d39c31afe0e417d18c5a70a56c18f6db309efc9e 100644 (file)
@@ -159,13 +159,6 @@ extern void tx3912_console_init(void);
 extern void tx3912_rs_init(void);
 extern void hvc_console_init(void);
 
-#ifndef MIN
-#define MIN(a,b)       ((a) < (b) ? (a) : (b))
-#endif
-#ifndef MAX
-#define MAX(a,b)       ((a) < (b) ? (b) : (a))
-#endif
-
 static struct tty_struct *alloc_tty_struct(void)
 {
        struct tty_struct *tty;
@@ -714,7 +707,7 @@ static inline ssize_t do_tty_write(
                unlock_kernel();
        } else {
                for (;;) {
-                       unsigned long size = MAX(PAGE_SIZE*2,16384);
+                       unsigned long size = max((unsigned long)PAGE_SIZE*2, 16384UL);
                        if (size > count)
                                size = count;
                        lock_kernel();