[PATCH] drivers/firmware: Fix unused const variable 'efifb_fwnode_ops'

Zeng Heng posted 1 patch 1 month ago
drivers/firmware/efi/sysfb_efi.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
[PATCH] drivers/firmware: Fix unused const variable 'efifb_fwnode_ops'
Posted by Zeng Heng 1 month ago
Fix the following compilation warning:

drivers/firmware/efi/sysfb_efi.c:345:39: warning:
‘efifb_fwnode_ops’ defined but not used [-Wunused-const-variable=]
  345 | static const struct fwnode_operations efifb_fwnode_ops = {

drivers/firmware/efi/sysfb_efi.c:238:35: warning:
‘efifb_dmi_swap_width_height’ defined but not used
[-Wunused-const-variable=]
  238 | static const struct dmi_system_id
	efifb_dmi_swap_width_height[] __initconst = {

drivers/firmware/efi/sysfb_efi.c:188:35: warning:
‘efifb_dmi_system_table’ defined but not used
[-Wunused-const-variable=]
  188 | static const struct dmi_system_id
	efifb_dmi_system_table[] __initconst = {

Only define the const variables when the CONFIG_EFI is enabled.

Fixes: 8633ef82f101 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")
Signed-off-by: Zeng Heng <zengheng4@huawei.com>
---
 drivers/firmware/efi/sysfb_efi.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/efi/sysfb_efi.c b/drivers/firmware/efi/sysfb_efi.c
index cc807ed35aed..f75bfe9b197c 100644
--- a/drivers/firmware/efi/sysfb_efi.c
+++ b/drivers/firmware/efi/sysfb_efi.c
@@ -185,6 +185,7 @@ static int __init efifb_set_system(const struct dmi_system_id *id)
 		&efifb_dmi_list[enumid]				\
 	}
 
+#ifdef CONFIG_EFI
 static const struct dmi_system_id efifb_dmi_system_table[] __initconst = {
 	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac4,1", M_I17),
 	/* At least one of these two will be right; maybe both? */
@@ -282,6 +283,7 @@ static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
 	},
 	{},
 };
+#endif
 
 static bool efifb_overlaps_pci_range(const struct of_pci_range *range)
 {
@@ -342,10 +344,6 @@ static int efifb_add_links(struct fwnode_handle *fwnode)
 	return 0;
 }
 
-static const struct fwnode_operations efifb_fwnode_ops = {
-	.add_links = efifb_add_links,
-};
-
 #ifdef CONFIG_EFI
 static struct fwnode_handle efifb_fwnode;
 
@@ -365,6 +363,10 @@ __init void sysfb_apply_efi_quirks(void)
 	}
 }
 
+static const struct fwnode_operations efifb_fwnode_ops = {
+	.add_links = efifb_add_links,
+};
+
 __init void sysfb_set_efifb_fwnode(struct platform_device *pd)
 {
 	if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI && IS_ENABLED(CONFIG_PCI)) {
-- 
2.25.1

Re: [PATCH] drivers/firmware: Fix unused const variable 'efifb_fwnode_ops'
Posted by kernel test robot 1 month ago
Hi Zeng,

kernel test robot noticed the following build warnings:

[auto build test WARNING on efi/next]
[also build test WARNING on linus/master v6.12-rc4 next-20241024]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Zeng-Heng/drivers-firmware-Fix-unused-const-variable-efifb_fwnode_ops/20241024-163259
base:   https://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git next
patch link:    https://lore.kernel.org/r/20241024084435.165333-1-zengheng4%40huawei.com
patch subject: [PATCH] drivers/firmware: Fix unused const variable 'efifb_fwnode_ops'
config: x86_64-buildonly-randconfig-002-20241025 (https://download.01.org/0day-ci/archive/20241025/202410251211.Jze0KkZR-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241025/202410251211.Jze0KkZR-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410251211.Jze0KkZR-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/firmware/efi/sysfb_efi.c:328:12: warning: 'efifb_add_links' defined but not used [-Wunused-function]
     328 | static int efifb_add_links(struct fwnode_handle *fwnode)
         |            ^~~~~~~~~~~~~~~
>> drivers/firmware/efi/sysfb_efi.c:94:19: warning: 'efifb_set_system' defined but not used [-Wunused-function]
      94 | static int __init efifb_set_system(const struct dmi_system_id *id)
         |                   ^~~~~~~~~~~~~~~~


vim +/efifb_add_links +328 drivers/firmware/efi/sysfb_efi.c

8633ef82f101c0 Javier Martinez Canillas 2021-06-25  320  
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  321  /*
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  322   * If the efifb framebuffer is backed by a PCI graphics controller, we have
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  323   * to ensure that this relation is expressed using a device link when
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  324   * running in DT mode, or the probe order may be reversed, resulting in a
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  325   * resource reservation conflict on the memory window that the efifb
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  326   * framebuffer steals from the PCIe host bridge.
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  327   */
8633ef82f101c0 Javier Martinez Canillas 2021-06-25 @328  static int efifb_add_links(struct fwnode_handle *fwnode)
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  329  {
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  330  	struct device_node *sup_np;
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  331  
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  332  	sup_np = find_pci_overlap_node();
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  333  
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  334  	/*
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  335  	 * If there's no PCI graphics controller backing the efifb, we are
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  336  	 * done here.
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  337  	 */
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  338  	if (!sup_np)
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  339  		return 0;
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  340  
75cde56a5b504d Saravana Kannan          2024-03-04  341  	fwnode_link_add(fwnode, of_fwnode_handle(sup_np), 0);
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  342  	of_node_put(sup_np);
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  343  
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  344  	return 0;
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  345  }
8633ef82f101c0 Javier Martinez Canillas 2021-06-25  346  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki