linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI/sysfs: hide boot_display definition when VIDEO=n
@ 2025-07-21 21:02 Randy Dunlap
  2025-07-21 21:05 ` Limonciello, Mario
  0 siblings, 1 reply; 3+ messages in thread
From: Randy Dunlap @ 2025-07-21 21:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: Randy Dunlap, Mario Limonciello, Bjorn Helgaas, linux-pci

When CONFIG_VIDEO is not set, defining the 'boot_display' attribute
causes build errors/warnings, so hide the declaration as is done with
other code that uses this variable. Bracket unused code inside
#ifdef CONFIG_VIDEO/#endif to prevent other build warnings/errors.

include/linux/device.h:199:33: warning: 'dev_attr_boot_display' defined but not used [-Wunused-variable]
  199 |         struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
drivers/pci/pci-sysfs.c:688:8: note: in expansion of macro 'DEVICE_ATTR_RO'
  688 | static DEVICE_ATTR_RO(boot_display);

drivers/pci/pci-sysfs.c:683:16: warning: ‘boot_display_show’ defined but not used [-Wunused-function]
  683 | static ssize_t boot_display_show(struct device *dev,
      |                ^~~~~~~~~~~~~~~~~

Fixes: c4f2dc1e5293c ("PCI: Add a new 'boot_display' attribute")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
---
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org

Also, a question:
What does this do in pci-sysfs.c?
#ifndef ARCH_PCI_DEV_GROUPS
#define ARCH_PCI_DEV_GROUPS
#endif
Is there some hidden macro (probably using string concatenation)
that uses this define value? Thanks.

 drivers/pci/pci-sysfs.c |    3 +++
 1 file changed, 3 insertions(+)

--- linux-next-20250721.orig/drivers/pci/pci-sysfs.c
+++ linux-next-20250721/drivers/pci/pci-sysfs.c
@@ -680,12 +680,15 @@ const struct attribute_group *pcibus_gro
 	NULL,
 };
 
+#ifdef CONFIG_VIDEO
 static ssize_t boot_display_show(struct device *dev,
 				 struct device_attribute *attr, char *buf)
 {
 	return sysfs_emit(buf, "1\n");
 }
+
 static DEVICE_ATTR_RO(boot_display);
+#endif
 
 static ssize_t boot_vga_show(struct device *dev, struct device_attribute *attr,
 			     char *buf)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI/sysfs: hide boot_display definition when VIDEO=n
  2025-07-21 21:02 [PATCH] PCI/sysfs: hide boot_display definition when VIDEO=n Randy Dunlap
@ 2025-07-21 21:05 ` Limonciello, Mario
  2025-07-21 21:08   ` Randy Dunlap
  0 siblings, 1 reply; 3+ messages in thread
From: Limonciello, Mario @ 2025-07-21 21:05 UTC (permalink / raw)
  To: Randy Dunlap, linux-kernel@vger.kernel.org
  Cc: Bjorn Helgaas, linux-pci@vger.kernel.org, Stephen Rothwell

On 7/21/25 4:02 PM, Randy Dunlap wrote:
> When CONFIG_VIDEO is not set, defining the 'boot_display' attribute
> causes build errors/warnings, so hide the declaration as is done with
> other code that uses this variable. Bracket unused code inside
> #ifdef CONFIG_VIDEO/#endif to prevent other build warnings/errors.
> 
> include/linux/device.h:199:33: warning: 'dev_attr_boot_display' defined but not used [-Wunused-variable]
>    199 |         struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
> drivers/pci/pci-sysfs.c:688:8: note: in expansion of macro 'DEVICE_ATTR_RO'
>    688 | static DEVICE_ATTR_RO(boot_display);
> 
> drivers/pci/pci-sysfs.c:683:16: warning: ‘boot_display_show’ defined but not used [-Wunused-function]
>    683 | static ssize_t boot_display_show(struct device *dev,
>        |                ^~~~~~~~~~~~~~~~~
> 
> Fixes: c4f2dc1e5293c ("PCI: Add a new 'boot_display' attribute")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>

Hi Randy,

Thanks for the patch.  Stephen raised this last week too and it's 
brought up some other interesting topics as part of fixing it.

I have two other approaches on the mailing list right now waiting for 
review.

1) Make a static sysfs file.
https://lore.kernel.org/linux-pci/20250721023818.2410062-1-superm1@kernel.org/T/#u

2) Move out of PCI into DRM.
https://lore.kernel.org/linux-pci/20250721185726.1264909-1-superm1@kernel.org/T/#me4356b3a172cbdafe83393bedce10f17a86e0da7

Thanks,

> ---
> Cc: Mario Limonciello <mario.limonciello@amd.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: linux-pci@vger.kernel.org
> 
> Also, a question:
> What does this do in pci-sysfs.c?
> #ifndef ARCH_PCI_DEV_GROUPS
> #define ARCH_PCI_DEV_GROUPS
> #endif
> Is there some hidden macro (probably using string concatenation)
> that uses this define value? Thanks.
> 
>   drivers/pci/pci-sysfs.c |    3 +++
>   1 file changed, 3 insertions(+)
> 
> --- linux-next-20250721.orig/drivers/pci/pci-sysfs.c
> +++ linux-next-20250721/drivers/pci/pci-sysfs.c
> @@ -680,12 +680,15 @@ const struct attribute_group *pcibus_gro
>   	NULL,
>   };
>   
> +#ifdef CONFIG_VIDEO
>   static ssize_t boot_display_show(struct device *dev,
>   				 struct device_attribute *attr, char *buf)
>   {
>   	return sysfs_emit(buf, "1\n");
>   }
> +
>   static DEVICE_ATTR_RO(boot_display);
> +#endif
>   
>   static ssize_t boot_vga_show(struct device *dev, struct device_attribute *attr,
>   			     char *buf)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI/sysfs: hide boot_display definition when VIDEO=n
  2025-07-21 21:05 ` Limonciello, Mario
