Skip to contentSkip to conversation

staging: rts5208: Replace bit shifting with BIT macro

PATCH In review Payal Kshirsagar 3 participants 4 messages Mar 8, 2020 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rts5208: Replace bit shifting with BIT macro

Prefer using BIT macro and replace bit shifting with the BIT(x) macro.

---
 drivers/staging/rts5208/rtsx_card.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rts5208/rtsx_card.h +2 -2
index 39727371cd7a..9d2504fddb13 100644
@@ -338,7 +338,7 @@
 #define DMA_DIR_FROM_CARD		0x02
 #define DMA_EN				0x01
 #define DMA_128				(0 << 4)
-#define DMA_256				(1 << 4)
+#define DMA_256				BIT(4)
 #define DMA_512				(2 << 4)
 #define DMA_1024			(3 << 4)
 #define DMA_PACK_SIZE_MASK		0x30
@@ -542,7 +542,7 @@
 
 #define BLINK_EN			0x08
 #define LED_GPIO0			(0 << 4)
-#define LED_GPIO1			(1 << 4)
+#define LED_GPIO1			BIT(4)
 #define LED_GPIO2			(2 << 4)
 
 #define SDIO_BUS_CTRL		0x01
Signature · 1 line
2.17.1
#1 lore raw
Quoted 12 lines · On Sun, 8 Mar 2020 19:40:57 +0530 Payal Kshirsagar…

Prefer using BIT macro and replace bit shifting with the BIT(x) macro.

---
 drivers/staging/rts5208/rtsx_card.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rts5208/rtsx_card.h +0 -0
index 39727371cd7a..9d2504fddb13 100644

drivers/staging/rts5208/rtsx_card.h line 343

Quoted 7 lines
drivers/staging/rts5208/rtsx_card.h +1 -1
@@ -338,7 +338,7 @@
 #define DMA_DIR_FROM_CARD		0x02
 #define DMA_EN				0x01
 #define DMA_128				(0 << 4)
-#define DMA_256				(1 << 4)
+#define DMA_256				BIT(4)
 #define DMA_512				(2 << 4)
 #define DMA_1024			(3 << 4)

I'm not sure this is a good idea. I understand checkpatch might report this, but please have a look around this line:

#define DMA_128 (0 << 4)
#define DMA_256 (1 << 4)
#define DMA_512 (2 << 4)
#define DMA_1024 (3 << 4)

this tells me that for each of these DMA modes
(https://en.wikipedia.org/wiki/Direct_memory_access -- no need to dig into that, just for context), '0', '1', '2' or '3' need to be set somewhere. Before this value can be written, it needs to be shifted left
(https://en.wikipedia.org/wiki/Logical_shift) by 4 bits.

Now, your version:

#define DMA_128 (0 << 4)
#define DMA_256 BIT(4)
#define DMA_512 (2 << 4)
#define DMA_1024 (3 << 4)

"If it's 128, 512 or 1024, write 0, 2 or 3, then shift left by 4. If it's 256, instead, set bit 4." This is actually confusing.

Maybe try to put changes into the context a bit -- don't rush, take your time to read the effect of the changes you're proposing :) Thanks.

Signature · 1 line
Stefano
#2 lore raw
In reply to Payal Kshirsagar
Quoted 12 lines · Payal Kshirsagar

Prefer using BIT macro and replace bit shifting with the BIT(x) macro.

---
 drivers/staging/rts5208/rtsx_card.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rts5208/rtsx_card.h +0 -0
index 39727371cd7a..9d2504fddb13 100644

drivers/staging/rts5208/rtsx_card.h line 343

Quoted 7 lines
drivers/staging/rts5208/rtsx_card.h +1 -1
@@ -338,7 +338,7 @@
 #define DMA_DIR_FROM_CARD		0x02
 #define DMA_EN				0x01
 #define DMA_128				(0 << 4)
-#define DMA_256				(1 << 4)
+#define DMA_256				BIT(4)
 #define DMA_512				(2 << 4)
 #define DMA_1024			(3 << 4)

It would be better to keep them all being expressed in the same way, in this case and the next one.

julia

Quoted 18 lines
drivers/staging/rts5208/rtsx_card.h +1 -2
 #define DMA_PACK_SIZE_MASK		0x30
@@ -542,7 +542,7 @@
 
 #define BLINK_EN			0x08
 #define LED_GPIO0			(0 << 4)
-#define LED_GPIO1			(1 << 4)
+#define LED_GPIO1			BIT(4)
 #define LED_GPIO2			(2 << 4)
 
 #define SDIO_BUS_CTRL		0x01
--

2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20200308141057.5857-1-payalskshirsagar1234%40gmail.com.

#3 lore raw
Quoted 11 lines · Julia Lawall

Review

Quoted 8 lines · Payal Kshirsagar

Prefer using BIT macro and replace bit shifting with the BIT(x) macro.

---
 drivers/staging/rts5208/rtsx_card.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/rts5208/rtsx_card.h

Quoted 14 lines

drivers/staging/rts5208/rtsx_card.h line 343

Quoted 11 lines

index 39727371cd7a..9d2504fddb13 100644

drivers/staging/rts5208/rtsx_card.h +1 -1
@@ -338,7 +338,7 @@
 #define DMA_DIR_FROM_CARD            0x02
 #define DMA_EN                               0x01
 #define DMA_128                              (0 << 4)
-#define DMA_256                              (1 << 4)
+#define DMA_256                              BIT(4)
 #define DMA_512                              (2 << 4)
 #define DMA_1024                     (3 << 4)

It would be better to keep them all being expressed in the same way, in this case and the next one.

Yes, I agree.

julia

Quoted 24 lines
Quoted 14 lines
drivers/staging/rts5208/rtsx_card.h +1 -2
 #define DMA_PACK_SIZE_MASK           0x30
@@ -542,7 +542,7 @@
 
 #define BLINK_EN                     0x08
 #define LED_GPIO0                    (0 << 4)
-#define LED_GPIO1                    (1 << 4)
+#define LED_GPIO1                    BIT(4)
 #define LED_GPIO2                    (2 << 4)
 
 #define SDIO_BUS_CTRL                0x01
--

2.17.1

Quoted 2 lines

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 1 line

To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/20200308141057.5857-1-payalskshirsagar1234%40gmail.com
.

Quoted 1 line