Skip to contentSkip to conversation

fw_cfg: avoid unused function warning

PATCH In review Arnd Bergmann 2 participants 2 messages Feb 28, 2018 Qemu machine emulator and virtualizer support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fw_cfg: avoid unused function warning

The newly introduced fw_cfg_dma_transfer() function is unused when CONFIG_CRASH_CORE is disabled:

drivers/firmware/qemu_fw_cfg.c:89:16: error: 'fw_cfg_dma_transfer' defined but not used [-Werror=unused-function]
static ssize_t fw_cfg_dma_transfer(void *address, u32 length, u32 control)

This moves it into the #ifdef section that hides its caller to avoid the warning.

Fixes 47e78bfb5426 ("fw_cfg: write vmcoreinfo details")
---
 drivers/firmware/qemu_fw_cfg.c | 60 +++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 30 deletions(-)
drivers/firmware/qemu_fw_cfg.c +30 -30
index 3015e77aebca..f002bb40519b 100644
@@ -66,6 +66,36 @@ static void fw_cfg_sel_endianness(u16 key)
 		iowrite16(key, fw_cfg_reg_ctrl);
 }
 
+/* read chunk of given fw_cfg blob (caller responsible for sanity-check) */
+static ssize_t fw_cfg_read_blob(u16 key,
+				void *buf, loff_t pos, size_t count)
+{
+	u32 glk = -1U;
+	acpi_status status;
+
+	/* If we have ACPI, ensure mutual exclusion against any potential
+	 * device access by the firmware, e.g. via AML methods:
+	 */
+	status = acpi_acquire_global_lock(ACPI_WAIT_FOREVER, &glk);
+	if (ACPI_FAILURE(status) && status != AE_NOT_CONFIGURED) {
+		/* Should never get here */
+		WARN(1, "fw_cfg_read_blob: Failed to lock ACPI!\n");
+		memset(buf, 0, count);
+		return -EINVAL;
+	}
+
+	mutex_lock(&fw_cfg_dev_lock);
+	fw_cfg_sel_endianness(key);
+	while (pos-- > 0)
+		ioread8(fw_cfg_reg_data);
+	ioread8_rep(fw_cfg_reg_data, buf, count);
+	mutex_unlock(&fw_cfg_dev_lock);
+
+	acpi_release_global_lock(glk);
+	return count;
+}
+
+#ifdef CONFIG_CRASH_CORE
 static inline bool fw_cfg_dma_enabled(void)
 {
 	return (fw_cfg_rev & FW_CFG_VERSION_DMA) && fw_cfg_reg_dma;
@@ -124,36 +154,6 @@ static ssize_t fw_cfg_dma_transfer(void *address, u32 length, u32 control)
 	return ret;
 }
 
-/* read chunk of given fw_cfg blob (caller responsible for sanity-check) */
-static ssize_t fw_cfg_read_blob(u16 key,
-				void *buf, loff_t pos, size_t count)
-{
-	u32 glk = -1U;
-	acpi_status status;
-
-	/* If we have ACPI, ensure mutual exclusion against any potential
-	 * device access by the firmware, e.g. via AML methods:
-	 */
-	status = acpi_acquire_global_lock(ACPI_WAIT_FOREVER, &glk);
-	if (ACPI_FAILURE(status) && status != AE_NOT_CONFIGURED) {
-		/* Should never get here */
-		WARN(1, "fw_cfg_read_blob: Failed to lock ACPI!\n");
-		memset(buf, 0, count);
-		return -EINVAL;
-	}
-
-	mutex_lock(&fw_cfg_dev_lock);
-	fw_cfg_sel_endianness(key);
-	while (pos-- > 0)
-		ioread8(fw_cfg_reg_data);
-	ioread8_rep(fw_cfg_reg_data, buf, count);
-	mutex_unlock(&fw_cfg_dev_lock);
-
-	acpi_release_global_lock(glk);
-	return count;
-}
-
-#ifdef CONFIG_CRASH_CORE
 /* write chunk of given fw_cfg blob (caller responsible for sanity-check) */
 static ssize_t fw_cfg_write_blob(u16 key,
 				 void *buf, loff_t pos, size_t count)
Signature · 1 line
2.9.0
#1 lore raw

