[flashrom] [commit] r1560 - trunk
repository service
svn at flashrom.org
Fri Aug 3 01:54:59 CEST 2012
Author: stefanct
Date: Fri Aug 3 01:51:28 2012
New Revision: 1560
URL: http://flashrom.org/trac/flashrom/changeset/1560
Log:
Clean up a25.c, at25.c, spi25.c.
- introduce spi_prettyprint_status_register_atmel_at25_wpen()
- use spi_prettyprint_status_register_bit() where possible
- generify spi_prettyprint_status_register_bp3210 and use it in at25.c too
Signed-off-by: Stefan Tauner <stefan.tauner at student.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner at student.tuwien.ac.at>
Modified:
trunk/a25.c
trunk/at25.c
trunk/chipdrivers.h
trunk/spi25.c
Modified: trunk/a25.c
==============================================================================
--- trunk/a25.c Fri Aug 3 00:06:14 2012 (r1559)
+++ trunk/a25.c Fri Aug 3 01:51:28 2012 (r1560)
@@ -40,7 +40,7 @@
spi_prettyprint_status_register_bit(status, 6);
spi_prettyprint_status_register_bit(status, 5);
spi_prettyprint_status_register_bit(status, 4);
- spi_prettyprint_status_register_bp3210(status, 1);
+ spi_prettyprint_status_register_bp(status, 1);
spi_prettyprint_status_register_welwip(status);
return 0;
}
@@ -55,7 +55,7 @@
spi_prettyprint_status_register_amic_a25_srwd(status);
spi_prettyprint_status_register_bit(status, 6);
spi_prettyprint_status_register_bit(status, 5);
- spi_prettyprint_status_register_bp3210(status, 2);
+ spi_prettyprint_status_register_bp(status, 2);
spi_prettyprint_status_register_welwip(status);
return 0;
}
@@ -72,7 +72,7 @@
"is %i KB\n", (status & (1 << 6)) ? 4 : 64);
msg_cdbg("Chip status register: Top/Bottom (TB) "
"is %s\n", (status & (1 << 5)) ? "bottom" : "top");
- spi_prettyprint_status_register_bp3210(status, 2);
+ spi_prettyprint_status_register_bp(status, 2);
spi_prettyprint_status_register_welwip(status);
msg_cdbg("Chip status register 2 is NOT decoded!\n");
return 0;
@@ -90,7 +90,7 @@
"is %i KB\n", (status & (1 << 6)) ? 4 : 64);
msg_cdbg("Chip status register: Top/Bottom (TB) "
"is %s\n", (status & (1 << 5)) ? "bottom" : "top");
- spi_prettyprint_status_register_bp3210(status, 2);
+ spi_prettyprint_status_register_bp(status, 2);
spi_prettyprint_status_register_welwip(status);
msg_cdbg("Chip status register 2 is NOT decoded!\n");
return 0;
Modified: trunk/at25.c
==============================================================================
--- trunk/at25.c Fri Aug 3 00:06:14 2012 (r1559)
+++ trunk/at25.c Fri Aug 3 01:51:28 2012 (r1560)
@@ -23,6 +23,12 @@
/* Prettyprint the status register. Works for Atmel A25/A26 series. */
+static void spi_prettyprint_status_register_atmel_at25_wpen(uint8_t status)
+{
+ msg_cdbg("Chip status register: Write Protect Enable (WPEN) "
+ "is %sset\n", (status & (1 << 7)) ? "" : "not ");
+}
+
static void spi_prettyprint_status_register_atmel_at25_srpl(uint8_t status)
{
msg_cdbg("Chip status register: Sector Protection Register Lock (SRPL) "
@@ -91,10 +97,7 @@
spi_prettyprint_status_register_bit(status, 6);
spi_prettyprint_status_register_atmel_at25_epewpp(status);
spi_prettyprint_status_register_bit(status, 3);
- msg_cdbg("Chip status register: Block Protect 0 (BP0) is "
- "%sset, %s sectors are protected\n",
- (status & (1 << 2)) ? "" : "not ",
- (status & (1 << 2)) ? "all" : "no");
+ spi_prettyprint_status_register_bp(status, 0);
spi_prettyprint_status_register_welwip(status);
return 0;
}
@@ -106,14 +109,12 @@
status = spi_read_status_register(flash);
msg_cdbg("Chip status register is %02x\n", status);
- msg_cdbg("Chip status register: Status Register Write Protect (WPEN) "
- "is %sset\n", (status & (1 << 7)) ? "" : "not ");
+ spi_prettyprint_status_register_atmel_at25_wpen(status);
msg_cdbg("Chip status register: Bit 6 / Block Protect 4 (BP4) is "
"%sset\n", (status & (1 << 6)) ? "" : "not ");
msg_cdbg("Chip status register: Bit 5 / Block Protect 3 (BP3) is "
"%sset\n", (status & (1 << 5)) ? "" : "not ");
- msg_cdbg("Chip status register: Bit 4 is "
- "%sset\n", (status & (1 << 4)) ? "" : "not ");
+ spi_prettyprint_status_register_bit(status, 4);
msg_cdbg("Chip status register: Bit 3 / Block Protect 1 (BP1) is "
"%sset\n", (status & (1 << 3)) ? "" : "not ");
msg_cdbg("Chip status register: Bit 2 / Block Protect 0 (BP0) is "
@@ -130,18 +131,8 @@
status = spi_read_status_register(flash);
msg_cdbg("Chip status register is %02x\n", status);
- msg_cdbg("Chip status register: Status Register Write Protect (WPEN) "
- "is %sset\n", (status & (1 << 7)) ? "" : "not ");
- msg_cdbg("Chip status register: Bit 6 / Block Protect 4 (BP4) is "
- "%sset\n", (status & (1 << 6)) ? "" : "not ");
- msg_cdbg("Chip status register: Bit 5 / Block Protect 3 (BP3) is "
- "%sset\n", (status & (1 << 5)) ? "" : "not ");
- msg_cdbg("Chip status register: Bit 4 / Block Protect 2 (BP2) is "
- "%sset\n", (status & (1 << 4)) ? "" : "not ");
- msg_cdbg("Chip status register: Bit 3 / Block Protect 1 (BP1) is "
- "%sset\n", (status & (1 << 3)) ? "" : "not ");
- msg_cdbg("Chip status register: Bit 2 / Block Protect 0 (BP0) is "
- "%sset\n", (status & (1 << 2)) ? "" : "not ");
+ spi_prettyprint_status_register_atmel_at25_wpen(status);
+ spi_prettyprint_status_register_bp(status, 4);
/* FIXME: Pretty-print detailed sector protection status. */
spi_prettyprint_status_register_welwip(status);
return 0;
Modified: trunk/chipdrivers.h
==============================================================================
--- trunk/chipdrivers.h Fri Aug 3 00:06:14 2012 (r1559)
+++ trunk/chipdrivers.h Fri Aug 3 01:51:28 2012 (r1560)
@@ -48,7 +48,7 @@
uint8_t spi_read_status_register(struct flashctx *flash);
int spi_write_status_register(struct flashctx *flash, int status);
void spi_prettyprint_status_register_bit(uint8_t status, int bit);
-void spi_prettyprint_status_register_bp3210(uint8_t status, int bp);
+void spi_prettyprint_status_register_bp(uint8_t status, int bp);
void spi_prettyprint_status_register_welwip(uint8_t status);
int spi_prettyprint_status_register(struct flashctx *flash);
int spi_disable_blockprotect(struct flashctx *flash);
Modified: trunk/spi25.c
==============================================================================
--- trunk/spi25.c Fri Aug 3 00:06:14 2012 (r1559)
+++ trunk/spi25.c Fri Aug 3 01:51:28 2012 (r1560)
@@ -327,21 +327,24 @@
}
/* Prettyprint the status register. Common definitions. */
-void spi_prettyprint_status_register_bp3210(uint8_t status, int bp)
+void spi_prettyprint_status_register_bp(uint8_t status, int bp)
{
switch (bp) {
/* Fall through. */
+ case 4:
+ msg_cdbg("Chip status register: Block Protect 4 (BP4) "
+ "is %sset\n", (status & (1 << 5)) ? "" : "not ");
case 3:
- msg_cdbg("Chip status register: Bit 5 / Block Protect 3 (BP3) "
+ msg_cdbg("Chip status register: Block Protect 3 (BP3) "
"is %sset\n", (status & (1 << 5)) ? "" : "not ");
case 2:
- msg_cdbg("Chip status register: Bit 4 / Block Protect 2 (BP2) "
+ msg_cdbg("Chip status register: Block Protect 2 (BP2) "
"is %sset\n", (status & (1 << 4)) ? "" : "not ");
case 1:
- msg_cdbg("Chip status register: Bit 3 / Block Protect 1 (BP1) "
+ msg_cdbg("Chip status register: Block Protect 1 (BP1) "
"is %sset\n", (status & (1 << 3)) ? "" : "not ");
case 0:
- msg_cdbg("Chip status register: Bit 2 / Block Protect 0 (BP0) "
+ msg_cdbg("Chip status register: Block Protect 0 (BP0) "
"is %sset\n", (status & (1 << 2)) ? "" : "not ");
}
}
@@ -355,7 +358,7 @@
static void spi_prettyprint_status_register_common(uint8_t status)
{
- spi_prettyprint_status_register_bp3210(status, 3);
+ spi_prettyprint_status_register_bp(status, 3);
spi_prettyprint_status_register_welwip(status);
}
More information about the flashrom
mailing list