public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jules Irenge <jbi.octave@gmail.com>
To: outreachy-kernel@googlegroups.com
Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org, Jules Irenge <jbi.octave@gmail.com>
Subject: [PATCH] staging: rts5208: rewrite macro with GNU extension __auto_type
Date: Mon,  4 Nov 2019 16:44:00 +0000	[thread overview]
Message-ID: <20191104164400.9935-1-jbi.octave@gmail.com> (raw)

Rewrite macro function with GNU extension __auto_type
to remove issue detected by checkpatch tool.
CHECK: MACRO argument reuse - possible side-effects?

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
 drivers/staging/rts5208/rtsx_chip.h | 92 +++++++++++++++++------------
 1 file changed, 55 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_chip.h b/drivers/staging/rts5208/rtsx_chip.h
index bac65784d4a1..4b986d5c68da 100644
--- a/drivers/staging/rts5208/rtsx_chip.h
+++ b/drivers/staging/rts5208/rtsx_chip.h
@@ -386,23 +386,31 @@ struct zone_entry {
 
 /* SD card */
 #define CHK_SD(sd_card)			(((sd_card)->sd_type & 0xFF) == TYPE_SD)
-#define CHK_SD_HS(sd_card)		(CHK_SD(sd_card) && \
-					 ((sd_card)->sd_type & SD_HS))
-#define CHK_SD_SDR50(sd_card)		(CHK_SD(sd_card) && \
-					 ((sd_card)->sd_type & SD_SDR50))
-#define CHK_SD_DDR50(sd_card)		(CHK_SD(sd_card) && \
-					 ((sd_card)->sd_type & SD_DDR50))
-#define CHK_SD_SDR104(sd_card)		(CHK_SD(sd_card) && \
-					 ((sd_card)->sd_type & SD_SDR104))
-#define CHK_SD_HCXC(sd_card)		(CHK_SD(sd_card) && \
-					 ((sd_card)->sd_type & SD_HCXC))
-#define CHK_SD_HC(sd_card)		(CHK_SD_HCXC(sd_card) && \
-					 ((sd_card)->capacity <= 0x4000000))
-#define CHK_SD_XC(sd_card)		(CHK_SD_HCXC(sd_card) && \
-					 ((sd_card)->capacity > 0x4000000))
-#define CHK_SD30_SPEED(sd_card)		(CHK_SD_SDR50(sd_card) || \
-					 CHK_SD_DDR50(sd_card) || \
-					 CHK_SD_SDR104(sd_card))
+#define CHK_SD_HS(sd_card)\
+	({__auto_type _sd = sd_card; CHK_SD(_sd) && \
+					 (_sd->sd_type & SD_HS); })
+#define CHK_SD_SDR50(sd_card)\
+	({__auto_type _sd = sd_card; CHK_SD(_sd) && \
+					 (_sd->sd_type & SD_SDR50); })
+#define CHK_SD_DDR50(sd_card)\
+	({__auto_type _sd = sd_card; CHK_SD(_sd) && \
+					 (_sd->sd_type & SD_DDR50); })
+#define CHK_SD_SDR104(sd_card)\
+	({__auto_type _sd = sd_card; CHK_SD(_sd) && \
+					 (_sd->sd_type & SD_SDR104); })
+#define CHK_SD_HCXC(sd_card)\
+	({__auto_type _sd = sd_card; CHK_SD(_sd) && \
+					 (_sd->sd_type & SD_HCXC); })
+#define CHK_SD_HC(sd_card)\
+	({__auto_type _sd = sd_card; CHK_SD_HCXC(_sd) && \
+					(_sd->capacity <= 0x4000000); })
+#define CHK_SD_XC(sd_card)\
+	({__auto_type _sd = sd_card; CHK_SD_HCXC(_sd) && \
+					 (_sd->capacity > 0x4000000); })
+#define CHK_SD30_SPEED(sd_card)\
+	({__auto_type _sd = sd_card; CHK_SD_SDR50(_sd) || \
+					CHK_SD_DDR50(_sd) || \
+					CHK_SD_SDR104(_sd); })
 
 #define SET_SD(sd_card)			((sd_card)->sd_type = TYPE_SD)
 #define SET_SD_HS(sd_card)		((sd_card)->sd_type |= SD_HS)
@@ -420,18 +428,24 @@ struct zone_entry {
 /* MMC card */
 #define CHK_MMC(sd_card)		(((sd_card)->sd_type & 0xFF) == \
 					 TYPE_MMC)