@ 2025-07-21 21:08   ` Randy Dunlap
  0 siblings, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2025-07-21 21:08 UTC (permalink / raw)
  To: Limonciello, Mario, linux-kernel@vger.kernel.org
  Cc: Bjorn Helgaas, linux-pci@vger.kernel.org, Stephen Rothwell

Hi Mario,

On 7/21/25 2:05 PM, Limonciello, Mario wrote:
> On 7/21/25 4:02 PM, Randy Dunlap wrote:
>> When CONFIG_VIDEO is not set, defining the 'boot_display' attribute
>> causes build errors/warnings, so hide the declaration as is done with
>> other code that uses this variable. Bracket unused code inside
>> #ifdef CONFIG_VIDEO/#endif to prevent other build warnings/errors.
>>
>> include/linux/device.h:199:33: warning: 'dev_attr_boot_display' defined but not used [-Wunused-variable]
>>    199 |         struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
>> drivers/pci/pci-sysfs.c:688:8: note: in expansion of macro 'DEVICE_ATTR_RO'
>>    688 | static DEVICE_ATTR_RO(boot_display);
>>
>> drivers/pci/pci-sysfs.c:683:16: warning: ‘boot_display_show’ defined but not used [-Wunused-function]
>>    683 | static ssize_t boot_display_show(struct device *dev,
>>        |                ^~~~~~~~~~~~~~~~~
>>
>> Fixes: c4f2dc1e5293c ("PCI: Add a new 'boot_display' attribute")
>> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> 
> Hi Randy,
> 
> Thanks for the patch.  Stephen raised this last week too and it's 
> brought up some other interesting topics as part of fixing it.
> 
> I have two other approaches on the mailing list right now waiting for 
> review.
> 
> 1) Make a static sysfs file.
> https://lore.kernel.org/linux-pci/20250721023818.2410062-1-superm1@kernel.org/T/#u
> 
> 2) Move out of PCI into DRM.
> https://lore.kernel.org/linux-pci/20250721185726.1264909-1-superm1@kernel.org/T/#me4356b3a172cbdafe83393bedce10f17a86e0da7

Yes, I found the second one just after I sent the patch.
Anyway, my patch is not relevant now.

Thanks.

-- 
~Randy


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-21 21:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-21 21:02 [PATCH] PCI/sysfs: hide boot_display definition when VIDEO=n Randy Dunlap
2025-07-21 21:05 ` Limonciello, Mario
2025-07-21 21:08   ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).