Skip to contentSkip to conversation

aty128fb: move block to where it should be in function aty128_var_to_pll

PATCH In review Jaswinder Singh Rajput 2 participants 4 messages Sep 20, 2009 – Sep 22, 2009 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aty128fb: move block to where it should be in function aty128_var_to_pll

In function aty128_var_to_pll moving block to where it should be.

This also fixed following compilation warning:
CC [M] drivers/video/aty/aty128fb.o
drivers/video/aty/aty128fb.c: In function ‘aty128_decode_var’:
drivers/video/aty/aty128fb.c:1520: warning: ‘pll.post_divider’ may be used uninitialized in this function

---
 drivers/video/aty/aty128fb.c |   33 ++++++++++++++++-----------------
 1 files changed, 16 insertions(+), 17 deletions(-)
drivers/video/aty/aty128fb.c +16 -17
index e4e4d43..fd6746e 100644
@@ -1328,8 +1328,7 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
 	unsigned char post_dividers[] = {1,2,4,8,3,6,12};
 	u32 output_freq;
 	u32 vclk;        /* in .01 MHz */
-	int i = 0;
-	u32 n, d;
+	int i;
 
 	vclk = 100000000 / period_in_ps;	/* convert units to 10 kHz */
 
@@ -1343,27 +1342,27 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
 	for (i = 0; i < ARRAY_SIZE(post_dividers); i++) {
 		output_freq = post_dividers[i] * vclk;
 		if (output_freq >= c.ppll_min && output_freq <= c.ppll_max) {
+			u32 n, d;
+
 			pll->post_divider = post_dividers[i];
-			break;
-		}
-	}
 
-	if (i == ARRAY_SIZE(post_dividers))
-		return -EINVAL;
+			/* calculate feedback divider */
+			n = c.ref_divider * output_freq;
+			d = c.ref_clk;
 
-	/* calculate feedback divider */
-	n = c.ref_divider * output_freq;
-	d = c.ref_clk;
+			pll->feedback_divider = round_div(n, d);
+			pll->vclk = vclk;
 
-	pll->feedback_divider = round_div(n, d);
-	pll->vclk = vclk;
+			DBG("post %d feedback %d vlck %d output %d "
+			    "ref_divider %d vclk_per: %d\n", pll->post_divider,
+			    pll->feedback_divider, vclk, output_freq,
+			    c.ref_divider, period_in_ps);
 
-	DBG("post %d feedback %d vlck %d output %d ref_divider %d "
-	    "vclk_per: %d\n", pll->post_divider,
-	    pll->feedback_divider, vclk, output_freq,
-	    c.ref_divider, period_in_ps);
+			return 0;
+		}
+	}
 
-	return 0;
+	return -EINVAL;
 }
 
 
Signature · 14 lines
1.6.4.4



------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Linux-fbdev-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel
#1 lore raw
Quoted 6 lines · Jaswinder Singh Rajput

In function aty128_var_to_pll moving block to where it should be.

This also fixed following compilation warning:
CC [M] drivers/video/aty/aty128fb.o
drivers/video/aty/aty128fb.c: In function ‘aty128_decode_var’:
drivers/video/aty/aty128fb.c:1520: warning: ‘pll.post_divider’ may be used uninitialized in this function

I dislike moving pretty much the whole function 2 indentation levels to the right just because gcc is being silly.

If you really want to silence that warning, just initialize the value

Ben.

Quoted 52 lines
---
 drivers/video/aty/aty128fb.c |   33 ++++++++++++++++-----------------
 1 files changed, 16 insertions(+), 17 deletions(-)
drivers/video/aty/aty128fb.c +12 -15
index e4e4d43..fd6746e 100644
@@ -1328,8 +1328,7 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
 	unsigned char post_dividers[] = {1,2,4,8,3,6,12};
 	u32 output_freq;
 	u32 vclk;        /* in .01 MHz */
-	int i = 0;
-	u32 n, d;
+	int i;
 
 	vclk = 100000000 / period_in_ps;	/* convert units to 10 kHz */
 
@@ -1343,27 +1342,27 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
 	for (i = 0; i < ARRAY_SIZE(post_dividers); i++) {
 		output_freq = post_dividers[i] * vclk;
 		if (output_freq >= c.ppll_min && output_freq <= c.ppll_max) {
+			u32 n, d;
+
 			pll->post_divider = post_dividers[i];
-			break;
-		}
-	}
 
-	if (i == ARRAY_SIZE(post_dividers))
-		return -EINVAL;
+			/* calculate feedback divider */
+			n = c.ref_divider * output_freq;
+			d = c.ref_clk;
 
-	/* calculate feedback divider */
-	n = c.ref_divider * output_freq;
-	d = c.ref_clk;
+			pll->feedback_divider = round_div(n, d);
+			pll->vclk = vclk;
 
