aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2016-01-04 13:23:07 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2016-01-15 15:04:57 +1100
commit6b53f9241cf4d044d0f0f756f4a8c9f4c55f0140 (patch)
treedb7699c82d90abd49867f462c3dd306449b46298 /external
parentb25529d182b53be0b760638c812c422b794546e4 (diff)
downloadskiboot-6b53f9241cf4d044d0f0f756f4a8c9f4c55f0140.zip
skiboot-6b53f9241cf4d044d0f0f756f4a8c9f4c55f0140.tar.gz
skiboot-6b53f9241cf4d044d0f0f756f4a8c9f4c55f0140.tar.bz2
libflash/blocklevel: Add keep_alive parameter
Currently the file backend will keep a file descriptor open until the structure is destroyed. This is undesirable for daemons and long running processes that only have a very occasional need to access the file. Keeping the file open requires users of blocklevel to close and reinit their structures every time, doing is isn't disastrous but can easily be managed at the interface level. This has been done at the blocklevel_device interface so as to provide minimal changes to arch_flash_init(). At the moment there isn't a need for the actually flash driver to be able to do this, this remains unimplmented there. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r--external/common/arch_flash.h3
-rw-r--r--external/common/arch_flash_arm.c4
-rw-r--r--external/common/arch_flash_powerpc.c8
-rw-r--r--external/common/arch_flash_x86.c4
-rw-r--r--external/gard/gard.c2
-rw-r--r--external/pflash/pflash.c2
6 files changed, 12 insertions, 11 deletions
diff --git a/external/common/arch_flash.h b/external/common/arch_flash.h
index 60c4de8..918ffa9 100644
--- a/external/common/arch_flash.h
+++ b/external/common/arch_flash.h
@@ -20,7 +20,8 @@
#include <getopt.h>
#include <libflash/blocklevel.h>
-int arch_flash_init(struct blocklevel_device **bl, const char *file);
+int arch_flash_init(struct blocklevel_device **bl, const char *file,
+ bool keep_alive);
void arch_flash_close(struct blocklevel_device *bl, const char *file);
diff --git a/external/common/arch_flash_arm.c b/external/common/arch_flash_arm.c
index 13d2946..f65bddc 100644
--- a/external/common/arch_flash_arm.c
+++ b/external/common/arch_flash_arm.c
@@ -263,7 +263,7 @@ int arch_flash_set_wrprotect(struct blocklevel_device *bl, int set)
return set_wrprotect(set);
}
-int arch_flash_init(struct blocklevel_device **r_bl, const char *file)
+int arch_flash_init(struct blocklevel_device **r_bl, const char *file, bool keep_alive)
{
struct blocklevel_device *new_bl;
@@ -272,7 +272,7 @@ int arch_flash_init(struct blocklevel_device **r_bl, const char *file)
return -1;
if (file) {
- file_init_path(file, NULL, &new_bl);
+ file_init_path(file, NULL, keep_alive, &new_bl);
} else {
new_bl = flash_setup(arch_data.bmc);
}
diff --git a/external/common/arch_flash_powerpc.c b/external/common/arch_flash_powerpc.c
index 93eacee..19dfec8 100644
--- a/external/common/arch_flash_powerpc.c
+++ b/external/common/arch_flash_powerpc.c
@@ -188,7 +188,7 @@ static int get_dev_mtd(const char *fdt_flash_path, char **mtd_path)
return done ? rc : -1;
}
-static struct blocklevel_device *arch_init_blocklevel(const char *file)
+static struct blocklevel_device *arch_init_blocklevel(const char *file, bool keep_alive)
{
int rc;
struct blocklevel_device *new_bl = NULL;
@@ -200,7 +200,7 @@ static struct blocklevel_device *arch_init_blocklevel(const char *file)
return NULL;
}
- file_init_path(file ? file : real_file, NULL, &new_bl);
+ file_init_path(file ? file : real_file, NULL, keep_alive, &new_bl);
free(real_file);
return new_bl;
}
@@ -211,11 +211,11 @@ int arch_flash_set_wrprotect(struct blocklevel_device *bl, int set)
return 0;
}
-int arch_flash_init(struct blocklevel_device **r_bl, const char *file)
+int arch_flash_init(struct blocklevel_device **r_bl, const char *file, bool keep_alive)
{
struct blocklevel_device *new_bl;
- new_bl = arch_init_blocklevel(file);
+ new_bl = arch_init_blocklevel(file, keep_alive);
if (!new_bl)
return -1;
diff --git a/external/common/arch_flash_x86.c b/external/common/arch_flash_x86.c
index 29c0229..3be05df 100644
--- a/external/common/arch_flash_x86.c
+++ b/external/common/arch_flash_x86.c
@@ -28,7 +28,7 @@
#include "arch_flash.h"
-int arch_flash_init(struct blocklevel_device **r_bl, const char *file)
+int arch_flash_init(struct blocklevel_device **r_bl, const char *file, bool keep_alive)
{
struct blocklevel_device *new_bl;
@@ -38,7 +38,7 @@ int arch_flash_init(struct blocklevel_device **r_bl, const char *file)
return -1;
}
- file_init_path(file, NULL, &new_bl);
+ file_init_path(file, NULL, keep_alive, &new_bl);
if (!new_bl)
return -1;
diff --git a/external/gard/gard.c b/external/gard/gard.c
index 53f31d9..2163707 100644
--- a/external/gard/gard.c
+++ b/external/gard/gard.c
@@ -637,7 +637,7 @@ int main(int argc, char **argv)
argv += optind;
action = argv[0];
- if (arch_flash_init(&(ctx->bl), filename)) {
+ if (arch_flash_init(&(ctx->bl), filename, true)) {
/* Can fail for a few ways, most likely couldn't open MTD device */
fprintf(stderr, "Can't open %s\n", filename ? filename : "MTD Device. Are you root?");
rc = EXIT_FAILURE;
diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index 8231708..c1d4949 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -722,7 +722,7 @@ int main(int argc, char *argv[])
}
}
- if (arch_flash_init(&bl, NULL))
+ if (arch_flash_init(&bl, NULL, true))
exit(1);
on_exit(exiting, NULL);