diff options
author | Cyril Bur <cyril.bur@au1.ibm.com> | 2016-10-24 15:36:48 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-10-25 19:52:29 +1100 |
commit | 39fea04c47ab614ddd2c943f5308cc9d873e67a0 (patch) | |
tree | 80340d430b42c2f2c47fd86a74fa5614cd73fa37 /external | |
parent | 9c3b35a15f3a2762288e1e460843c9c1246e1acd (diff) | |
download | skiboot-39fea04c47ab614ddd2c943f5308cc9d873e67a0.zip skiboot-39fea04c47ab614ddd2c943f5308cc9d873e67a0.tar.gz skiboot-39fea04c47ab614ddd2c943f5308cc9d873e67a0.tar.bz2 |
external/common: Rename arch_flash_bmc() to arch_flash_access()
Honestly the first name was terrible. Initially this was intended only
to serve for BMC/ARM flash access, however, it should be more generic as
it is in the external/common arch code it should play nice on all
architectures.
This change also paves the way to change the default flash access
methods in pflash.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Acked-by: Joel Stanley <joel@jms.id.au>
[stewart@linux.vnet.ibm.com: preserve Joel's ack]
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r-- | external/common/arch_flash.h | 6 | ||||
-rw-r--r-- | external/common/arch_flash_arm.c | 12 | ||||
-rw-r--r-- | external/common/arch_flash_common.c | 6 | ||||
-rw-r--r-- | external/common/arch_flash_powerpc.c | 16 | ||||
-rw-r--r-- | external/pflash/pflash.c | 4 |
5 files changed, 31 insertions, 13 deletions
diff --git a/external/common/arch_flash.h b/external/common/arch_flash.h index aae9e10..c1be706 100644 --- a/external/common/arch_flash.h +++ b/external/common/arch_flash.h @@ -20,7 +20,7 @@ #include <getopt.h> #include <libflash/blocklevel.h> -enum bmc_access { +enum flash_access { PNOR_DIRECT, PNOR_MTD, BMC_DIRECT, @@ -40,8 +40,8 @@ void arch_flash_close(struct blocklevel_device *bl, const char *file); * accessed. * If called AFTER init, then this returns how the flash is being accessed. */ -enum bmc_access arch_flash_bmc(struct blocklevel_device *bl, - enum bmc_access access); +enum flash_access arch_flash_access(struct blocklevel_device *bl, + enum flash_access access); int arch_flash_erase_chip(struct blocklevel_device *bl); int arch_flash_4b_mode(struct blocklevel_device *bl, int set_4b); diff --git a/external/common/arch_flash_arm.c b/external/common/arch_flash_arm.c index 0776436..697609d 100644 --- a/external/common/arch_flash_arm.c +++ b/external/common/arch_flash_arm.c @@ -43,7 +43,7 @@ static struct arch_arm_data { size_t ahb_flash_base; size_t ahb_flash_size; void *ahb_flash_map; - enum bmc_access access; + enum flash_access access; struct flash_chip *flash_chip; struct blocklevel_device *init_bl; } arch_data; @@ -156,7 +156,7 @@ static void close_devs(void) */ } -static int open_devs(enum bmc_access access) +static int open_devs(enum flash_access access) { if (access != BMC_DIRECT && access != PNOR_DIRECT) return -1; @@ -190,7 +190,7 @@ static int open_devs(enum bmc_access access) return 0; } -static struct blocklevel_device *flash_setup(enum bmc_access access) +static struct blocklevel_device *flash_setup(enum flash_access access) { int rc; struct blocklevel_device *bl; @@ -237,7 +237,7 @@ static bool is_pnor_part(const char *str) { return strcasestr(str, "pnor"); } -static char *get_dev_mtd(enum bmc_access access) +static char *get_dev_mtd(enum flash_access access) { FILE *f; char *ret = NULL, *pos = NULL; @@ -276,8 +276,8 @@ static char *get_dev_mtd(enum bmc_access access) return ret; } -enum bmc_access arch_flash_bmc(struct blocklevel_device *bl, - enum bmc_access access) +enum flash_access arch_flash_access(struct blocklevel_device *bl, + enum flash_access access) { if (access == ACCESS_INVAL) return ACCESS_INVAL; diff --git a/external/common/arch_flash_common.c b/external/common/arch_flash_common.c index ef4669a..ba06fb2 100644 --- a/external/common/arch_flash_common.c +++ b/external/common/arch_flash_common.c @@ -16,6 +16,8 @@ #include <libflash/blocklevel.h> +#include "arch_flash.h" + /* Default implmentations */ int __attribute__((weak)) arch_flash_erase_chip(struct blocklevel_device *bl) { @@ -27,9 +29,9 @@ int __attribute__((weak)) arch_flash_4b_mode(struct blocklevel_device *bl, int s return -1; } -int __attribute__((weak)) arch_flash_bmc(struct blocklevel_device *bl, int bmc) +enum flash_access __attribute__((weak)) arch_flash_access(struct blocklevel_device *bl, enum flash_access access) { - return -1; + return ACCESS_INVAL; } int __attribute__((weak)) arch_flash_set_wrprotect(struct blocklevel_device *bl, int set) diff --git a/external/common/arch_flash_powerpc.c b/external/common/arch_flash_powerpc.c index 7ce962e..6f32a00 100644 --- a/external/common/arch_flash_powerpc.c +++ b/external/common/arch_flash_powerpc.c @@ -213,10 +213,26 @@ int arch_flash_set_wrprotect(struct blocklevel_device *bl, int set) return 0; } +enum flash_access arch_flash_access(struct blocklevel_device *bl, + enum flash_access access) +{ + if (access != PNOR_MTD) + return ACCESS_INVAL; + + return PNOR_MTD; +} + int arch_flash_init(struct blocklevel_device **r_bl, const char *file, bool keep_alive) { struct blocklevel_device *new_bl; + /* + * In theory here we should check that something crazy wasn't + * passed to arch_flash_access() and refuse to init. + * However, arch_flash_access won't accept anything except + * PNOR_MTD, if they want something different then they should + * have checked with arch_flash_access() + */ new_bl = arch_init_blocklevel(file, keep_alive); if (!new_bl) return -1; diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c index bece12a..002d0dc 100644 --- a/external/pflash/pflash.c +++ b/external/pflash/pflash.c @@ -762,14 +762,14 @@ int main(int argc, char *argv[]) * This helps give a more meaningful error messages. */ - if (arch_flash_bmc(NULL, BMC_DIRECT) == ACCESS_INVAL) { + if (arch_flash_access(NULL, BMC_DIRECT) == ACCESS_INVAL) { fprintf(stderr, "Can't access BMC flash on this architecture\n"); exit(1); } } if (mtd) { - if (arch_flash_bmc(NULL, bmc_flash ? BMC_MTD : PNOR_MTD) == ACCESS_INVAL) { + if (arch_flash_access(NULL, bmc_flash ? BMC_MTD : PNOR_MTD) == ACCESS_INVAL) { fprintf(stderr, "Can't access %s flash through MTD on this architecture\n", bmc_flash ? "BMC" : "PNOR"); exit(1); |