diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2019-01-28 22:55:37 -0800 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-01-29 09:27:03 +0100 |
commit | c44997e621cfe190fe44523e6cbcb03fea21eb8c (patch) | |
tree | bfd907f6c2fcd6ee6073f1d48864df6644aa559a /fs/smhfs.c | |
parent | 6811cc0dbc04c71cdc1ff12efe0edc8660200563 (diff) | |
download | barebox-c44997e621cfe190fe44523e6cbcb03fea21eb8c.tar.gz barebox-c44997e621cfe190fe44523e6cbcb03fea21eb8c.tar.xz |
fs: Update FILE position in lseek()
Instead on relying on driver callbacks to update 'pos' in FILE, do it
as a part of lseek() code. This allows us to drop a bit of repeating
code as well as making lseek() implementation consistent with write()
and read().
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs/smhfs.c')
-rw-r--r-- | fs/smhfs.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/smhfs.c b/fs/smhfs.c index f1b6d6bb1b..18eaa9dfcf 100644 --- a/fs/smhfs.c +++ b/fs/smhfs.c @@ -112,12 +112,10 @@ static int smhfs_read(struct device_d __always_unused *dev, static loff_t smhfs_lseek(struct device_d __always_unused *dev, FILE *f, loff_t pos) { - if (semihosting_seek(file_to_fd(f), pos)) { + if (semihosting_seek(file_to_fd(f), pos)) return -semihosting_errno(); - } else { - f->pos = pos; - return f->pos; - } + + return pos; } static DIR* smhfs_opendir(struct device_d __always_unused *dev, |