Re: [U-Boot] [PATCH] x86: quark: MRC codes clean up

2015-03-22 Thread Simon Glass
Hi Bin,

On 10 March 2015 at 04:31, Bin Meng  wrote:
> This patch cleans up the quark MRC codes coding style by:
> - Remove BIT0/1../31 defines from mrc_util.h
> - Create names for the documented BITs and use them
> - For undocumented single BITs, use (1 << n) directly
> - For undocumented ORed BITs, use the hex number directly
> - Remove redundancy parenthesis all over the codes
> - Replace to use lower case hex numbers
>
> Signed-off-by: Bin Meng 

The code is now 80% less awful. Thank you for taking on this task.

Applied to u-boot/x86.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] x86: quark: MRC codes clean up

2015-03-10 Thread Bin Meng
This patch cleans up the quark MRC codes coding style by:
- Remove BIT0/1../31 defines from mrc_util.h
- Create names for the documented BITs and use them
- For undocumented single BITs, use (1 << n) directly
- For undocumented ORed BITs, use the hex number directly
- Remove redundancy parenthesis all over the codes
- Replace to use lower case hex numbers

Signed-off-by: Bin Meng 
---

 arch/x86/cpu/quark/hte.c  |   74 +--
 arch/x86/cpu/quark/hte.h  |4 +-
 arch/x86/cpu/quark/mrc.c  |   12 +-
 arch/x86/cpu/quark/mrc_util.c |  326 ++-
 arch/x86/cpu/quark/mrc_util.h |   34 --
 arch/x86/cpu/quark/smc.c  | 1205 ++---
 arch/x86/cpu/quark/smc.h  |  349 +++-
 7 files changed, 955 insertions(+), 1049 deletions(-)

diff --git a/arch/x86/cpu/quark/hte.c b/arch/x86/cpu/quark/hte.c
index 372815d..db601e4 100644
--- a/arch/x86/cpu/quark/hte.c
+++ b/arch/x86/cpu/quark/hte.c
@@ -20,9 +20,9 @@
  */
 static void hte_enable_all_errors(void)
 {
-   msg_port_write(HTE, 0x000200A2, 0x);
-   msg_port_write(HTE, 0x000200A3, 0x00FF);
-   msg_port_write(HTE, 0x000200A4, 0x);
+   msg_port_write(HTE, 0x000200a2, 0x);
+   msg_port_write(HTE, 0x000200a3, 0x00ff);
+   msg_port_write(HTE, 0x000200a4, 0x);
 }
 
 /**
@@ -32,7 +32,7 @@ static void hte_enable_all_errors(void)
  */
 static u32 hte_check_errors(void)
 {
-   return msg_port_read(HTE, 0x000200A7);
+   return msg_port_read(HTE, 0x000200a7);
 }
 
 /**
@@ -44,11 +44,11 @@ static void hte_wait_for_complete(void)
 
ENTERFN();
 
-   do {} while ((msg_port_read(HTE, 0x00020012) & BIT30) != 0);
+   do {} while ((msg_port_read(HTE, 0x00020012) & (1 << 30)) != 0);
 
tmp = msg_port_read(HTE, 0x00020011);
-   tmp |= BIT9;
-   tmp &= ~(BIT12 | BIT13);
+   tmp |= (1 << 9);
+   tmp &= ~((1 << 12) | (1 << 13));
msg_port_write(HTE, 0x00020011, tmp);
 
LEAVEFN();
@@ -65,9 +65,9 @@ static void hte_clear_error_regs(void)
 * Clear all HTE errors and enable error checking
 * for burst and chunk.
 */
-   tmp = msg_port_read(HTE, 0x000200A1);
-   tmp |= BIT8;
-   msg_port_write(HTE, 0x000200A1, tmp);
+   tmp = msg_port_read(HTE, 0x000200a1);
+   tmp |= (1 << 8);
+   msg_port_write(HTE, 0x000200a1, tmp);
 }
 
 /**
@@ -91,25 +91,25 @@ static u16 hte_basic_data_cmp(struct mrc_params 
*mrc_params, u32 addr,
u32 offset;
 
if (first_run) {
-   msg_port_write(HTE, 0x00020020, 0x01B10021);
+   msg_port_write(HTE, 0x00020020, 0x01b10021);
msg_port_write(HTE, 0x00020021, 0x0600);
msg_port_write(HTE, 0x00020022, addr >> 6);
msg_port_write(HTE, 0x00020062, 0x00800015);
-   msg_port_write(HTE, 0x00020063, 0x);
-   msg_port_write(HTE, 0x00020064, 0x);
-   msg_port_write(HTE, 0x00020065, 0xF0F0F0F0);
+   msg_port_write(HTE, 0x00020063, 0x);
+   msg_port_write(HTE, 0x00020064, 0x);
+   msg_port_write(HTE, 0x00020065, 0xf0f0f0f0);
msg_port_write(HTE, 0x00020061, 0x00030008);
 
if (mode == WRITE_TRAIN)
-   pattern = 0xC33C;
+   pattern = 0xc33c;
else /* READ_TRAIN */
-   pattern = 0xAAAA;
+   pattern = 0xaaaa;
 
-   for (offset = 0x80; offset <= 0x8F; offset++)
+   for (offset = 0x80; offset <= 0x8f; offset++)
msg_port_write(HTE, offset, pattern);
}
 
-   msg_port_write(HTE, 0x000200A1, 0x1000);
+   msg_port_write(HTE, 0x000200a1, 0x1000);
msg_port_write(HTE, 0x00020011, 0x00011000);
msg_port_write(HTE, 0x00020011, 0x00011100);
 
@@ -119,7 +119,7 @@ static u16 hte_basic_data_cmp(struct mrc_params 
*mrc_params, u32 addr,
 * Return bits 15:8 of HTE_CH0_ERR_XSTAT to check for
 * any bytelane errors.
 */
-   return (hte_check_errors() >> 8) & 0xFF;
+   return (hte_check_errors() >> 8) & 0xff;
 }
 
 /**
@@ -153,7 +153,7 @@ static u16 hte_rw_data_cmp(struct mrc_params *mrc_params, 
u32 addr,
msg_port_write(HTE, 0x00020024, 0x0607);
msg_port_write(HTE, 0x00020022, addr >> 6);
msg_port_write(HTE, 0x00020025, addr >> 6);
-   msg_port_write(HTE, 0x00020062, 0x002A);
+   msg_port_write(HTE, 0x00020062, 0x002a);
msg_port_write(HTE, 0x00020063, seed_victim);
msg_port_write(HTE, 0x00020064, seed_aggressor);
msg_port_write(HTE, 0x00020065, seed_victim);
@@ -163,21 +163,21 @@ static u16 hte_rw_data_cmp(struct mrc_params *mrc_params, 
u32 addr,
 *
 * Start with bit0