[PATCH v2] efi: sysfb_efi: Fix unused const variable 'efifb_fwnode_ops'

Zeng Heng posted 1 patch 1 month ago
drivers/firmware/efi/sysfb_efi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] efi: sysfb_efi: 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 = {

In addition to the above warning messages, a series of unused warnings
because of cascading dependencies were found. The variables and functions
related to warnings are only used after CONFIG_EFI enabled. Therefore,
these warnings are addressed and fixed in this commit.

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/sysfb_efi.c b/drivers/firmware/efi/sysfb_efi.c
index cc807ed35aed..0cfc11ecc98b 100644
--- a/drivers/firmware/efi/sysfb_efi.c
+++ b/drivers/firmware/efi/sysfb_efi.c
@@ -82,6 +82,7 @@ void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
 	}
 }
 
+#ifdef CONFIG_EFI
 #define choose_value(dmivalue, fwvalue, field, flags) ({	\
 		typeof(fwvalue) _ret_ = fwvalue;		\
 		if ((flags) & (field))				\
@@ -346,7 +347,6 @@ static const struct fwnode_operations efifb_fwnode_ops = {
 	.add_links = efifb_add_links,
 };
 
-#ifdef CONFIG_EFI
 static struct fwnode_handle efifb_fwnode;
 
 __init void sysfb_apply_efi_quirks(void)
-- 
2.25.1

Re: [PATCH v2] efi: sysfb_efi: Fix unused const variable 'efifb_fwnode_ops'
Posted by Ard Biesheuvel 1 week, 3 days ago
On Sat, 26 Oct 2024 at 08:48, Zeng Heng <zengheng4@huawei.com> wrote:
>
> 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 = {
>
> In addition to the above warning messages, a series of unused warnings
> because of cascading dependencies were found. The variables and functions
> related to warnings are only used after CONFIG_EFI enabled. Therefore,
> these warnings are addressed and fixed in this commit.
>
> 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 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Is there any reason to build this file in the first place if
CONFIG_EFI is disabled? Should we fix this in the Makefile instead?


> diff --git a/drivers/firmware/efi/sysfb_efi.c b/drivers/firmware/efi/sysfb_efi.c
> index cc807ed35aed..0cfc11ecc98b 100644
> --- a/drivers/firmware/efi/sysfb_efi.c
> +++ b/drivers/firmware/efi/sysfb_efi.c
> @@ -82,6 +82,7 @@ void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
>         }
>  }
>
> +#ifdef CONFIG_EFI
>  #define choose_value(dmivalue, fwvalue, field, flags) ({       \
>                 typeof(fwvalue) _ret_ = fwvalue;                \
>                 if ((flags) & (field))                          \
> @@ -346,7 +347,6 @@ static const struct fwnode_operations efifb_fwnode_ops = {
>         .add_links = efifb_add_links,
>  };
>
> -#ifdef CONFIG_EFI
>  static struct fwnode_handle efifb_fwnode;
>
>  __init void sysfb_apply_efi_quirks(void)
> --
> 2.25.1
>