linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: mt7621-mmc: Remove do {} while (0) loop for single statement macro
@ 2018-09-15 13:17 Nishad Kamdar
  2018-09-17 16:20 ` Joe Perches
  2018-09-18 11:27 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 4+ messages in thread
From: Nishad Kamdar @ 2018-09-15 13:17 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Joe Perches, NeilBrown, devel, Christian Lütke-Stetzkamp,
	linux-kernel, John Crispin, Dan Carpenter

This patch removes do {} while (0) loop for single statement macros.
Issue found by checkpatch.

Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
---
 drivers/staging/mt7621-mmc/sd.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 7474f9ed7b5b..ec12a3a5a926 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -104,14 +104,10 @@ static int cd_active_low = 1;
 /* gate means clock power down */
 static int g_clk_gate = 0;
 #define msdc_gate_clock(id) \
-	do {					       \
-		g_clk_gate &= ~(1 << ((id) + PERI_MSDC0_PDN));	\
-	} while (0)
+	(g_clk_gate &= ~(1 << ((id) + PERI_MSDC0_PDN)))
 /* not like power down register. 1 means clock on. */
 #define msdc_ungate_clock(id) \
-	do {					    \
-		g_clk_gate |= 1 << ((id) + PERI_MSDC0_PDN);	\
-	} while (0)
+	(g_clk_gate |= 1 << ((id) + PERI_MSDC0_PDN))
 
 // do we need sync object or not
 void msdc_clk_status(int *status)
@@ -170,9 +166,7 @@ static void msdc_clr_fifo(struct msdc_host *host)
 	} while (0)
 
 #define msdc_irq_restore(val) \
-	do {					\
-		sdr_set_bits(host->base + MSDC_INTEN, val);	\
-	} while (0)
+	(sdr_set_bits(host->base + MSDC_INTEN, val))
 
 /* clock source for host: global */
 #if defined(CONFIG_SOC_MT7620)
@@ -186,26 +180,18 @@ static u32 hclks[] = {50000000}; /* +/- by chhung */
 //    always keep the VMC on.
 //============================================
 #define msdc_vcore_on(host) \
-	do {								\
-		(void)hwPowerOn(MT65XX_POWER_LDO_VMC, VOL_3300, "SD");	\
-	} while (0)
+	((void)hwPowerOn(MT65XX_POWER_LDO_VMC, VOL_3300, "SD"))
 #define msdc_vcore_off(host) \
-	do {								\
-		(void)hwPowerDown(MT65XX_POWER_LDO_VMC, "SD");		\
-	} while (0)
+	((void)hwPowerDown(MT65XX_POWER_LDO_VMC, "SD"))
 
 //====================================
 // the vdd output for card: global
 //   always keep the VMCH on.
 //====================================
 #define msdc_vdd_on(host) \
-	do {								\
-		(void)hwPowerOn(MT65XX_POWER_LDO_VMCH, VOL_3300, "SD"); \
-	} while (0)
+	((void)hwPowerOn(MT65XX_POWER_LDO_VMCH, VOL_3300, "SD"))
 #define msdc_vdd_off(host) \
-	do {							\
-		(void)hwPowerDown(MT65XX_POWER_LDO_VMCH, "SD"); \
-	} while (0)
+	((void)hwPowerDown(MT65XX_POWER_LDO_VMCH, "SD"))
 
 #define sdc_is_busy()          (readl(host->base + SDC_STS) & SDC_STS_SDCBUSY)
 #define sdc_is_cmd_busy()      (readl(host->base + SDC_STS) & SDC_STS_CMDBUSY)
-- 
2.17.1


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

* Re: [PATCH] staging: mt7621-mmc: Remove do {} while (0) loop for single statement macro
  2018-09-15 13:17 [PATCH] staging: mt7621-mmc: Remove do {} while (0) loop for single statement macro Nishad Kamdar
@ 2018-09-17 16:20 ` Joe Perches
  2018-09-18 11:27 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 4+ messages in thread
From: Joe Perches @ 2018-09-17 16:20 UTC (permalink / raw)
  To: Nishad Kamdar, Greg Kroah-Hartman
  Cc: NeilBrown, devel, Christian Lütke-Stetzkamp, linux-kernel,
	John Crispin, Dan Carpenter

On Sat, 2018-09-15 at 18:47 +0530, Nishad Kamdar wrote:
> This patch removes do {} while (0) loop for single statement macros.
> Issue found by checkpatch.

Some or all of this code is not used and should be deleted instead.

> Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
> ---
>  drivers/staging/mt7621-mmc/sd.c | 28 +++++++---------------------
>  1 file changed, 7 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
> index 7474f9ed7b5b..ec12a3a5a926 100644
> --- a/drivers/staging/mt7621-mmc/sd.c
> +++ b/drivers/staging/mt7621-mmc/sd.c
> @@ -104,14 +104,10 @@ static int cd_active_low = 1;
>  /* gate means clock power down */
>  static int g_clk_gate = 0;
>  #define msdc_gate_clock(id) \
> -	do {					       \
> -		g_clk_gate &= ~(1 << ((id) + PERI_MSDC0_PDN));	\
> -	} while (0)
> +	(g_clk_gate &= ~(1 << ((id) + PERI_MSDC0_PDN)))
>  /* not like power down register. 1 means clock on. */
>  #define msdc_ungate_clock(id) \
> -	do {					    \
> -		g_clk_gate |= 1 << ((id) + PERI_MSDC0_PDN);	\
> -	} while (0)
> +	(g_clk_gate |= 1 << ((id) + PERI_MSDC0_PDN))
>  
>  // do we need sync object or not
>  void msdc_clk_status(int *status)
> @@ -170,9 +166,7 @@ static void msdc_clr_fifo(struct msdc_host *host)
>  	} while (0)
>  
>  #define msdc_irq_restore(val) \
> -	do {					\
> -		sdr_set_bits(host->base + MSDC_INTEN, val);	\
> -	} while (0)
> +	(sdr_set_bits(host->base + MSDC_INTEN, val))
>  
>  /* clock source for host: global */
>  #if defined(CONFIG_SOC_MT7620)
> @@ -186,26 +180,18 @@ static u32 hclks[] = {50000000}; /* +/- by chhung */
>  //    always keep the VMC on.
>  //============================================
>  #define msdc_vcore_on(host) \
> -	do {								\
> -		(void)hwPowerOn(MT65XX_POWER_LDO_VMC, VOL_3300, "SD");	\
> -	} while (0)
> +	((void)hwPowerOn(MT65XX_POWER_LDO_VMC, VOL_3300, "SD"))
>  #define msdc_vcore_off(host) \
> -	do {								\
> -		(void)hwPowerDown(MT65XX_POWER_LDO_VMC, "SD");		\
> -	} while (0)
> +	((void)hwPowerDown(MT65XX_POWER_LDO_VMC, "SD"))
>  
>  //====================================
>  // the vdd output for card: global
>  //   always keep the VMCH on.
>  //====================================
>  #define msdc_vdd_on(host) \
> -	do {								\
> -		(void)hwPowerOn(MT65XX_POWER_LDO_VMCH, VOL_3300, "SD"); \
> -	} while (0)
> +	((void)hwPowerOn(MT65XX_POWER_LDO_VMCH, VOL_3300, "SD"))
>  #define msdc_vdd_off(host) \
> -	do {							\
> -		(void)hwPowerDown(MT65XX_POWER_LDO_VMCH, "SD"); \
> -	} while (0)
> +	((void)hwPowerDown(MT65XX_POWER_LDO_VMCH, "SD"))
>  
>  #define sdc_is_busy()          (readl(host->base + SDC_STS) & SDC_STS_SDCBUSY)
>  #define sdc_is_cmd_busy()      (readl(host->base + SDC_STS) & SDC_STS_CMDBUSY)

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

