mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: i.MX: Add missing braces
@ 2021-04-13  9:03 Sascha Hauer
  2021-04-13  9:56 ` Ahmad Fatoum
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2021-04-13  9:03 UTC (permalink / raw)
  To: Barebox List

Add braces around the definition of imx1_gpio_val and imx31_gpio_val
to make sure it's evaluated correctly.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/include/mach/imx-gpio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/include/mach/imx-gpio.h b/arch/arm/mach-imx/include/mach/imx-gpio.h
index 0cfd16f4fa..b9a6acc013 100644
--- a/arch/arm/mach-imx/include/mach/imx-gpio.h
+++ b/arch/arm/mach-imx/include/mach/imx-gpio.h
@@ -72,11 +72,11 @@ static inline void imx31_gpio_direction_input(void *base, int gpio)
 #define imx6_gpio_direction_input(base, gpio) imx31_gpio_direction_input(base, gpio)
 #define imx8m_gpio_direction_input(base, gpio) imx31_gpio_direction_input(base, gpio)
 
-#define imx1_gpio_val(base, gpio) readl(base + 0x1c) & (1 << gpio) ? 1 : 0
+#define imx1_gpio_val(base, gpio) (readl(base + 0x1c) & (1 << gpio) ? 1 : 0)
 #define imx21_gpio_val(base, gpio) imx1_gpio_val(base, gpio)
 #define imx27_gpio_val(base, gpio) imx1_gpio_val(base, gpio)
 
-#define imx31_gpio_val(base, gpio) readl(base) & (1 << gpio) ? 1 : 0
+#define imx31_gpio_val(base, gpio) (readl(base) & (1 << gpio) ? 1 : 0)
 #define imx25_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
 #define imx35_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
 #define imx51_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM: i.MX: Add missing braces
  2021-04-13  9:03 [PATCH] ARM: i.MX: Add missing braces Sascha Hauer
@ 2021-04-13  9:56 ` Ahmad Fatoum
  2021-04-13 10:08   ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2021-04-13  9:56 UTC (permalink / raw)
  To: Sascha Hauer, Barebox List

Hi,

On 13.04.21 11:03, Sascha Hauer wrote:
> Add braces around the definition of imx1_gpio_val and imx31_gpio_val
> to make sure it's evaluated correctly.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  arch/arm/mach-imx/include/mach/imx-gpio.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/include/mach/imx-gpio.h b/arch/arm/mach-imx/include/mach/imx-gpio.h
> index 0cfd16f4fa..b9a6acc013 100644
> --- a/arch/arm/mach-imx/include/mach/imx-gpio.h
> +++ b/arch/arm/mach-imx/include/mach/imx-gpio.h
> @@ -72,11 +72,11 @@ static inline void imx31_gpio_direction_input(void *base, int gpio)
>  #define imx6_gpio_direction_input(base, gpio) imx31_gpio_direction_input(base, gpio)
>  #define imx8m_gpio_direction_input(base, gpio) imx31_gpio_direction_input(base, gpio)
>  
> -#define imx1_gpio_val(base, gpio) readl(base + 0x1c) & (1 << gpio) ? 1 : 0
> +#define imx1_gpio_val(base, gpio) (readl(base + 0x1c) & (1 << gpio) ? 1 : 0)

Braces around base and especially gpio might be a good idea as well.
You never know..

>  #define imx21_gpio_val(base, gpio) imx1_gpio_val(base, gpio)
>  #define imx27_gpio_val(base, gpio) imx1_gpio_val(base, gpio)
>  
> -#define imx31_gpio_val(base, gpio) readl(base) & (1 << gpio) ? 1 : 0
> +#define imx31_gpio_val(base, gpio) (readl(base) & (1 << gpio) ? 1 : 0)
>  #define imx25_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
>  #define imx35_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
>  #define imx51_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM: i.MX: Add missing braces
  2021-04-13  9:56 ` Ahmad Fatoum
@ 2021-04-13 10:08   ` Sascha Hauer
  0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2021-04-13 10:08 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Barebox List

On Tue, Apr 13, 2021 at 11:56:10AM +0200, Ahmad Fatoum wrote:
> Hi,
> 
> On 13.04.21 11:03, Sascha Hauer wrote:
> > Add braces around the definition of imx1_gpio_val and imx31_gpio_val
> > to make sure it's evaluated correctly.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  arch/arm/mach-imx/include/mach/imx-gpio.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/mach-imx/include/mach/imx-gpio.h b/arch/arm/mach-imx/include/mach/imx-gpio.h
> > index 0cfd16f4fa..b9a6acc013 100644
> > --- a/arch/arm/mach-imx/include/mach/imx-gpio.h
> > +++ b/arch/arm/mach-imx/include/mach/imx-gpio.h
> > @@ -72,11 +72,11 @@ static inline void imx31_gpio_direction_input(void *base, int gpio)
> >  #define imx6_gpio_direction_input(base, gpio) imx31_gpio_direction_input(base, gpio)
> >  #define imx8m_gpio_direction_input(base, gpio) imx31_gpio_direction_input(base, gpio)
> >  
> > -#define imx1_gpio_val(base, gpio) readl(base + 0x1c) & (1 << gpio) ? 1 : 0
> > +#define imx1_gpio_val(base, gpio) (readl(base + 0x1c) & (1 << gpio) ? 1 : 0)
> 
> Braces around base and especially gpio might be a good idea as well.
> You never know..

Right. I converted the macros to static inline functions instead.

Sascha

> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-13 10:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13  9:03 [PATCH] ARM: i.MX: Add missing braces Sascha Hauer
2021-04-13  9:56 ` Ahmad Fatoum
2021-04-13 10:08   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox