| 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.
|
|
|