* Re: [PATCH] staging: mt7621-mmc: Remove do {} while (0) loop for single statement macro
  2018-09-15 13:17 [PATCH] staging: mt7621-mmc: Remove do {} while (0) loop for single statement macro Nishad Kamdar
  2018-09-17 16:20 ` Joe Perches
@ 2018-09-18 11:27 ` Greg Kroah-Hartman
  2018-09-23  9:34   ` Nishad Kamdar
  1 sibling, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2018-09-18 11:27 UTC (permalink / raw)
  To: Nishad Kamdar
  Cc: devel, linux-kernel, NeilBrown, Joe Perches,
	Christian Lütke-Stetzkamp, Dan Carpenter, John Crispin

On Sat, Sep 15, 2018 at 06:47:51PM +0530, Nishad Kamdar wrote:
> This patch removes do {} while (0) loop for single statement macros.
> Issue found by checkpatch.
> 
> Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
> ---
>  drivers/staging/mt7621-mmc/sd.c | 28 +++++++---------------------
>  1 file changed, 7 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
> index 7474f9ed7b5b..ec12a3a5a926 100644
> --- a/drivers/staging/mt7621-mmc/sd.c
> +++ b/drivers/staging/mt7621-mmc/sd.c
> @@ -104,14 +104,10 @@ static int cd_active_low = 1;
>  /* gate means clock power down */
>  static int g_clk_gate = 0;
>  #define msdc_gate_clock(id) \
> -	do {					       \
> -		g_clk_gate &= ~(1 << ((id) + PERI_MSDC0_PDN));	\
> -	} while (0)
> +	(g_clk_gate &= ~(1 << ((id) + PERI_MSDC0_PDN)))

This should become an inline function, right?


>  /* not like power down register. 1 means clock on. */
>  #define msdc_ungate_clock(id) \
> -	do {					    \
> -		g_clk_gate |= 1 << ((id) + PERI_MSDC0_PDN);	\
> -	} while (0)
> +	(g_clk_gate |= 1 << ((id) + PERI_MSDC0_PDN))

Same here.

>  
>  // do we need sync object or not
>  void msdc_clk_status(int *status)
> @@ -170,9 +166,7 @@ static void msdc_clr_fifo(struct msdc_host *host)
>  	} while (0)
>  
>  #define msdc_irq_restore(val) \
> -	do {					\
> -		sdr_set_bits(host->base + MSDC_INTEN, val);	\
> -	} while (0)
> +	(sdr_set_bits(host->base + MSDC_INTEN, val))

Just call the one function where this is used and delete this #define.

Same type of changes for the rest of these as well.

thanks,

greg k-h

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

* Re: [PATCH] staging: mt7621-mmc: Remove do {} while (0) loop for single statement macro
  2018-09-18 11:27 ` Greg Kroah-Hartman
@ 2018-09-23  9:34   ` Nishad Kamdar
  0 siblings, 0 replies; 4+ messages in thread
From: Nishad Kamdar @ 2018-09-23  9:34 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Joe Perches, NeilBrown, devel, Christian Lütke-Stetzkamp,
	linux-kernel, John Crispin, Dan Carpenter

On Tue, Sep 18, 2018 at 01:27:11PM +0200, Greg Kroah-Hartman wrote:
> On Sat, Sep 15, 2018 at 06:47:51PM +0530, Nishad Kamdar wrote:
> > This patch removes do {} while (0) loop for single statement macros.
> > Issue found by checkpatch.
> > 
> > Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
> > ---
> >  drivers/staging/mt7621-mmc/sd.c | 28 +++++++---------------------
> >  1 file changed, 7 insertions(+), 21 deletions(-)
> > 
> > diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
> > index 7474f9ed7b5b..ec12a3a5a926 100644
> > --- a/drivers/staging/mt7621-mmc/sd.c
> > +++ b/drivers/staging/mt7621-mmc/sd.c
> > @@ -104,14 +104,10 @@ static int cd_active_low = 1;
> >  /* gate means clock power down */
> >  static int g_clk_gate = 0;
> >  #define msdc_gate_clock(id) \
> > -	do {					       \
> > -		g_clk_gate &= ~(1 << ((id) + PERI_MSDC0_PDN));	\
> > -	} while (0)
> > +	(g_clk_gate &= ~(1 << ((id) + PERI_MSDC0_PDN)))
> 
> This should become an inline function, right?
> 
> 
> >  /* not like power down register. 1 means clock on. */
> >  #define msdc_ungate_clock(id) \
> > -	do {					    \
> > -		g_clk_gate |= 1 << ((id) + PERI_MSDC0_PDN);	\
> > -	} while (0)
> > +	(g_clk_gate |= 1 << ((id) + PERI_MSDC0_PDN))
> 
> Same here.
> 
> >  
> >  // do we need sync object or not
> >  void msdc_clk_status(int *status)
> > @@ -170,9 +166,7 @@ static void msdc_clr_fifo(struct msdc_host *host)
> >  	} while (0)
> >  
> >  #define msdc_irq_restore(val) \
> > -	do {					\
> > -		sdr_set_bits(host->base + MSDC_INTEN, val);	\
> > -	} while (0)
> > +	(sdr_set_bits(host->base + MSDC_INTEN, val))
> 
> Just call the one function where this is used and delete this #define.
> 
> Same type of changes for the rest of these as well.
> 
> thanks,
> 
> greg k-h

Ok. I'll do that.

Thanks for the review.

regards,
nishad

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

end of thread, other threads:[~2018-09-23  9:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-15 13:17 [PATCH] staging: mt7621-mmc: Remove do {} while (0) loop for single statement macro Nishad Kamdar
2018-09-17 16:20 ` Joe Perches
2018-09-18 11:27 ` Greg Kroah-Hartman
2018-09-23  9:34   ` Nishad Kamdar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).