aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorSean Anderson <sean.anderson@seco.com>2022-03-22 16:59:15 -0400
committerTom Rini <trini@konsulko.com>2022-04-01 15:03:13 -0400
commiteff77c3a24ff6623f3767816ca54b8124f0e69a7 (patch)
tree40464d4b5457de29ef9de2d9e32185a34b9a9cfe /arch
parentb10f724807312a996100c7c4b779d320ed40d573 (diff)
downloadu-boot-eff77c3a24ff6623f3767816ca54b8124f0e69a7.zip
u-boot-eff77c3a24ff6623f3767816ca54b8124f0e69a7.tar.gz
u-boot-eff77c3a24ff6623f3767816ca54b8124f0e69a7.tar.bz2
arm: smh: Use numeric modes for smh_open
There's no point in using string constants for smh_open if we are just going to have to parse them. Instead, use numeric modes. The user needs to be a bit careful with these, since they are much closer semantically to string modes used by fopen(3) than the numeric modes used with open(2). Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/lib/semihosting.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/arch/arm/lib/semihosting.c b/arch/arm/lib/semihosting.c
index c38892f..b983cc3 100644
--- a/arch/arm/lib/semihosting.c
+++ b/arch/arm/lib/semihosting.c
@@ -22,9 +22,6 @@
#define SYSREAD 0x06
#define SYSFLEN 0x0C
-#define MODE_READ 0x0
-#define MODE_READBIN 0x1
-
/*
* Call the handler
*/
@@ -46,28 +43,16 @@ static noinline long smh_trap(unsigned int sysnum, void *addr)
* Open a file on the host. Mode is "r" or "rb" currently. Returns a file
* descriptor or -1 on error.
*/
-long smh_open(const char *fname, char *modestr)
+long smh_open(const char *fname, enum smh_open_mode mode)
{
long fd;
- unsigned long mode;
struct smh_open_s {
const char *fname;
unsigned long mode;
size_t len;
} open;
- debug("%s: file \'%s\', mode \'%s\'\n", __func__, fname, modestr);
-
- /* Check the file mode */
- if (!(strcmp(modestr, "r"))) {
- mode = MODE_READ;
- } else if (!(strcmp(modestr, "rb"))) {
- mode = MODE_READBIN;
- } else {
- printf("%s: ERROR mode \'%s\' not supported\n", __func__,
- modestr);
- return -1;
- }
+ debug("%s: file \'%s\', mode \'%u\'\n", __func__, fname, mode);
open.fname = fname;
open.len = strlen(fname);
@@ -155,7 +140,7 @@ static int smh_load_file(const char * const name, ulong load_addr,
long len;
long ret;
- fd = smh_open(name, "rb");
+ fd = smh_open(name, MODE_READ | MODE_BINARY);
if (fd == -1)
return -1;