linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: Make the pci_dev_present() stub a static inline
@ 2021-11-16 13:12 Hans de Goede
  2021-11-16 15:28 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Hans de Goede @ 2021-11-16 13:12 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Hans de Goede, linux-pci, platform-driver-x86, kernel test robot

Change the pci_dev_present() stub which is used when CONFIG_PCI is not set
from a #define to a static inline stub.

Thix should fix clang -Werror builds failing due to errors like this:

drivers/platform/x86/thinkpad_acpi.c:4475:35:
 error: unused variable 'fwbug_cards_ids' [-Werror,-Wunused-const-variable]

Where fwbug_cards_ids is an array if pci_device_id-s passed to
pci_dev_present() during a quirk check.

Fixing this in include/linux/pci.h should ensure that the same issue is
also fixed in any other drivers hitting the same -Werror issue.

Cc: platform-driver-x86@vger.kernel.org
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Note the commit message says "should fix" because I could not actually
be bothered to verify this. The whole notion of combining:
1. clang
2. -Werror
3. -Wunused-const-variable
Is frankly a bit crazy, causing way too much noise and has already
cost me too much time IMHO.
---
 include/linux/pci.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index 18a75c8e615c..7d825637d7ca 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1775,7 +1775,10 @@ static inline struct pci_dev *pci_get_class(unsigned int class,
 					    struct pci_dev *from)
 { return NULL; }
 
-#define pci_dev_present(ids)	(0)
+
+static inline int pci_dev_present(const struct pci_device_id *ids)
+{ return 0; }
+
 #define no_pci_devices()	(1)
 #define pci_dev_put(dev)	do { } while (0)
 
-- 
2.31.1


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

* Re: [PATCH] PCI: Make the pci_dev_present() stub a static inline
  2021-11-16 13:12 [PATCH] PCI: Make the pci_dev_present() stub a static inline Hans de Goede
@ 2021-11-16 15:28 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2021-11-16 15:28 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Bjorn Helgaas, linux-pci, Platform Driver, kernel test robot

On Tue, Nov 16, 2021 at 3:14 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> Change the pci_dev_present() stub which is used when CONFIG_PCI is not set
> from a #define to a static inline stub.
>
> Thix should fix clang -Werror builds failing due to errors like this:
>
> drivers/platform/x86/thinkpad_acpi.c:4475:35:
>  error: unused variable 'fwbug_cards_ids' [-Werror,-Wunused-const-variable]
>
> Where fwbug_cards_ids is an array if pci_device_id-s passed to
> pci_dev_present() during a quirk check.
>
> Fixing this in include/linux/pci.h should ensure that the same issue is
> also fixed in any other drivers hitting the same -Werror issue.

FWIW,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Cc: platform-driver-x86@vger.kernel.org
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> Note the commit message says "should fix" because I could not actually
> be bothered to verify this. The whole notion of combining:
> 1. clang
> 2. -Werror
> 3. -Wunused-const-variable
> Is frankly a bit crazy, causing way too much noise and has already
> cost me too much time IMHO.
> ---
>  include/linux/pci.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 18a75c8e615c..7d825637d7ca 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1775,7 +1775,10 @@ static inline struct pci_dev *pci_get_class(unsigned int class,
>                                             struct pci_dev *from)
>  { return NULL; }
>
> -#define pci_dev_present(ids)   (0)
> +
> +static inline int pci_dev_present(const struct pci_device_id *ids)
> +{ return 0; }
> +
>  #define no_pci_devices()       (1)
>  #define pci_dev_put(dev)       do { } while (0)
>
> --
> 2.31.1
>


-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2021-11-16 15:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 13:12 [PATCH] PCI: Make the pci_dev_present() stub a static inline Hans de Goede
2021-11-16 15:28 ` Andy Shevchenko

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).