diff options
author | Cristian Ciocaltea <cristian.ciocaltea@gmail.com> | 2019-01-12 02:03:15 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-11-07 17:58:31 -0500 |
commit | 036218a67130343a71ea34aeae1231bc11f040c2 (patch) | |
tree | 600e9b8b408872167ee05626fa7046b4df4a4371 /api/api_storage.c | |
parent | 0be2ecd4861faa410491170e205488f9ee82a227 (diff) | |
download | u-boot-036218a67130343a71ea34aeae1231bc11f040c2.tar.gz |
api: storage: Add the missing write operation support
API_dev_write(va_list ap) is currently lacking the write support
to storage devices because, historically, those devices did not
implement block_write()
The solution has been tested by loading and booting a (patched)
GRUB instance in a QEMU vexpress-a9 environment. The disk write
operations were triggered with GRUB's save_env command.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
Diffstat (limited to 'api/api_storage.c')
-rw-r--r-- | api/api_storage.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/api/api_storage.c b/api/api_storage.c index 2b90c18aae..7ae03ac230 100644 --- a/api/api_storage.c +++ b/api/api_storage.c @@ -349,3 +349,27 @@ lbasize_t dev_read_stor(void *cookie, void *buf, lbasize_t len, lbastart_t start return dd->block_read(dd, start, len, buf); #endif /* defined(CONFIG_BLK) */ } + + +lbasize_t dev_write_stor(void *cookie, void *buf, lbasize_t len, lbastart_t start) +{ + struct blk_desc *dd = (struct blk_desc *)cookie; + int type = dev_stor_type(dd); + + if (type == ENUM_MAX) + return 0; + + if (!dev_stor_is_valid(type, dd)) + return 0; + +#ifdef CONFIG_BLK + return blk_dwrite(dd, start, len, buf); +#else + if (dd->block_write == NULL) { + debugf("no block_write() for device 0x%08x\n", cookie); + return 0; + } + + return dd->block_write(dd, start, len, buf); +#endif /* defined(CONFIG_BLK) */ +} |