Commit c3c0dc75 authored by Rob Herring's avatar Rob Herring

of: address: Use IS_ENABLED() for !CONFIG_PCI

Convert address.c to use IS_ENABLED() instead of ifdefs for the
public PCI functions. This simplifies the ifdefs in of_address.h.

Cc: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210527194547.1287934-4-robh@kernel.org
parent 050a2c62
...@@ -198,6 +198,7 @@ static int of_bus_pci_translate(__be32 *addr, u64 offset, int na) ...@@ -198,6 +198,7 @@ static int of_bus_pci_translate(__be32 *addr, u64 offset, int na)
{ {
return of_bus_default_translate(addr + 1, offset, na - 1); return of_bus_default_translate(addr + 1, offset, na - 1);
} }
#endif /* CONFIG_PCI */
int of_pci_address_to_resource(struct device_node *dev, int bar, int of_pci_address_to_resource(struct device_node *dev, int bar,
struct resource *r) struct resource *r)
...@@ -206,6 +207,9 @@ int of_pci_address_to_resource(struct device_node *dev, int bar, ...@@ -206,6 +207,9 @@ int of_pci_address_to_resource(struct device_node *dev, int bar,
u64 size; u64 size;
unsigned int flags; unsigned int flags;
if (!IS_ENABLED(CONFIG_PCI))
return -ENOSYS;
addrp = of_get_pci_address(dev, bar, &size, &flags); addrp = of_get_pci_address(dev, bar, &size, &flags);
if (addrp == NULL) if (addrp == NULL)
return -EINVAL; return -EINVAL;
...@@ -236,6 +240,9 @@ int of_pci_range_to_resource(struct of_pci_range *range, ...@@ -236,6 +240,9 @@ int of_pci_range_to_resource(struct of_pci_range *range,
res->parent = res->child = res->sibling = NULL; res->parent = res->child = res->sibling = NULL;
res->name = np->full_name; res->name = np->full_name;
if (!IS_ENABLED(CONFIG_PCI))
return -ENOSYS;
if (res->flags & IORESOURCE_IO) { if (res->flags & IORESOURCE_IO) {
unsigned long port; unsigned long port;
err = pci_register_io_range(&np->fwnode, range->cpu_addr, err = pci_register_io_range(&np->fwnode, range->cpu_addr,
...@@ -266,7 +273,6 @@ int of_pci_range_to_resource(struct of_pci_range *range, ...@@ -266,7 +273,6 @@ int of_pci_range_to_resource(struct of_pci_range *range,
return err; return err;
} }
EXPORT_SYMBOL(of_pci_range_to_resource); EXPORT_SYMBOL(of_pci_range_to_resource);
#endif /* CONFIG_PCI */
/* /*
* ISA bus specific translator * ISA bus specific translator
......
...@@ -61,6 +61,11 @@ extern int of_pci_dma_range_parser_init(struct of_pci_range_parser *parser, ...@@ -61,6 +61,11 @@ extern int of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
extern struct of_pci_range *of_pci_range_parser_one( extern struct of_pci_range *of_pci_range_parser_one(
struct of_pci_range_parser *parser, struct of_pci_range_parser *parser,
struct of_pci_range *range); struct of_pci_range *range);
extern int of_pci_address_to_resource(struct device_node *dev, int bar,
struct resource *r);
extern int of_pci_range_to_resource(struct of_pci_range *range,
struct device_node *np,
struct resource *res);
extern bool of_dma_is_coherent(struct device_node *np); extern bool of_dma_is_coherent(struct device_node *np);
#else /* CONFIG_OF_ADDRESS */ #else /* CONFIG_OF_ADDRESS */
static inline void __iomem *of_io_request_and_map(struct device_node *device, static inline void __iomem *of_io_request_and_map(struct device_node *device,
...@@ -100,6 +105,19 @@ static inline struct of_pci_range *of_pci_range_parser_one( ...@@ -100,6 +105,19 @@ static inline struct of_pci_range *of_pci_range_parser_one(
return NULL; return NULL;
} }
static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
struct resource *r)
{
return -ENOSYS;
}
static inline int of_pci_range_to_resource(struct of_pci_range *range,
struct device_node *np,
struct resource *res)
{
return -ENOSYS;
}
static inline bool of_dma_is_coherent(struct device_node *np) static inline bool of_dma_is_coherent(struct device_node *np)
{ {
return false; return false;
...@@ -124,27 +142,6 @@ static inline void __iomem *of_iomap(struct device_node *device, int index) ...@@ -124,27 +142,6 @@ static inline void __iomem *of_iomap(struct device_node *device, int index)
#endif #endif
#define of_range_parser_init of_pci_range_parser_init #define of_range_parser_init of_pci_range_parser_init
#if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
extern int of_pci_address_to_resource(struct device_node *dev, int bar,
struct resource *r);
extern int of_pci_range_to_resource(struct of_pci_range *range,
struct device_node *np,
struct resource *res);
#else /* CONFIG_OF_ADDRESS && CONFIG_PCI */
static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
struct resource *r)
{
return -ENOSYS;
}
static inline int of_pci_range_to_resource(struct of_pci_range *range,
struct device_node *np,
struct resource *res)
{
return -ENOSYS;
}
#endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */
static inline const __be32 *of_get_address(struct device_node *dev, int index, static inline const __be32 *of_get_address(struct device_node *dev, int index,
u64 *size, unsigned int *flags) u64 *size, unsigned int *flags)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment