Skip to contentSkip to conversation

staging: sm750fb: Code readability is improved

PATCH Superseded Arushi Singhal 3 participants 6 messages Mar 19, 2017

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 staging: sm750fb: Code readability is improved

New variables are added to make the code more readable.

---
changes in v3
-try to make the code much more readable.

 drivers/staging/sm750fb/ddk750_mode.c | 61 ++++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 26 deletions(-)
drivers/staging/sm750fb/ddk750_mode.c +35 -26
index eea5aef2956f..5f18ce4d10de 100644
@@ -81,33 +81,42 @@ static int programModeRegisters(mode_parameter_t *pModeParam, struct pll_value *
 	if (pll->clockType == SECONDARY_PLL) {
 		/* programe secondary pixel clock */
 		poke32(CRT_PLL_CTRL, sm750_format_pll_reg(pll));
-		poke32(CRT_HORIZONTAL_TOTAL,
-		       (((pModeParam->horizontal_total - 1) <<
-			 CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT) &
-			CRT_HORIZONTAL_TOTAL_TOTAL_MASK) |
-		       ((pModeParam->horizontal_display_end - 1) &
-			CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK));
-
-		poke32(CRT_HORIZONTAL_SYNC,
-		       ((pModeParam->horizontal_sync_width <<
-			 CRT_HORIZONTAL_SYNC_WIDTH_SHIFT) &
-			CRT_HORIZONTAL_SYNC_WIDTH_MASK) |
-		       ((pModeParam->horizontal_sync_start - 1) &
-			CRT_HORIZONTAL_SYNC_START_MASK));
 
-		poke32(CRT_VERTICAL_TOTAL,
-		       (((pModeParam->vertical_total - 1) <<
-			 CRT_VERTICAL_TOTAL_TOTAL_SHIFT) &
-			CRT_VERTICAL_TOTAL_TOTAL_MASK) |
-		       ((pModeParam->vertical_display_end - 1) &
-			CRT_VERTICAL_TOTAL_DISPLAY_END_MASK));
-
-		poke32(CRT_VERTICAL_SYNC,
-		       ((pModeParam->vertical_sync_height <<
-			 CRT_VERTICAL_SYNC_HEIGHT_SHIFT) &
-			CRT_VERTICAL_SYNC_HEIGHT_MASK) |
-		       ((pModeParam->vertical_sync_start - 1) &
-			CRT_VERTICAL_SYNC_START_MASK));
+		unsigned int a = (pModeParam->horizontal_total - 1) <<
+				CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT;
+		unsigned int b = a & CRT_HORIZONTAL_TOTAL_TOTAL_MASK;
+		unsigned int c = (pModeParam->horizontal_display_end - 1) &
+				CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK;
+		unsigned int temp = b | c;
+
+		poke32(CRT_HORIZONTAL_TOTAL, temp);
+
+		unsigned int a = (pModeParam->horizontal_sync_width <<
+				CRT_HORIZONTAL_SYNC_WIDTH_SHIFT);
+		unsigned int b = a & CRT_HORIZONTAL_SYNC_WIDTH_MASK;
+		unsigned int c = (pModeParam->horizontal_sync_start - 1) &
+				CRT_HORIZONTAL_SYNC_START_MASK;
+		unsigned int temp = b | c;
+
+		poke32(CRT_HORIZONTAL_SYNC, temp);
+
+		unsigned int a = (pModeParam->vertical_total - 1) <<
+				CRT_VERTICAL_TOTAL_TOTAL_SHIFT;
+		unsigned int b = a & CRT_VERTICAL_TOTAL_TOTAL_MASK;
+		unsigned int c = (pModeParam->vertical_display_end - 1) &
+				CRT_VERTICAL_TOTAL_DISPLAY_END_MASK;
+		unsigned int temp = b | c;
+
+		poke32(CRT_VERTICAL_TOTAL, temp);
+
+		unsigned int a = pModeParam->vertical_sync_height <<
+				CRT_VERTICAL_SYNC_HEIGHT_SHIFT;
+		unsigned int b = a & CRT_VERTICAL_SYNC_HEIGHT_MASK;
+		unsigned int c = (pModeParam->vertical_sync_start - 1) &
+				CRT_VERTICAL_SYNC_START_MASK;
+		unsigned int temp = b | c;
+
+		poke32(CRT_VERTICAL_SYNC, temp);
 
 		tmp = DISPLAY_CTRL_TIMING | DISPLAY_CTRL_PLANE;
 		if (pModeParam->vertical_sync_polarity)
Signature · 1 line
2.11.0
#1 lore raw
Quoted 50 lines · Arushi Singhal

New variables are added to make the code more readable.

---
changes in v3
-try to make the code much more readable.

 drivers/staging/sm750fb/ddk750_mode.c | 61 ++++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 26 deletions(-)
drivers/staging/sm750fb/ddk750_mode.c +5 -26
index eea5aef2956f..5f18ce4d10de 100644
@@ -81,33 +81,42 @@ static int programModeRegisters(mode_parameter_t *pModeParam, struct pll_value *
 	if (pll->clockType = SECONDARY_PLL) {
 		/* programe secondary pixel clock */
 		poke32(CRT_PLL_CTRL, sm750_format_pll_reg(pll));
-		poke32(CRT_HORIZONTAL_TOTAL,
-		       (((pModeParam->horizontal_total - 1) <<
-			 CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT) &
-			CRT_HORIZONTAL_TOTAL_TOTAL_MASK) |
-		       ((pModeParam->horizontal_display_end - 1) &
-			CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK));
-
-		poke32(CRT_HORIZONTAL_SYNC,
-		       ((pModeParam->horizontal_sync_width <<
-			 CRT_HORIZONTAL_SYNC_WIDTH_SHIFT) &
-			CRT_HORIZONTAL_SYNC_WIDTH_MASK) |
-		       ((pModeParam->horizontal_sync_start - 1) &
-			CRT_HORIZONTAL_SYNC_START_MASK));
 
-		poke32(CRT_VERTICAL_TOTAL,
-		       (((pModeParam->vertical_total - 1) <<
-			 CRT_VERTICAL_TOTAL_TOTAL_SHIFT) &
-			CRT_VERTICAL_TOTAL_TOTAL_MASK) |
-		       ((pModeParam->vertical_display_end - 1) &
-			CRT_VERTICAL_TOTAL_DISPLAY_END_MASK));
-
-		poke32(CRT_VERTICAL_SYNC,
-		       ((pModeParam->vertical_sync_height <<
-			 CRT_VERTICAL_SYNC_HEIGHT_SHIFT) &
-			CRT_VERTICAL_SYNC_HEIGHT_MASK) |
-		       ((pModeParam->vertical_sync_start - 1) &
-			CRT_VERTICAL_SYNC_START_MASK));
+		unsigned int a = (pModeParam->horizontal_total - 1) <<
+				CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT;
+		unsigned int b = a & CRT_HORIZONTAL_TOTAL_TOTAL_MASK;
+		unsigned int c = (pModeParam->horizontal_display_end - 1) &
+				CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK;

drivers/staging/sm750fb/ddk750_mode.c static int programModeRegisters(mode_parameter_t *pModeParam, struct pll_value * · line 99

Quoted 10 lines
drivers/staging/sm750fb/ddk750_mode.c +10 -0
+		unsigned int temp = b | c;
+
+		poke32(CRT_HORIZONTAL_TOTAL, temp);
+
+		unsigned int a = (pModeParam->horizontal_sync_width <<
+				CRT_HORIZONTAL_SYNC_WIDTH_SHIFT);
+		unsigned int b = a & CRT_HORIZONTAL_SYNC_WIDTH_MASK;
+		unsigned int c = (pModeParam->horizontal_sync_start - 1) &
+				CRT_HORIZONTAL_SYNC_START_MASK;
+		unsigned int temp = b | c;

This is back to the original incorrect solution. You can't declare variables on the fly in Linux code. Variables have to be declared at the top of a block.

But you can reuse the same variables over and over, if no one cares about their previous values.

julia

Quoted 33 lines
drivers/staging/sm750fb/ddk750_mode.c +20 -1
+
+		poke32(CRT_HORIZONTAL_SYNC, temp);
+
+		unsigned int a = (pModeParam->vertical_total - 1) <<
+				CRT_VERTICAL_TOTAL_TOTAL_SHIFT;
+		unsigned int b = a & CRT_VERTICAL_TOTAL_TOTAL_MASK;
+		unsigned int c = (pModeParam->vertical_display_end - 1) &
+				CRT_VERTICAL_TOTAL_DISPLAY_END_MASK;
+		unsigned int temp = b | c;
+
+		poke32(CRT_VERTICAL_TOTAL, temp);
+
+		unsigned int a = pModeParam->vertical_sync_height <<
+				CRT_VERTICAL_SYNC_HEIGHT_SHIFT;
+		unsigned int b = a & CRT_VERTICAL_SYNC_HEIGHT_MASK;
+		unsigned int c = (pModeParam->vertical_sync_start - 1) &
+				CRT_VERTICAL_SYNC_START_MASK;
+		unsigned int temp = b | c;
+
+		poke32(CRT_VERTICAL_SYNC, temp);
 
 		tmp = DISPLAY_CTRL_TIMING | DISPLAY_CTRL_PLANE;
 		if (pModeParam->vertical_sync_polarity)
--

2.11.0

--
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/20170319130744.GA24605%40arushi-HP-Pavilion-Notebook.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 57 lines · Julia Lawall
Quoted 56 lines · Arushi Singhal

New variables are added to make the code more readable.

---
changes in v3
-try to make the code much more readable.

 drivers/staging/sm750fb/ddk750_mode.c | 61 ++++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 26 deletions(-)
drivers/staging/sm750fb/ddk750_mode.c +11 -26
index eea5aef2956f..5f18ce4d10de 100644
@@ -81,33 +81,42 @@ static int programModeRegisters(mode_parameter_t *pModeParam, struct pll_value *
      if (pll->clockType = SECONDARY_PLL) {
              /* programe secondary pixel clock */
              poke32(CRT_PLL_CTRL, sm750_format_pll_reg(pll));
-             poke32(CRT_HORIZONTAL_TOTAL,
-                    (((pModeParam->horizontal_total - 1) <<
-                      CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT) &
-                     CRT_HORIZONTAL_TOTAL_TOTAL_MASK) |
-                    ((pModeParam->horizontal_display_end - 1) &
-                     CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK));
-
-             poke32(CRT_HORIZONTAL_SYNC,
-                    ((pModeParam->horizontal_sync_width <<
-                      CRT_HORIZONTAL_SYNC_WIDTH_SHIFT) &
-                     CRT_HORIZONTAL_SYNC_WIDTH_MASK) |
-                    ((pModeParam->horizontal_sync_start - 1) &
-                     CRT_HORIZONTAL_SYNC_START_MASK));
 
-             poke32(CRT_VERTICAL_TOTAL,
-                    (((pModeParam->vertical_total - 1) <<
-                      CRT_VERTICAL_TOTAL_TOTAL_SHIFT) &
-                     CRT_VERTICAL_TOTAL_TOTAL_MASK) |
-                    ((pModeParam->vertical_display_end - 1) &
-                     CRT_VERTICAL_TOTAL_DISPLAY_END_MASK));
-
-             poke32(CRT_VERTICAL_SYNC,
-                    ((pModeParam->vertical_sync_height <<
-                      CRT_VERTICAL_SYNC_HEIGHT_SHIFT) &
-                     CRT_VERTICAL_SYNC_HEIGHT_MASK) |
-                    ((pModeParam->vertical_sync_start - 1) &
-                     CRT_VERTICAL_SYNC_START_MASK));
+             unsigned int a = (pModeParam->horizontal_total - 1) <<
+                             CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT;
+             unsigned int b = a & CRT_HORIZONTAL_TOTAL_TOTAL_MASK;
+             unsigned int c = (pModeParam->horizontal_display_end - 1) &
+                             CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK;
+             unsigned int temp = b | c;
+
+             poke32(CRT_HORIZONTAL_TOTAL, temp);
+
+             unsigned int a = (pModeParam->horizontal_sync_width <<
+                             CRT_HORIZONTAL_SYNC_WIDTH_SHIFT);
Quoted 8 lines

drivers/staging/sm750fb/ddk750_mode.c static int programModeRegisters(mode_parameter_t *pModeParam, struct pll_value * · line 99

Quoted 4 lines
drivers/staging/sm750fb/ddk750_mode.c +4 -0
+             unsigned int b = a & CRT_HORIZONTAL_SYNC_WIDTH_MASK;
+             unsigned int c = (pModeParam->horizontal_sync_start - 1) &
+                             CRT_HORIZONTAL_SYNC_START_MASK;
+             unsigned int temp = b | c;

This is back to the original incorrect solution. You can't declare variables on the fly in Linux code. Variables have to be declared at the top of a block.

Arushi: have you tried to compile this?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#3 lore raw
Quoted 66 lines · Geert Uytterhoeven
Quoted 9 lines · Julia Lawall
Quoted 8 lines · Arushi Singhal

New variables are added to make the code more readable.

---
changes in v3
-try to make the code much more readable.

 drivers/staging/sm750fb/ddk750_mode.c | 61

++++++++++++++++++++---------------

Quoted 3 lines

Review

Quoted 3 lines
 1 file changed, 35 insertions(+), 26 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/sm750fb/ddk750_mode.c

Quoted 4 lines

drivers/staging/sm750fb/ddk750_mode.c static int programModeRegisters(mode_parameter_t

Quoted 4 lines

index eea5aef2956f..5f18ce4d10de 100644

drivers/staging/sm750fb/ddk750_mode.c +0 -0
@@ -81,33 +81,42 @@ static int programModeRegisters(mode_parameter_t

*pModeParam, struct pll_value *

Quoted 26 lines
Quoted 26 lines
drivers/staging/sm750fb/ddk750_mode.c +0 -22
      if (pll->clockType == SECONDARY_PLL) {
              /* programe secondary pixel clock */
              poke32(CRT_PLL_CTRL, sm750_format_pll_reg(pll));
-             poke32(CRT_HORIZONTAL_TOTAL,
-                    (((pModeParam->horizontal_total - 1) <<
-                      CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT) &
-                     CRT_HORIZONTAL_TOTAL_TOTAL_MASK) |
-                    ((pModeParam->horizontal_display_end - 1) &
-                     CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK));
-
-             poke32(CRT_HORIZONTAL_SYNC,
-                    ((pModeParam->horizontal_sync_width <<
-                      CRT_HORIZONTAL_SYNC_WIDTH_SHIFT) &
-                     CRT_HORIZONTAL_SYNC_WIDTH_MASK) |
-                    ((pModeParam->horizontal_sync_start - 1) &
-                     CRT_HORIZONTAL_SYNC_START_MASK));
 
-             poke32(CRT_VERTICAL_TOTAL,
-                    (((pModeParam->vertical_total - 1) <<
-                      CRT_VERTICAL_TOTAL_TOTAL_SHIFT) &
-                     CRT_VERTICAL_TOTAL_TOTAL_MASK) |
-                    ((pModeParam->vertical_display_end - 1) &
-                     CRT_VERTICAL_TOTAL_DISPLAY_END_MASK));
-
-             poke32(CRT_VERTICAL_SYNC,
-                    ((pModeParam->vertical_sync_height <<
Quoted 8 lines

drivers/staging/sm750fb/ddk750_mode.c static int programModeRegisters(mode_parameter_t *pModeParam, struct pll_value *

Quoted 8 lines
drivers/staging/sm750fb/ddk750_mode.c +4 -4
-                      CRT_VERTICAL_SYNC_HEIGHT_SHIFT) &
-                     CRT_VERTICAL_SYNC_HEIGHT_MASK) |
-                    ((pModeParam->vertical_sync_start - 1) &
-                     CRT_VERTICAL_SYNC_START_MASK));
+             unsigned int a = (pModeParam->horizontal_total - 1) <<
+                             CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT;
+             unsigned int b = a & CRT_HORIZONTAL_TOTAL_TOTAL_MASK;
+             unsigned int c = (pModeParam->horizontal_display_end -

1) &

Quoted 9 lines

drivers/staging/sm750fb/ddk750_mode.c static int programModeRegisters(mode_parameter_t *pModeParam, struct pll_value *

Quoted 9 lines
drivers/staging/sm750fb/ddk750_mode.c +9 -0
+                             CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK;
+             unsigned int temp = b | c;
+
+             poke32(CRT_HORIZONTAL_TOTAL, temp);
+
+             unsigned int a = (pModeParam->horizontal_sync_width <<
+                             CRT_HORIZONTAL_SYNC_WIDTH_SHIFT);
+             unsigned int b = a & CRT_HORIZONTAL_SYNC_WIDTH_MASK;
+             unsigned int c = (pModeParam->horizontal_sync_start - 1)

&

Quoted 9 lines
Quoted 6 lines

drivers/staging/sm750fb/ddk750_mode.c static int programModeRegisters(mode_parameter_t · line 99

Quoted 2 lines
drivers/staging/sm750fb/ddk750_mode.c +2 -0
+                             CRT_HORIZONTAL_SYNC_START_MASK;
+             unsigned int temp = b | c;

This is back to the original incorrect solution. You can't declare variables on the fly in Linux code. Variables have to be declared at the top of a block.

Arushi: have you tried to compile this?

Yes.
It's not showing any error.
Is it not fine when you compiled :( ?
Arushi

Quoted 15 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#4 lore raw
Quoted 77 lines · Arushi Singhal
Quoted 75 lines · Geert Uytterhoeven
Quoted 71 lines · Julia Lawall
Quoted 63 lines · Arushi Singhal

New variables are added to make the code more readable.

---
changes in v3
-try to make the code much more readable.

 drivers/staging/sm750fb/ddk750_mode.c | 61
++++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 26 deletions(-)
drivers/staging/sm750fb/ddk750_mode.c +4 -26
index eea5aef2956f..5f18ce4d10de 100644
@@ -81,33 +81,42 @@ static int programModeRegisters(mode_parameter_t
 *pModeParam, struct pll_value *
      if (pll->clockType = SECONDARY_PLL) {
              /* programe secondary pixel clock */
              poke32(CRT_PLL_CTRL, sm750_format_pll_reg(pll));
-             poke32(CRT_HORIZONTAL_TOTAL,
-                    (((pModeParam->horizontal_total - 1) <<
-                      CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT) &
-                     CRT_HORIZONTAL_TOTAL_TOTAL_MASK) |
-                    ((pModeParam->horizontal_display_end - 1) &
-                     CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK));
-
-             poke32(CRT_HORIZONTAL_SYNC,
-                    ((pModeParam->horizontal_sync_width <<
-                      CRT_HORIZONTAL_SYNC_WIDTH_SHIFT) &
-                     CRT_HORIZONTAL_SYNC_WIDTH_MASK) |
-                    ((pModeParam->horizontal_sync_start - 1) &
-                     CRT_HORIZONTAL_SYNC_START_MASK));
 
-             poke32(CRT_VERTICAL_TOTAL,
-                    (((pModeParam->vertical_total - 1) <<
-                      CRT_VERTICAL_TOTAL_TOTAL_SHIFT) &
-                     CRT_VERTICAL_TOTAL_TOTAL_MASK) |
-                    ((pModeParam->vertical_display_end - 1) &
-                     CRT_VERTICAL_TOTAL_DISPLAY_END_MASK));
-
-             poke32(CRT_VERTICAL_SYNC,
-                    ((pModeParam->vertical_sync_height <<
-                      CRT_VERTICAL_SYNC_HEIGHT_SHIFT) &
-                     CRT_VERTICAL_SYNC_HEIGHT_MASK) |
-                    ((pModeParam->vertical_sync_start - 1) &
-                     CRT_VERTICAL_SYNC_START_MASK));
+             unsigned int a = (pModeParam->horizontal_total - 1) <<
+                             CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT;
+             unsigned int b = a & CRT_HORIZONTAL_TOTAL_TOTAL_MASK;
+             unsigned int c = (pModeParam->horizontal_display_end - 1)

&

drivers/staging/sm750fb/ddk750_mode.c +9 -0
+                             CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK;
+             unsigned int temp = b | c;
+
+             poke32(CRT_HORIZONTAL_TOTAL, temp);
+
+             unsigned int a = (pModeParam->horizontal_sync_width <<
+                             CRT_HORIZONTAL_SYNC_WIDTH_SHIFT);
+             unsigned int b = a & CRT_HORIZONTAL_SYNC_WIDTH_MASK;
+             unsigned int c = (pModeParam->horizontal_sync_start - 1)

&

drivers/staging/sm750fb/ddk750_mode.c

Quoted 2 lines
drivers/staging/sm750fb/ddk750_mode.c +2 -0
+                             CRT_HORIZONTAL_SYNC_START_MASK;
+             unsigned int temp = b | c;

This is back to the original incorrect solution. You can't declare variables on the fly in Linux code. Variables have to be declared at the
top of a block.

Quoted 4 lines
Quoted 1 line

Arushi: have you tried to compile this?

Yes.
It's not showing any error.

No, not an error.

Quoted 1 line

Is it not fine when you compiled :( ?

But you did introduce warnings, like:

drivers/staging/sm750fb/ddk750_mode.c: In function 'programModeRegisters':
drivers/staging/sm750fb/ddk750_mode.c:87:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#5 lore raw
Quoted 84 lines · Geert Uytterhoeven
Quoted 1 line · Arushi Singhal

On Sun, Mar 19, 2017 at 7:34 PM, Geert Uytterhoeven <

[email protected]>

Quoted 49 lines
Quoted 48 lines · wrote:
Quoted 45 lines · Julia Lawall
Quoted 44 lines · Arushi Singhal

New variables are added to make the code more readable.

---
changes in v3
-try to make the code much more readable.

 drivers/staging/sm750fb/ddk750_mode.c | 61
++++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 26 deletions(-)
drivers/staging/sm750fb/ddk750_mode.c +0 -22
index eea5aef2956f..5f18ce4d10de 100644
@@ -81,33 +81,42 @@ static int programModeRegisters(mode_parameter_t
 *pModeParam, struct pll_value *
      if (pll->clockType == SECONDARY_PLL) {
              /* programe secondary pixel clock */
              poke32(CRT_PLL_CTRL, sm750_format_pll_reg(pll));
-             poke32(CRT_HORIZONTAL_TOTAL,
-                    (((pModeParam->horizontal_total - 1) <<
-                      CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT) &
-                     CRT_HORIZONTAL_TOTAL_TOTAL_MASK) |
-                    ((pModeParam->horizontal_display_end - 1) &
-                     CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK));
-
-             poke32(CRT_HORIZONTAL_SYNC,
-                    ((pModeParam->horizontal_sync_width <<
-                      CRT_HORIZONTAL_SYNC_WIDTH_SHIFT) &
-                     CRT_HORIZONTAL_SYNC_WIDTH_MASK) |
-                    ((pModeParam->horizontal_sync_start - 1) &
-                     CRT_HORIZONTAL_SYNC_START_MASK));
 
-             poke32(CRT_VERTICAL_TOTAL,
-                    (((pModeParam->vertical_total - 1) <<
-                      CRT_VERTICAL_TOTAL_TOTAL_SHIFT) &
-                     CRT_VERTICAL_TOTAL_TOTAL_MASK) |
-                    ((pModeParam->vertical_display_end - 1) &
-                     CRT_VERTICAL_TOTAL_DISPLAY_END_MASK));
-
-             poke32(CRT_VERTICAL_SYNC,
-                    ((pModeParam->vertical_sync_height <<
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/staging/sm750fb/ddk750_mode.c static int programModeRegisters(mode_parameter_t *pModeParam, struct pll_value *

Quoted 8 lines
drivers/staging/sm750fb/ddk750_mode.c +4 -4
-                      CRT_VERTICAL_SYNC_HEIGHT_SHIFT) &
-                     CRT_VERTICAL_SYNC_HEIGHT_MASK) |
-                    ((pModeParam->vertical_sync_start - 1) &
-                     CRT_VERTICAL_SYNC_START_MASK));
+             unsigned int a = (pModeParam->horizontal_total - 1) <<
+                             CRT_HORIZONTAL_TOTAL_TOTAL_SHIFT;
+             unsigned int b = a & CRT_HORIZONTAL_TOTAL_TOTAL_MASK;
+             unsigned int c = (pModeParam->horizontal_display_end

- 1)

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

drivers/staging/sm750fb/ddk750_mode.c static int programModeRegisters(mode_parameter_t *pModeParam, struct pll_value *

Quoted 10 lines

&

drivers/staging/sm750fb/ddk750_mode.c +9 -0
+                             CRT_HORIZONTAL_TOTAL_DISPLAY_END_MASK;
+             unsigned int temp = b | c;
+
+             poke32(CRT_HORIZONTAL_TOTAL, temp);
+
+             unsigned int a = (pModeParam->horizontal_sync_width <<
+                             CRT_HORIZONTAL_SYNC_WIDTH_SHIFT);
+             unsigned int b = a & CRT_HORIZONTAL_SYNC_WIDTH_MASK;
+             unsigned int c = (pModeParam->horizontal_sync_start -

1)

Quoted 11 lines
Quoted 10 lines
Quoted 8 lines

drivers/staging/sm750fb/ddk750_mode.c

Quoted 3 lines

&

drivers/staging/sm750fb/ddk750_mode.c +2 -0
+                             CRT_HORIZONTAL_SYNC_START_MASK;
+             unsigned int temp = b | c;

This is back to the original incorrect solution. You can't declare variables on the fly in Linux code. Variables have to be declared at the
top of a block.

Arushi: have you tried to compile this?

Quoted 10 lines
Quoted 2 lines

Yes.
It's not showing any error.

No, not an error.

Quoted 1 line

Is it not fine when you compiled :( ?

But you did introduce warnings, like:

drivers/staging/sm750fb/ddk750_mode.c: In function 'programModeRegisters':

Quoted 4 lines

drivers/staging/sm750fb/ddk750_mode.c:87:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

No

Arushi

Quoted 14 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds