Skip to contentSkip to conversation

staging: sm750fb: ddk750_chip.c: Prefer using the BIT macro

PATCH Superseded Sanjana Sanikommu 2 participants 3 messages Mar 25, 2019

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: sm750fb: ddk750_chip.c: Prefer using the BIT macro

Challenge suggested by coccinelle.

Replace bit shifting on 1 with the BIT(x) macro.
Coccinelle script:

@@
constant c;
@@

-1 << c
+BIT(c)

---
 drivers/staging/sm750fb/ddk750_chip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/sm750fb/ddk750_chip.c +1 -1
index 4c1f00f551da..5690fb46e095 100644
@@ -45,7 +45,7 @@ static unsigned int get_mxclk_freq(void)
 	OD = (pll_reg & PLL_CTRL_OD_MASK) >> PLL_CTRL_OD_SHIFT;
 	POD = (pll_reg & PLL_CTRL_POD_MASK) >> PLL_CTRL_POD_SHIFT;
 
-	return DEFAULT_INPUT_CLOCK * M / N / (1 << OD) / (1 << POD);
+	return DEFAULT_INPUT_CLOCK * M / N / (BIT(OD)) / (BIT(POD));
 }
 
 /*
Signature · 1 line
2.17.1
#1 lore raw
Quoted 22 lines · Sanjana Sanikommu

Challenge suggested by coccinelle.

Replace bit shifting on 1 with the BIT(x) macro.
Coccinelle script:

@@
constant c;
@@

-1 << c
+BIT(c)

---
 drivers/staging/sm750fb/ddk750_chip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/sm750fb/ddk750_chip.c +0 -0
index 4c1f00f551da..5690fb46e095 100644

drivers/staging/sm750fb/ddk750_chip.c static unsigned int get_mxclk_freq(void) · line 48

Quoted 5 lines
drivers/staging/sm750fb/ddk750_chip.c +1 -1
@@ -45,7 +45,7 @@ static unsigned int get_mxclk_freq(void)
 	OD = (pll_reg & PLL_CTRL_OD_MASK) >> PLL_CTRL_OD_SHIFT;
 	POD = (pll_reg & PLL_CTRL_POD_MASK) >> PLL_CTRL_POD_SHIFT;
 
-	return DEFAULT_INPUT_CLOCK * M / N / (1 << OD) / (1 << POD);
+	return DEFAULT_INPUT_CLOCK * M / N / (BIT(OD)) / (BIT(POD));

You don't need the parentheses around the call to BIT. BIT will take care of it.

julia

Quoted 13 lines
drivers/staging/sm750fb/ddk750_chip.c +0 -1
 }
 
 /*
--

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 post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190325070536.5463-1-sanjana99reddy99%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 31 lines · Julia Lawall
Quoted 12 lines · Sanjana Sanikommu

Challenge suggested by coccinelle.

Replace bit shifting on 1 with the BIT(x) macro.
Coccinelle script:

@@
constant c;
@@

-1 << c
+BIT(c)

Review

Quoted 6 lines
Signed-off-by Sanjana Sanikommu <[email protected] <javascript:>>

---

 drivers/staging/sm750fb/ddk750_chip.c | 2 +- 
 1 file changed, 1 insertion(+), 1 deletion(-) 
(quoted diff) +0 -0

b/drivers/staging/sm750fb/ddk750_chip.c

Quoted 7 lines

index 4c1f00f551da..5690fb46e095 100644

drivers/staging/sm750fb/ddk750_chip.c +0 -0
@@ -45,7 +45,7 @@ static unsigned int get_mxclk_freq(void) 
         OD = (pll_reg & PLL_CTRL_OD_MASK) >> PLL_CTRL_OD_SHIFT; 
         POD = (pll_reg & PLL_CTRL_POD_MASK) >> PLL_CTRL_POD_SHIFT; 
 
Quoted 6 lines

drivers/staging/sm750fb/ddk750_chip.c static unsigned int get_mxclk_freq(void) · line 48

Quoted 2 lines
drivers/staging/sm750fb/ddk750_chip.c +1 -1
-        return DEFAULT_INPUT_CLOCK * M / N / (1 << OD) / (1 << POD); 
+        return DEFAULT_INPUT_CLOCK * M / N / (BIT(OD)) / (BIT(POD)); 

You don't need the parentheses around the call to BIT. BIT will take care of it.

Sure I would change it :)
Sanjana

Quoted 22 lines

julia

Quoted 8 lines
drivers/staging/sm750fb/ddk750_chip.c +0 -0
 } 
 
 /* 
Signature · 4 lines
2.17.1 

-- 
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] <javascript:>.

Quoted 1 line

To post to this group, send email to [email protected]

<javascript:>.

Quoted 1 line

To view this discussion on the web visit

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

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.