for (i = 0; true; i += sizeof(data)) {
ret = misc_read(dev, i, &data, sizeof(data));
- if (ret < 0)
+ if (ret <= 0)
return 0;
print_buffer(i, data, 1, sizeof(data), sizeof(data));
offset += data->offset;
- if (data->block_size <= 1)
- return data->read(dev, offset, buf, size);
+ if (data->block_size <= 1) {
+ ret = data->read(dev, offset, buf, size);
+ goto done;
+ }
block_start = offset / data->block_size;
block_offset = offset % data->block_size;
memcpy(buf, buffer + block_offset, size);
free(buffer);
- return ret;
+
+done:
+ return ret < 0 ? ret : size;
}
static const struct misc_ops rockchip_efuse_ops = {