diff options
| author | Vivek Gautam <gautam.vivek@samsung.com> | 2013-04-24 02:50:13 +0000 | 
|---|---|---|
| committer | Marek Vasut <marex@denx.de> | 2013-05-06 02:16:37 +0200 | 
| commit | 4f4eab4d14b181c3a9447c75fd2b41b9d0d761e4 (patch) | |
| tree | 9d909117695b3a2084674c72285a04e8382c3579 /include/common.h | |
| parent | 55f4b57542de9f4bee8dc0b7ca70686bd20e2aa4 (diff) | |
| download | olio-uboot-2014.01-4f4eab4d14b181c3a9447c75fd2b41b9d0d761e4.tar.xz olio-uboot-2014.01-4f4eab4d14b181c3a9447c75fd2b41b9d0d761e4.zip | |
usb: common: Use a global definition for 'min3'
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>
Diffstat (limited to 'include/common.h')
| -rw-r--r-- | include/common.h | 25 | 
1 files changed, 21 insertions, 4 deletions
| diff --git a/include/common.h b/include/common.h index 8a1f3e406..40e4b077f 100644 --- a/include/common.h +++ b/include/common.h @@ -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.   * |