Skip to contentSkip to conversation

staging: sm750fb: replace macro w builtin fn

PATCH In review Elizabeth Ferdman 2 participants 2 messages Sep 28, 2016 – Sep 29, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: sm750fb: replace macro w builtin fn

Replace the unique arithmetic macro expression with a built-in function from linux/kernel.h DIV_ROUND_CLOSEST(x, divisor).

---
Changes in v2:
- Change commit message
- replace arithmetic expression with built in function

 drivers/staging/sm750fb/ddk750_chip.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/sm750fb/ddk750_chip.c +2 -6
index 3a0afe1..0c96a17 100644
@@ -6,8 +6,6 @@
 #include "ddk750_chip.h"
 #include "ddk750_power.h"
 
-/* n / d + 1 / 2 = (2n + d) / 2d */
-#define roundedDiv(num, denom)	((2 * (num) + (denom)) / (2 * (denom)))
 #define MHz(x) ((x) * 1000000)
 
 logical_chip_type_t sm750_get_chip_type(void)
@@ -102,7 +100,7 @@ static void setMemoryClock(unsigned int frequency)
 			frequency = MHz(336);
 
 		/* Calculate the divisor */
-		divisor = roundedDiv(get_mxclk_freq(), frequency);
+		divisor = DIV_ROUND_CLOSEST(get_mxclk_freq(), frequency);
 
 		/* Set the corresponding divisor in the register. */
 		reg = PEEK32(CURRENT_GATE) & ~CURRENT_GATE_M2XCLK_MASK;
@@ -152,7 +150,7 @@ static void setMasterClock(unsigned int frequency)
 			frequency = MHz(190);
 
 		/* Calculate the divisor */
-		divisor = roundedDiv(get_mxclk_freq(), frequency);
+		divisor = DIV_ROUND_CLOSEST(get_mxclk_freq(), frequency);
 
 		/* Set the corresponding divisor in the register. */
 		reg = PEEK32(CURRENT_GATE) & ~CURRENT_GATE_MCLK_MASK;
@@ -401,5 +399,3 @@ unsigned int formatPllReg(pll_value_t *pPLL)
 
 	return reg;
 }
-
-
Signature · 1 line
2.1.4
#1 lore raw
Quoted 1 line · Elizabeth Ferdman

Replace the unique arithmetic macro expression with a built-in

I don't understand "unique arithmetic macro expression".

Quoted 1 line

function from linux/kernel.h DIV_ROUND_CLOSEST(x, divisor).

Some blank lines are deleted at the end of the patch. This seems like a separate change.

julia

Quoted 57 lines

---
Changes in v2:
- Change commit message
- replace arithmetic expression with built in function

 drivers/staging/sm750fb/ddk750_chip.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/sm750fb/ddk750_chip.c +2 -7
index 3a0afe1..0c96a17 100644
@@ -6,8 +6,6 @@
 #include "ddk750_chip.h"
 #include "ddk750_power.h"
 
-/* n / d + 1 / 2 = (2n + d) / 2d */
-#define roundedDiv(num, denom)	((2 * (num) + (denom)) / (2 * (denom)))
 #define MHz(x) ((x) * 1000000)
 
 logical_chip_type_t sm750_get_chip_type(void)
@@ -102,7 +100,7 @@ static void setMemoryClock(unsigned int frequency)
 			frequency = MHz(336);
 
 		/* Calculate the divisor */
-		divisor = roundedDiv(get_mxclk_freq(), frequency);
+		divisor = DIV_ROUND_CLOSEST(get_mxclk_freq(), frequency);
 
 		/* Set the corresponding divisor in the register. */
 		reg = PEEK32(CURRENT_GATE) & ~CURRENT_GATE_M2XCLK_MASK;
@@ -152,7 +150,7 @@ static void setMasterClock(unsigned int frequency)
 			frequency = MHz(190);
 
 		/* Calculate the divisor */
-		divisor = roundedDiv(get_mxclk_freq(), frequency);
+		divisor = DIV_ROUND_CLOSEST(get_mxclk_freq(), frequency);
 
 		/* Set the corresponding divisor in the register. */
 		reg = PEEK32(CURRENT_GATE) & ~CURRENT_GATE_MCLK_MASK;
@@ -401,5 +399,3 @@ unsigned int formatPllReg(pll_value_t *pPLL)
 
 	return reg;
 }
-
-
--

2.1.4

--
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/20160928234631.GA31844%40localhost.
For more options, visit https://groups.google.com/d/optout.