[U-Boot] [PATCH] [cosmetic], i2c: Codingstyle cleanup for i2c evb64260 board driver

Heiko Schocher hs at denx.de
Thu Nov 17 08:02:27 CET 2011


There are some magic constants in this drivers, which I cannot
fixup ... Eran, can you help here?

Signed-off-by: Heiko Schocher <hs at denx.de>
Cc: Eran Man <eran at nbase.co.il>
---
 board/evb64260/i2c.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/board/evb64260/i2c.c b/board/evb64260/i2c.c
index 3eae3d9..d943baa 100644
--- a/board/evb64260/i2c.c
+++ b/board/evb64260/i2c.c
@@ -20,25 +20,25 @@ static void
 i2c_init(int speed, int slaveaddr)
 {
 	unsigned int n, m, freq, margin, power;
-	unsigned int actualN = 0, actualM = 0;
+	unsigned int actualn = 0, actualm = 0;
 	unsigned int control, status;
-	unsigned int minMargin = 0xffffffff;
+	unsigned int minmargin = 0xffffffff;
 	unsigned int tclk = 125000000;
 
 	DP(puts("i2c_init\n"));
 
 	for (n = 0 ; n < 8 ; n++) {
 		for (m = 0 ; m < 16 ; m++) {
-			power = 2<<n; /* power = 2^(n+1) */
-			freq = tclk/(10*(m+1)*power);
+			power = 2 << n; /* power = 2^(n+1) */
+			freq = tclk / (10 * (m + 1) * power);
 			if (speed > freq)
 				margin = speed - freq;
 			else
 				margin = freq - speed;
-			if (margin < minMargin) {
-				minMargin   = margin;
-				actualN	    = n;
-				actualM	    = m;
+			if (margin < minmargin) {
+				minmargin   = margin;
+				actualn	    = n;
+				actualm	    = m;
 			}
 		}
 	}
@@ -55,7 +55,7 @@ i2c_init(int speed, int slaveaddr)
 
 	DP(puts("set baudrate\n"));
 
-	GT_REG_WRITE(I2C_STATUS_BAUDE_RATE, (actualM << 3) | actualN);
+	GT_REG_WRITE(I2C_STATUS_BAUDE_RATE, (actualn << 3) | actualn);
 	GT_REG_WRITE(I2C_CONTROL, (0x1 << 2) | (0x1 << 6));
 
 	udelay(I2C_DELAY * 10);
@@ -257,11 +257,11 @@ i2c_read(uchar dev_addr, unsigned int offset, int len, uchar *data,
 	 int ten_bit)
 {
 	uchar status = 0;
-	unsigned int i2cFreq = 400000;
+	unsigned int i2cfreq = 400000;
 
 	DP(puts("i2c_read\n"));
 
-	i2c_init(i2cFreq, 0);
+	i2c_init(i2cfreq, 0);
 
 	status = i2c_start();
 
@@ -280,7 +280,7 @@ i2c_read(uchar dev_addr, unsigned int offset, int len, uchar *data,
 		return status;
 	}
 
-	i2c_init(i2cFreq, 0);
+	i2c_init(i2cnreq, 0);
 
 	status = i2c_start();
 	if (status) {
-- 
1.7.6.4



More information about the U-Boot mailing list