Hi

Quoted 11 lines · Arnd Bergmann

The newly introduced fw_cfg_dma_transfer() function is unused when CONFIG_CRASH_CORE is disabled:

drivers/firmware/qemu_fw_cfg.c:89:16: error: 'fw_cfg_dma_transfer' defined but not used [-Werror=unused-function]
static ssize_t fw_cfg_dma_transfer(void *address, u32 length, u32 control)

This moves it into the #ifdef section that hides its caller to avoid the warning.

Fixes 47e78bfb5426 ("fw_cfg: write vmcoreinfo details")

I don't know from which tree you found this, I suppose from mst/linux-next (which btw, I don't know which version got partially applied).

This is a regression in v13, because dma read is last patch now, as RFC. Fixed in upcoming v16.

thanks

Quoted 85 lines
---
 drivers/firmware/qemu_fw_cfg.c | 60 +++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 30 deletions(-)
drivers/firmware/qemu_fw_cfg.c +30 -31
index 3015e77aebca..f002bb40519b 100644
@@ -66,6 +66,36 @@ static void fw_cfg_sel_endianness(u16 key)
                iowrite16(key, fw_cfg_reg_ctrl);
 }
 
+/* read chunk of given fw_cfg blob (caller responsible for sanity-check) */
+static ssize_t fw_cfg_read_blob(u16 key,
+                               void *buf, loff_t pos, size_t count)
+{
+       u32 glk = -1U;
+       acpi_status status;
+
+       /* If we have ACPI, ensure mutual exclusion against any potential
+        * device access by the firmware, e.g. via AML methods:
+        */
+       status = acpi_acquire_global_lock(ACPI_WAIT_FOREVER, &glk);
+       if (ACPI_FAILURE(status) && status != AE_NOT_CONFIGURED) {
+               /* Should never get here */
+               WARN(1, "fw_cfg_read_blob: Failed to lock ACPI!\n");
+               memset(buf, 0, count);
+               return -EINVAL;
+       }
+
+       mutex_lock(&fw_cfg_dev_lock);
+       fw_cfg_sel_endianness(key);
+       while (pos-- > 0)
+               ioread8(fw_cfg_reg_data);
+       ioread8_rep(fw_cfg_reg_data, buf, count);
+       mutex_unlock(&fw_cfg_dev_lock);
+
+       acpi_release_global_lock(glk);
+       return count;
+}
+
+#ifdef CONFIG_CRASH_CORE
 static inline bool fw_cfg_dma_enabled(void)
 {
        return (fw_cfg_rev & FW_CFG_VERSION_DMA) && fw_cfg_reg_dma;
@@ -124,36 +154,6 @@ static ssize_t fw_cfg_dma_transfer(void *address, u32 length, u32 control)
        return ret;
 }
 
-/* read chunk of given fw_cfg blob (caller responsible for sanity-check) */
-static ssize_t fw_cfg_read_blob(u16 key,
-                               void *buf, loff_t pos, size_t count)
-{
-       u32 glk = -1U;
-       acpi_status status;
-
-       /* If we have ACPI, ensure mutual exclusion against any potential
-        * device access by the firmware, e.g. via AML methods:
-        */
-       status = acpi_acquire_global_lock(ACPI_WAIT_FOREVER, &glk);
-       if (ACPI_FAILURE(status) && status != AE_NOT_CONFIGURED) {
-               /* Should never get here */
-               WARN(1, "fw_cfg_read_blob: Failed to lock ACPI!\n");
-               memset(buf, 0, count);
-               return -EINVAL;
-       }
-
-       mutex_lock(&fw_cfg_dev_lock);
-       fw_cfg_sel_endianness(key);
-       while (pos-- > 0)
-               ioread8(fw_cfg_reg_data);
-       ioread8_rep(fw_cfg_reg_data, buf, count);
-       mutex_unlock(&fw_cfg_dev_lock);
-
-       acpi_release_global_lock(glk);
-       return count;
-}
-
-#ifdef CONFIG_CRASH_CORE
 /* write chunk of given fw_cfg blob (caller responsible for sanity-check) */
 static ssize_t fw_cfg_write_blob(u16 key,
                                 void *buf, loff_t pos, size_t count)
--

2.9.0