Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: Introduce pci_resource_n()

Introduce pci_resource_n() and replace open-coded implementations of it
in pci.h.

Link: https://lore.kernel.org/r/20230330162434.35055-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

authored by

Andy Shevchenko and committed by
Bjorn Helgaas
144d204d fe15c26e

+7 -8
+7 -8
include/linux/pci.h
··· 1994 1994 * These helpers provide future and backwards compatibility 1995 1995 * for accessing popular PCI BAR info 1996 1996 */ 1997 - #define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start) 1998 - #define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end) 1999 - #define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags) 2000 - #define pci_resource_len(dev,bar) \ 2001 - ((pci_resource_end((dev), (bar)) == 0) ? 0 : \ 2002 - \ 2003 - (pci_resource_end((dev), (bar)) - \ 2004 - pci_resource_start((dev), (bar)) + 1)) 1997 + #define pci_resource_n(dev, bar) (&(dev)->resource[(bar)]) 1998 + #define pci_resource_start(dev, bar) (pci_resource_n(dev, bar)->start) 1999 + #define pci_resource_end(dev, bar) (pci_resource_n(dev, bar)->end) 2000 + #define pci_resource_flags(dev, bar) (pci_resource_n(dev, bar)->flags) 2001 + #define pci_resource_len(dev,bar) \ 2002 + (pci_resource_end((dev), (bar)) ? \ 2003 + resource_size(pci_resource_n((dev), (bar))) : 0) 2005 2004 2006 2005 /* 2007 2006 * Similar to the helpers above, these manipulate per-pci_dev