Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Unified Diff: lib/chromeos/load_firmware_fw.c

Issue 6650024: Factor out read_firmware_device() (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/u-boot-next.git@chromeos-v2010.09
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/chromeos/firmware_storage.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/chromeos/load_firmware_fw.c
diff --git a/lib/chromeos/load_firmware_fw.c b/lib/chromeos/load_firmware_fw.c
index b5d271bd7aa71f0b829c73543c2000011ea93a6e..18d2e34141fa022d427dbea4c05bc0c0aeafd85e 100644
--- a/lib/chromeos/load_firmware_fw.c
+++ b/lib/chromeos/load_firmware_fw.c
@@ -37,6 +37,36 @@ void GetFirmwareBody_dispose(firmware_storage_t *f)
free(f->firmware_body[i]);
}
+int read_firmware_device(firmware_storage_t *file, off_t offset, void *buf,
+ size_t count)
+{
+ ssize_t size;
+
+ if (file->seek(file->context, offset, SEEK_SET) < 0) {
+ debug(PREFIX "seek to address 0x%08x fail\n", offset);
+ return -1;
+ }
+
+ size = 0;
+ while (count > 0 &&
+ (size = file->read(file->context, buf, count)) > 0) {
+ count -= size;
+ buf += size;
+ }
+
+ if (size < 0) {
+ debug(PREFIX "an error occur when read firmware: %d\n", size);
+ return -1;
+ }
+
+ if (count > 0) {
+ debug(PREFIX "cannot read all data: %d\n", count);
+ return -1;
+ }
+
+ return 0;
+}
+
/*
* See vboot_reference/firmware/include/load_firmware_fw.h for documentation of
* this function.
« no previous file with comments | « include/chromeos/firmware_storage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698