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

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