[PATCH 1/3] Correct fw_cfg_add_callback()

Laurent Vivier
2008-12-16T15:20:36Z

This patch is needed to be able to register firmware configuration
device callback.
It is already included in qemu as commit r5978.

Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
---
qemu/hw/fw_cfg.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/qemu/hw/fw_cfg.c b/qemu/hw/fw_cfg.c
index 4e68670..c3b09c6 100644
--- a/qemu/hw/fw_cfg.c
+++ b/qemu/hw/fw_cfg.c
@@ -57,7 +57,6 @@ static void fw_cfg_write(FWCfgState *s, uint8_t value)
FWCfgEntry *e = &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];

FW_CFG_DPRINTF("write %d\n", value);
-
if (s->cur_entry & FW_CFG_WRITE_CHANNEL && s->cur_offset < e->len) {
e->data[s->cur_offset++] = value;
if (s->cur_offset == e->len) {
@@ -240,10 +239,12 @@ int fw_cfg_add_callback(void *opaque, uint16_t key, FWCfgCallback callback,
FWCfgState *s = opaque;
int arch = !!(key & FW_CFG_ARCH_LOCAL);

+ if (!(key & FW_CFG_WRITE_CHANNEL))
+ return 0;
+
key &= FW_CFG_ENTRY_MASK;

- if (key >= FW_CFG_MAX_ENTRY || !(key & FW_CFG_WRITE_CHANNEL)
- || len > 65535)
+ if (key >= FW_CFG_MAX_ENTRY || len > 65535)
return 0;

s->entries[arch][key].data = data;
--
1.5.6.5