Patchwork [U-Boot,v3,8/8] usb: common: Use a global macro for 'min3'

login
register
mail settings
Submitter Vivek Gautam
Date April 12, 2013, 11:04 a.m.
Message ID <1365764680-10917-9-git-send-email-gautam.vivek@samsung.com>
Download mbox | patch
Permalink /patch/236039/
State Superseded
Delegated to: Marek Vasut
Headers show

Comments

Vivek Gautam - April 12, 2013, 11:04 a.m.
We can use a common global macro 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>
---

This patch added in V3(current-version) of this patch-series.

 drivers/usb/host/ehci-hcd.c |   10 ----------
 include/common.h            |    2 ++
 2 files changed, 2 insertions(+), 10 deletions(-)
Marek Vasut - April 14, 2013, 5:11 p.m.
Dear Vivek Gautam,

> We can use a common global macro 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>
> ---
> 
> This patch added in V3(current-version) of this patch-series.
> 
>  drivers/usb/host/ehci-hcd.c |   10 ----------
>  include/common.h            |    2 ++
>  2 files changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index c816878..bcecae3 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -587,16 +587,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)
> diff --git a/include/common.h b/include/common.h
> index d41aeb4..37269c7 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -211,6 +211,8 @@ typedef void (interrupt_handler_t)(void *);
>  #define MIN(x, y)  min(x, y)
>  #define MAX(x, y)  max(x, y)
> 
> +#define min3(a, b, c)	min(min(a, b), c)
> +

You might want to keep it as an inline-function to allow GCC do the type-
checking?

>  /*
>   * Return the absolute value of a number.
>   *

Best regards,
Marek Vasut

Patch

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c816878..bcecae3 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -587,16 +587,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)
diff --git a/include/common.h b/include/common.h
index d41aeb4..37269c7 100644
--- a/include/common.h
+++ b/include/common.h
@@ -211,6 +211,8 @@  typedef void (interrupt_handler_t)(void *);
 #define MIN(x, y)  min(x, y)
 #define MAX(x, y)  max(x, y)
 
+#define min3(a, b, c)	min(min(a, b), c)
+
 /*
  * Return the absolute value of a number.
  *