-#define CHK_MMC_26M(sd_card)		(CHK_MMC(sd_card) && \
-					 ((sd_card)->sd_type & MMC_26M))
-#define CHK_MMC_52M(sd_card)		(CHK_MMC(sd_card) && \
-					 ((sd_card)->sd_type & MMC_52M))
-#define CHK_MMC_4BIT(sd_card)		(CHK_MMC(sd_card) && \
-					 ((sd_card)->sd_type & MMC_4BIT))
-#define CHK_MMC_8BIT(sd_card)		(CHK_MMC(sd_card) && \
-					 ((sd_card)->sd_type & MMC_8BIT))
-#define CHK_MMC_SECTOR_MODE(sd_card)	(CHK_MMC(sd_card) && \
-					 ((sd_card)->sd_type & MMC_SECTOR_MODE))
-#define CHK_MMC_DDR52(sd_card)		(CHK_MMC(sd_card) && \
-					 ((sd_card)->sd_type & MMC_DDR52))
+#define CHK_MMC_26M(sd_card)\
+	({__auto_type _sd = sd_card; CHK_MMC(_sd) && \
+					 (_sd->sd_type & MMC_26M); })
+#define CHK_MMC_52M(sd_card)\
+	({__auto_type _sd = sd_card; CHK_MMC(_sd) && \
+					 (_sd->sd_type & MMC_52M); })
+#define CHK_MMC_4BIT(sd_card)\
+	({__auto_type _sd = sd_card; CHK_MMC(_sd) && \
+					 (_sd->sd_type & MMC_4BIT); })
+#define CHK_MMC_8BIT(sd_card)\
+	({__auto_type _sd = sd_card; CHK_MMC(_sd) && \
+	 (_sd->sd_type & MMC_8BIT); })
+#define CHK_MMC_SECTOR_MODE(sd_card)\
+	({__auto_type _sd = sd_card; CHK_MMC(_sd) && \
+					 (_sd->sd_type & MMC_SECTOR_MODE); })
+#define CHK_MMC_DDR52(sd_card)\
+	({__auto_type _sd = sd_card; CHK_MMC(_sd) && \
+					 (_sd->sd_type & MMC_DDR52); })
 
 #define SET_MMC(sd_card)		((sd_card)->sd_type = TYPE_MMC)
 #define SET_MMC_26M(sd_card)		((sd_card)->sd_type |= MMC_26M)
@@ -448,8 +462,9 @@ struct zone_entry {
 #define CLR_MMC_SECTOR_MODE(sd_card)	((sd_card)->sd_type &= ~MMC_SECTOR_MODE)
 #define CLR_MMC_DDR52(sd_card)		((sd_card)->sd_type &= ~MMC_DDR52)
 
-#define CHK_MMC_HS(sd_card)		(CHK_MMC_52M(sd_card) && \
-					 CHK_MMC_26M(sd_card))
+#define CHK_MMC_HS(sd_card)\
+	({__auto_type _sd = sd_card; CHK_MMC_52M(_sd) && \
+					 CHK_MMC_26M(_sd); })
 #define CLR_MMC_HS(sd_card)			\
 do {						\
 	CLR_MMC_DDR52(sd_card);			\
@@ -560,12 +575,15 @@ struct xd_info {
 #define HG8BIT			(MS_HG | MS_8BIT)
 
 #define CHK_MSPRO(ms_card)	(((ms_card)->ms_type & 0xFF) == TYPE_MSPRO)
-#define CHK_HG8BIT(ms_card)	(CHK_MSPRO(ms_card) && \
-				 (((ms_card)->ms_type & HG8BIT) == HG8BIT))
-#define CHK_MSXC(ms_card)	(CHK_MSPRO(ms_card) && \
-				 ((ms_card)->ms_type & MS_XC))
-#define CHK_MSHG(ms_card)	(CHK_MSPRO(ms_card) && \
-				 ((ms_card)->ms_type & MS_HG))
+#define CHK_HG8BIT(ms_card)\
+	({__auto_type _ms = ms_card; CHK_MSPRO(_ms) && \
+		((_ms->ms_type & HG8BIT) == HG8BIT); })
+#define CHK_MSXC(ms_card)\
+	({__auto_type _ms = ms_card; CHK_MSPRO(_ms) && \
+				 ((_ms)->ms_type & MS_XC); })
+#define CHK_MSHG(ms_card)\
+	({__auto_type _ms = ms_card; CHK_MSPRO(_ms) && \
+				 ((_ms)->ms_type & MS_HG); })
 
 #define CHK_MS8BIT(ms_card)	(((ms_card)->ms_type & MS_8BIT))
 #define CHK_MS4BIT(ms_card)	(((ms_card)->ms_type & MS_4BIT))
-- 
2.17.1


             reply	other threads:[~2019-11-04 16:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04 16:44 Jules Irenge [this message]
2019-11-04 16:51 ` [PATCH] staging: rts5208: rewrite macro with GNU extension __auto_type Greg KH
2019-11-04 17:07   ` Joe Perches
2019-11-05 11:09   ` Jules Irenge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191104164400.9935-1-jbi.octave@gmail.com \
    --to=jbi.octave@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=outreachy-kernel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox