]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
usb: common: Use a global definition for 'min3'
authorVivek Gautam <gautam.vivek@samsung.com>
Wed, 24 Apr 2013 02:50:13 +0000 (02:50 +0000)
committerMarek Vasut <marex@denx.de>
Mon, 6 May 2013 00:16:37 +0000 (02:16 +0200)
We can use a common global method for calculating minimum of
3 numbers. Put the same in 'common header' and let 'ehci'
use it.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
Acked-by: Tom Rini <trini@ti.com>
drivers/usb/host/ehci-hcd.c
include/common.h

index 19d43520242bc1df78697ec70d7477dd624d9f6c..e0f3e4b6c788bf3e3d78dcf929c652f5e971845c 100644 (file)
@@ -603,16 +603,6 @@ fail:
        return -1;
 }
 
-static inline int min3(int a, int b, int c)
-{
-
-       if (b < a)
-               a = b;
-       if (c < a)
-               a = c;
-       return a;
-}
-
 int
 ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
                 int length, struct devrequest *req)
index 8a1f3e406d9f529fb04c9c9e50bd58e1f22b9e3e..40e4b077fdf2d1d1d52a45c241366e84675f69ce 100644 (file)
@@ -199,18 +199,35 @@ typedef void (interrupt_handler_t)(void *);
  * General Purpose Utilities
  */
 #define min(X, Y)                              \
-       ({ typeof (X) __x = (X);                \
-               typeof (Y) __y = (Y);           \
+       ({ typeof(X) __x = (X);                 \
+               typeof(Y) __y = (Y);            \
                (__x < __y) ? __x : __y; })
 
 #define max(X, Y)                              \
-       ({ typeof (X) __x = (X);                \
-               typeof (Y) __y = (Y);           \
+       ({ typeof(X) __x = (X);                 \
+               typeof(Y) __y = (Y);            \
                (__x > __y) ? __x : __y; })
 
 #define MIN(x, y)  min(x, y)
 #define MAX(x, y)  max(x, y)
 
+#define min3(X, Y, Z)                          \
+       ({ typeof(X) __x = (X);                 \
+               typeof(Y) __y = (Y);            \
+               typeof(Z) __z = (Z);            \
+               __x < __y ? (__x < __z ? __x : __z) :   \
+               (__y < __z ? __y : __z); })
+
+#define max3(X, Y, Z)                          \
+       ({ typeof(X) __x = (X);                 \
+               typeof(Y) __y = (Y);            \
+               typeof(Z) __z = (Z);            \
+               __x > __y ? (__x > __z ? __x : __z) :   \
+               (__y > __z ? __y : __z); })
+
+#define MIN3(x, y, z)  min3(x, y, z)
+#define MAX3(x, y, z)  max3(x, y, z)
+
 /*
  * Return the absolute value of a number.
  *