of/pci: Add of_pci_dma_range_parser_init() for dma-ranges parsing support

Several host bridge drivers duplicate of_pci_range_parser_init() in order
to parse their dma-ranges property.

Provide of_pci_dma_range_parser_init() for that use case.

Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Marc Gonzalez 2017-09-26 12:22:54 +02:00 committed by Bjorn Helgaas
parent 9e66317d3c
commit a060c2104e
2 changed files with 25 additions and 4 deletions

View File

@ -232,8 +232,8 @@ int of_pci_address_to_resource(struct device_node *dev, int bar,
} }
EXPORT_SYMBOL_GPL(of_pci_address_to_resource); EXPORT_SYMBOL_GPL(of_pci_address_to_resource);
int of_pci_range_parser_init(struct of_pci_range_parser *parser, static int parser_init(struct of_pci_range_parser *parser,
struct device_node *node) struct device_node *node, const char *name)
{ {
const int na = 3, ns = 2; const int na = 3, ns = 2;
int rlen; int rlen;
@ -242,7 +242,7 @@ int of_pci_range_parser_init(struct of_pci_range_parser *parser,
parser->pna = of_n_addr_cells(node); parser->pna = of_n_addr_cells(node);
parser->np = parser->pna + na + ns; parser->np = parser->pna + na + ns;
parser->range = of_get_property(node, "ranges", &rlen); parser->range = of_get_property(node, name, &rlen);
if (parser->range == NULL) if (parser->range == NULL)
return -ENOENT; return -ENOENT;
@ -250,8 +250,21 @@ int of_pci_range_parser_init(struct of_pci_range_parser *parser,
return 0; return 0;
} }
int of_pci_range_parser_init(struct of_pci_range_parser *parser,
struct device_node *node)
{
return parser_init(parser, node, "ranges");
}
EXPORT_SYMBOL_GPL(of_pci_range_parser_init); EXPORT_SYMBOL_GPL(of_pci_range_parser_init);
int of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
struct device_node *node)
{
return parser_init(parser, node, "dma-ranges");
}
EXPORT_SYMBOL_GPL(of_pci_dma_range_parser_init);
struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser, struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser,
struct of_pci_range *range) struct of_pci_range *range)
{ {

View File

@ -49,6 +49,8 @@ extern const __be32 *of_get_address(struct device_node *dev, int index,
extern int of_pci_range_parser_init(struct of_pci_range_parser *parser, extern int of_pci_range_parser_init(struct of_pci_range_parser *parser,
struct device_node *node); struct device_node *node);
extern int of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
struct device_node *node);
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);
@ -85,7 +87,13 @@ static inline const __be32 *of_get_address(struct device_node *dev, int index,
static inline int of_pci_range_parser_init(struct of_pci_range_parser *parser, static inline int of_pci_range_parser_init(struct of_pci_range_parser *parser,
struct device_node *node) struct device_node *node)
{ {
return -1; return -ENOSYS;
}
static inline int of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
struct device_node *node)
{
return -ENOSYS;
} }
static inline struct of_pci_range *of_pci_range_parser_one( static inline struct of_pci_range *of_pci_range_parser_one(