-	pll->feedback_divider = round_div(n, d);
-	pll->vclk = vclk;
+			DBG("post %d feedback %d vlck %d output %d "
+			    "ref_divider %d vclk_per: %d\n", pll->post_divider,
+			    pll->feedback_divider, vclk, output_freq,
+			    c.ref_divider, period_in_ps);
 
-	DBG("post %d feedback %d vlck %d output %d ref_divider %d "
-	    "vclk_per: %d\n", pll->post_divider,
-	    pll->feedback_divider, vclk, output_freq,

drivers/video/aty/aty128fb.c static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll, · line 1368

Quoted 10 lines
drivers/video/aty/aty128fb.c +4 -2
-	    c.ref_divider, period_in_ps);
+			return 0;
+		}
+	}
 
-	return 0;
+	return -EINVAL;
 }
 
 

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Linux-fbdev-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel

#2 lore raw

Hello Ben,

Quoted 11 lines · Benjamin Herrenschmidt
Quoted 6 lines · Jaswinder Singh Rajput

In function aty128_var_to_pll moving block to where it should be.

This also fixed following compilation warning:
CC [M] drivers/video/aty/aty128fb.o
drivers/video/aty/aty128fb.c: In function ‘aty128_decode_var’:
drivers/video/aty/aty128fb.c:1520: warning: ‘pll.post_divider’ may be used uninitialized in this function

I dislike moving pretty much the whole function 2 indentation levels to the right just because gcc is being silly.

Indentation is not an issue if I am not breaking any lines. I am moving the function where it should be and avoid unnecessary goto(break) and duplicate checking 'if (i == ARRAY_SIZE(post_dividers))'.

Quoted 2 lines

If you really want to silence that warning, just initialize the value

I am trying to save some CPU cycles and you are suggesting to add some more ;-)

--
JSR

Quoted 58 lines
Quoted 58 lines
---
 drivers/video/aty/aty128fb.c |   33 ++++++++++++++++-----------------
 1 files changed, 16 insertions(+), 17 deletions(-)
drivers/video/aty/aty128fb.c +15 -16
index e4e4d43..fd6746e 100644
@@ -1328,8 +1328,7 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
 	unsigned char post_dividers[] = {1,2,4,8,3,6,12};
 	u32 output_freq;
 	u32 vclk;        /* in .01 MHz */
-	int i = 0;
-	u32 n, d;
+	int i;
 
 	vclk = 100000000 / period_in_ps;	/* convert units to 10 kHz */
 
@@ -1343,27 +1342,27 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
 	for (i = 0; i < ARRAY_SIZE(post_dividers); i++) {
 		output_freq = post_dividers[i] * vclk;
 		if (output_freq >= c.ppll_min && output_freq <= c.ppll_max) {
+			u32 n, d;
+
 			pll->post_divider = post_dividers[i];
-			break;
-		}
-	}
 
-	if (i == ARRAY_SIZE(post_dividers))
-		return -EINVAL;
+			/* calculate feedback divider */
+			n = c.ref_divider * output_freq;
+			d = c.ref_clk;
 
-	/* calculate feedback divider */
-	n = c.ref_divider * output_freq;
-	d = c.ref_clk;
+			pll->feedback_divider = round_div(n, d);
+			pll->vclk = vclk;
 
-	pll->feedback_divider = round_div(n, d);
-	pll->vclk = vclk;
+			DBG("post %d feedback %d vlck %d output %d "
+			    "ref_divider %d vclk_per: %d\n", pll->post_divider,
+			    pll->feedback_divider, vclk, output_freq,
+			    c.ref_divider, period_in_ps);
 
-	DBG("post %d feedback %d vlck %d output %d ref_divider %d "
-	    "vclk_per: %d\n", pll->post_divider,
-	    pll->feedback_divider, vclk, output_freq,
-	    c.ref_divider, period_in_ps);
+			return 0;
+		}
+	}
 
Quoted 5 lines

drivers/video/aty/aty128fb.c static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll, · line 1368

Quoted 5 lines
drivers/video/aty/aty128fb.c +1 -1
-	return 0;
+	return -EINVAL;
 }
 
 

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Linux-fbdev-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel

#3 lore raw
Quoted 4 lines · Jaswinder Singh Rajput

Indentation is not an issue if I am not breaking any lines. I am moving
the function where it should be and avoid unnecessary goto(break) and duplicate checking 'if (i == ARRAY_SIZE(post_dividers))'.

Where it "should be" is a matter of taste :-)

Quoted 6 lines
Quoted 1 line

If you really want to silence that warning, just initialize the

value

Quoted 1 line

I am trying to save some CPU cycles and you are suggesting to add some more ;-)

Saving CPU cycles in the mode setting code ? :-)

Anyway, Paul maintains this driver afaik so it's his call :-)

Cheers,
Ben.

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf