summaryrefslogtreecommitdiffstats
path: root/at25.c
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2012-08-02 23:51:28 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2012-08-02 23:51:28 +0000
commit1ba08f6d417921d9cb37b8b8823f4cb9d68f5895 (patch)
tree1dba91fd092949624eaaa4e73dd43719c06dc3f0 /at25.c
parentcb30158fbf1a63d65de53080d0cdbcb23efd95d6 (diff)
downloadast2050-flashrom-1ba08f6d417921d9cb37b8b8823f4cb9d68f5895.zip
ast2050-flashrom-1ba08f6d417921d9cb37b8b8823f4cb9d68f5895.tar.gz
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 Corresponding to flashrom svn r1560. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Diffstat (limited to 'at25.c')
-rw-r--r--at25.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/at25.c b/at25.c
index ec9b4b6..8891e2b 100644
--- a/at25.c
+++ b/at25.c
@@ -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 @@ int spi_prettyprint_status_register_at25f(struct flashctx *flash)
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 @@ int spi_prettyprint_status_register_at25fs010(struct flashctx *flash)
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 @@ int spi_prettyprint_status_register_at25fs040(struct flashctx *flash)
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;
OpenPOWER on IntegriCloud