Blame SOURCES/kvm-fw_cfg-rename-read-callback.patch

4a2fec
From 571cf340ae415185ab21a1af146cb3df7b489286 Mon Sep 17 00:00:00 2001
4a2fec
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
4a2fec
Date: Mon, 27 Nov 2017 22:51:03 +0100
4a2fec
Subject: [PATCH 05/21] fw_cfg: rename read callback
4a2fec
MIME-Version: 1.0
4a2fec
Content-Type: text/plain; charset=UTF-8
4a2fec
Content-Transfer-Encoding: 8bit
4a2fec
4a2fec
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
4a2fec
Message-id: <20171127225111.24518-2-marcandre.lureau@redhat.com>
4a2fec
Patchwork-id: 77921
4a2fec
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 1/9] fw_cfg: rename read callback
4a2fec
Bugzilla: 1398633
4a2fec
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
4a2fec
RH-Acked-by: Andrew Jones <drjones@redhat.com>
4a2fec
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
4a2fec
The callback is called on select.
4a2fec
4a2fec
Furthermore, the next patch introduced a new callback, so rename the
4a2fec
function type with a generic name.
4a2fec
4a2fec
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
4a2fec
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
4a2fec
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
4a2fec
4a2fec
(cherry picked from commit 6f6f4aec749ba9a4fb58c7c20536a61b0381ff35)
4a2fec
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 hw/core/loader.c          |  2 +-
4a2fec
 hw/nvram/fw_cfg.c         | 30 ++++++++++++++++--------------
4a2fec
 include/hw/loader.h       |  2 +-
4a2fec
 include/hw/nvram/fw_cfg.h |  7 ++++---
4a2fec
 4 files changed, 22 insertions(+), 19 deletions(-)
4a2fec
4a2fec
diff --git a/hw/core/loader.c b/hw/core/loader.c
4a2fec
index ebe574c..4593061 100644
4a2fec
--- a/hw/core/loader.c
4a2fec
+++ b/hw/core/loader.c
4a2fec
@@ -989,7 +989,7 @@ err:
4a2fec
 
4a2fec
 MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len,
4a2fec
                    size_t max_len, hwaddr addr, const char *fw_file_name,
4a2fec
-                   FWCfgReadCallback fw_callback, void *callback_opaque,
4a2fec
+                   FWCfgCallback fw_callback, void *callback_opaque,
4a2fec
                    AddressSpace *as, bool read_only)
4a2fec
 {
4a2fec
     MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
4a2fec
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
4a2fec
index 5bd9044..e3bd626 100644
4a2fec
--- a/hw/nvram/fw_cfg.c
4a2fec
+++ b/hw/nvram/fw_cfg.c
4a2fec
@@ -55,7 +55,7 @@ struct FWCfgEntry {
4a2fec
     bool allow_write;
4a2fec
     uint8_t *data;
4a2fec
     void *callback_opaque;
4a2fec
-    FWCfgReadCallback read_callback;
4a2fec
+    FWCfgCallback select_cb;
4a2fec
 };
4a2fec
 
4a2fec
 #define JPG_FILE 0
4a2fec
@@ -236,8 +236,8 @@ static int fw_cfg_select(FWCfgState *s, uint16_t key)
4a2fec
         /* entry successfully selected, now run callback if present */
4a2fec
         arch = !!(key & FW_CFG_ARCH_LOCAL);
4a2fec
         e = &s->entries[arch][key & FW_CFG_ENTRY_MASK];
4a2fec
-        if (e->read_callback) {
4a2fec
-            e->read_callback(e->callback_opaque);
4a2fec
+        if (e->select_cb) {
4a2fec
+            e->select_cb(e->callback_opaque);
4a2fec
         }
4a2fec
     }
4a2fec
 
4a2fec
@@ -568,11 +568,11 @@ static const VMStateDescription vmstate_fw_cfg = {
4a2fec
     }
4a2fec
 };
4a2fec
 
