diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2010-01-09 03:15:50 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2010-01-09 03:15:50 +0000 |
commit | f9e9a695145d428c0bb73037125e46d4a73735a1 (patch) | |
tree | b1fd1a430202e2818df3bd4ff6168ded03d625c5 /jedec.c | |
parent | c1419d755b507781b889dd96b461443fe6a44276 (diff) | |
download | flashrom-f9e9a695145d428c0bb73037125e46d4a73735a1.zip flashrom-f9e9a695145d428c0bb73037125e46d4a73735a1.tar.gz |
Use address mask in probe_jedec
This allows us to have one common probe_jedec function instead of half a
dozen wrappers. The trick here is to have FEATURE_ADDR_FULL==0 and thus default
to unmasked addresses. That way, we only have to annotate chips which need
small address masks.
Corresponding to flashrom svn r840.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
Diffstat (limited to 'jedec.c')
-rw-r--r-- | jedec.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -373,6 +373,19 @@ retry: return failed; } +int getaddrmask(struct flashchip *flash) +{ + switch (flash->feature_bits & FEATURE_ADDR_MASK) { + case FEATURE_ADDR_FULL: + return MASK_FULL; + break; + default: + fprintf(stderr, "%s called with unknown mask\n", __func__); + return 0; + break; + } +} + int write_jedec(struct flashchip *flash, uint8_t *buf) { int i, failed = 0; @@ -438,7 +451,10 @@ int erase_chip_block_jedec(struct flashchip *flash, unsigned int addr, int probe_jedec(struct flashchip *flash) { - return probe_jedec_common(flash, MASK_FULL, 1); + int mask; + + mask = getaddrmask(flash); + return probe_jedec_common(flash, mask, 1); } int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int size) |