4a2fec
-static void fw_cfg_add_bytes_read_callback(FWCfgState *s, uint16_t key,
4a2fec
-                                           FWCfgReadCallback callback,
4a2fec
-                                           void *callback_opaque,
4a2fec
-                                           void *data, size_t len,
4a2fec
-                                           bool read_only)
4a2fec
+static void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
4a2fec
+                                      FWCfgCallback select_cb,
4a2fec
+                                      void *callback_opaque,
4a2fec
+                                      void *data, size_t len,
4a2fec
+                                      bool read_only)
4a2fec
 {
4a2fec
     int arch = !!(key & FW_CFG_ARCH_LOCAL);
4a2fec
 
4a2fec
@@ -583,7 +583,7 @@ static void fw_cfg_add_bytes_read_callback(FWCfgState *s, uint16_t key,
4a2fec
 
4a2fec
     s->entries[arch][key].data = data;
4a2fec
     s->entries[arch][key].len = (uint32_t)len;
4a2fec
-    s->entries[arch][key].read_callback = callback;
4a2fec
+    s->entries[arch][key].select_cb = select_cb;
4a2fec
     s->entries[arch][key].callback_opaque = callback_opaque;
4a2fec
     s->entries[arch][key].allow_write = !read_only;
4a2fec
 }
4a2fec
@@ -610,7 +610,7 @@ static void *fw_cfg_modify_bytes_read(FWCfgState *s, uint16_t key,
4a2fec
 
4a2fec
 void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len)
4a2fec
 {
4a2fec
-    fw_cfg_add_bytes_read_callback(s, key, NULL, NULL, data, len, true);
4a2fec
+    fw_cfg_add_bytes_callback(s, key, NULL, NULL, data, len, true);
4a2fec
 }
4a2fec
 
4a2fec
 void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value)
4a2fec
@@ -736,7 +736,8 @@ static int get_fw_cfg_order(FWCfgState *s, const char *name)
4a2fec
 }
4a2fec
 
4a2fec
 void fw_cfg_add_file_callback(FWCfgState *s,  const char *filename,
4a2fec
-                              FWCfgReadCallback callback, void *callback_opaque,
4a2fec
+                              FWCfgCallback select_cb,
4a2fec
+                              void *callback_opaque,
4a2fec
                               void *data, size_t len, bool read_only)
4a2fec
 {
4a2fec
     int i, index, count;
4a2fec
@@ -798,9 +799,10 @@ void fw_cfg_add_file_callback(FWCfgState *s,  const char *filename,
4a2fec
         }
4a2fec
     }
4a2fec
 
4a2fec
-    fw_cfg_add_bytes_read_callback(s, FW_CFG_FILE_FIRST + index,
4a2fec
-                                   callback, callback_opaque, data, len,
4a2fec
-                                   read_only);
4a2fec
+    fw_cfg_add_bytes_callback(s, FW_CFG_FILE_FIRST + index,
4a2fec
+                              select_cb,
4a2fec
+                              callback_opaque, data, len,
4a2fec
+                              read_only);
4a2fec
 
4a2fec
     s->files->f[index].size   = cpu_to_be32(len);
4a2fec
     s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);
4a2fec
diff --git a/include/hw/loader.h b/include/hw/loader.h
4a2fec
index 490c9ff..355fe0f 100644
4a2fec
--- a/include/hw/loader.h
4a2fec
+++ b/include/hw/loader.h
4a2fec
@@ -192,7 +192,7 @@ int rom_add_file(const char *file, const char *fw_dir,
4a2fec
 MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len,
4a2fec
                            size_t max_len, hwaddr addr,
4a2fec
                            const char *fw_file_name,
4a2fec
-                           FWCfgReadCallback fw_callback,
4a2fec
+                           FWCfgCallback fw_callback,
4a2fec
                            void *callback_opaque, AddressSpace *as,
4a2fec
                            bool read_only);
4a2fec
 int rom_add_elf_program(const char *name, void *data, size_t datasize,
4a2fec
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
4a2fec
index b77ea48..f50d068 100644
4a2fec
--- a/include/hw/nvram/fw_cfg.h
4a2fec
+++ b/include/hw/nvram/fw_cfg.h
4a2fec
@@ -44,7 +44,7 @@ typedef struct FWCfgDmaAccess {
4a2fec
     uint64_t address;
4a2fec
 } QEMU_PACKED FWCfgDmaAccess;
4a2fec
 
4a2fec
-typedef void (*FWCfgReadCallback)(void *opaque);
4a2fec
+typedef void (*FWCfgCallback)(void *opaque);
4a2fec
 
4a2fec
 struct FWCfgState {
4a2fec
     /*< private >*/
4a2fec
@@ -182,7 +182,7 @@ void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data,
4a2fec
  * fw_cfg_add_file_callback:
4a2fec
  * @s: fw_cfg device being modified
4a2fec
  * @filename: name of new fw_cfg file item
4a2fec
- * @callback: callback function
4a2fec
+ * @select_cb: callback function when selecting
4a2fec
  * @callback_opaque: argument to be passed into callback function
4a2fec
  * @data: pointer to start of item data
4a2fec
  * @len: size of item data
4a2fec
@@ -201,7 +201,8 @@ void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data,
4a2fec
  * with FW_CFG_DMA_CTL_SELECT).
4a2fec
  */
4a2fec
 void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
4a2fec
-                              FWCfgReadCallback callback, void *callback_opaque,
4a2fec
+                              FWCfgCallback select_cb,
4a2fec
+                              void *callback_opaque,
4a2fec
                               void *data, size_t len, bool read_only);
4a2fec
 
4a2fec
 /**
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec