Skip to content

Commit

Permalink
Merge branch 'pci/host-tango' into next
Browse files Browse the repository at this point in the history
* pci/host-tango:
  PCI: tango: Add MSI controller support
  PCI: Use of_pci_dma_range_parser_init() to reduce duplication
  of/pci: Add of_pci_dma_range_parser_init() for dma-ranges parsing support
  • Loading branch information
bjorn-helgaas committed Nov 14, 2017
2 parents 9ff9503 + d76bdce commit 2b61a44
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 102 deletions.
19 changes: 16 additions & 3 deletions drivers/of/address.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ int of_pci_address_to_resource(struct device_node *dev, int bar,
}
EXPORT_SYMBOL_GPL(of_pci_address_to_resource);

int of_pci_range_parser_init(struct of_pci_range_parser *parser,
struct device_node *node)
static int parser_init(struct of_pci_range_parser *parser,
struct device_node *node, const char *name)
{
const int na = 3, ns = 2;
int rlen;
Expand All @@ -242,16 +242,29 @@ int of_pci_range_parser_init(struct of_pci_range_parser *parser,
parser->pna = of_n_addr_cells(node);
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)
return -ENOENT;

parser->end = parser->range + rlen / sizeof(__be32);

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

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 *range)
{
Expand Down
20 changes: 1 addition & 19 deletions drivers/pci/host/pci-ftpci100.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,24 +370,6 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p)
return 0;
}

static int pci_dma_range_parser_init(struct of_pci_range_parser *parser,
struct device_node *node)
{
const int na = 3, ns = 2;
int rlen;

parser->node = node;
parser->pna = of_n_addr_cells(node);
parser->np = parser->pna + na + ns;

parser->range = of_get_property(node, "dma-ranges", &rlen);
if (!parser->range)
return -ENOENT;
parser->end = parser->range + rlen / sizeof(__be32);

return 0;
}

static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p,
struct device_node *np)
{
Expand All @@ -402,7 +384,7 @@ static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p,
int i = 0;
u32 val;

if (pci_dma_range_parser_init(&parser, np)) {
if (of_pci_dma_range_parser_init(&parser, np)) {
dev_err(dev, "missing dma-ranges property\n");
return -EINVAL;
}
Expand Down
20 changes: 1 addition & 19 deletions drivers/pci/host/pci-rcar-gen2.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,24 +293,6 @@ static struct pci_ops rcar_pci_ops = {
.write = pci_generic_config_write,
};

static int pci_dma_range_parser_init(struct of_pci_range_parser *parser,
struct device_node *node)
{
const int na = 3, ns = 2;
int rlen;

parser->node = node;
parser->pna = of_n_addr_cells(node);
parser->np = parser->pna + na + ns;

parser->range = of_get_property(node, "dma-ranges", &rlen);
if (!parser->range)
return -ENOENT;

parser->end = parser->range + rlen / sizeof(__be32);
return 0;
}

static int rcar_pci_parse_map_dma_ranges(struct rcar_pci_priv *pci,
struct device_node *np)
{
Expand All @@ -320,7 +302,7 @@ static int rcar_pci_parse_map_dma_ranges(struct rcar_pci_priv *pci,
int index = 0;

/* Failure to parse is ok as we fall back to defaults */
if (pci_dma_range_parser_init(&parser, np))
if (of_pci_dma_range_parser_init(&parser, np))
return 0;

/* Get the dma-ranges from DT */
Expand Down
20 changes: 1 addition & 19 deletions drivers/pci/host/pci-xgene.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,24 +542,6 @@ static void xgene_pcie_setup_ib_reg(struct xgene_pcie_port *port,
xgene_pcie_setup_pims(port, pim_reg, pci_addr, ~(size - 1));
}

static int pci_dma_range_parser_init(struct of_pci_range_parser *parser,
struct device_node *node)
{
const int na = 3, ns = 2;
int rlen;

parser->node = node;
parser->pna = of_n_addr_cells(node);
parser->np = parser->pna + na + ns;

parser->range = of_get_property(node, "dma-ranges", &rlen);
if (!parser->range)
return -ENOENT;
parser->end = parser->range + rlen / sizeof(__be32);

return 0;
}

static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie_port *port)
{
struct device_node *np = port->node;
Expand All @@ -568,7 +550,7 @@ static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie_port *port)
struct device *dev = port->dev;
u8 ib_reg_mask = 0;

if (pci_dma_range_parser_init(&parser, np)) {
if (of_pci_dma_range_parser_init(&parser, np)) {
dev_err(dev, "missing dma-ranges property\n");
return -EINVAL;
}
Expand Down
20 changes: 1 addition & 19 deletions drivers/pci/host/pcie-iproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,32 +1097,14 @@ static int iproc_pcie_setup_ib(struct iproc_pcie *pcie,
return ret;
}

static int pci_dma_range_parser_init(struct of_pci_range_parser *parser,
struct device_node *node)
{
const int na = 3, ns = 2;
int rlen;

parser->node = node;
parser->pna = of_n_addr_cells(node);
parser->np = parser->pna + na + ns;

parser->range = of_get_property(node, "dma-ranges", &rlen);
if (!parser->range)
return -ENOENT;

parser->end = parser->range + rlen / sizeof(__be32);
return 0;
}

static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie)
{
struct of_pci_range range;
struct of_pci_range_parser parser;
int ret;

/* Get the dma-ranges from DT */
ret = pci_dma_range_parser_init(&parser, pcie->dev->of_node);
ret = of_pci_dma_range_parser_init(&parser, pcie->dev->of_node);
if (ret)
return ret;

Expand Down
20 changes: 1 addition & 19 deletions drivers/pci/host/pcie-rcar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,24 +1027,6 @@ static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie,
return 0;
}

static int pci_dma_range_parser_init(struct of_pci_range_parser *parser,
struct device_node *node)
{
const int na = 3, ns = 2;
int rlen;

parser->node = node;
parser->pna = of_n_addr_cells(node);
parser->np = parser->pna + na + ns;

parser->range = of_get_property(node, "dma-ranges", &rlen);
if (!parser->range)
return -ENOENT;

parser->end = parser->range + rlen / sizeof(__be32);
return 0;
}

static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie,
struct device_node *np)
{
Expand All @@ -1053,7 +1035,7 @@ static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie,
int index = 0;
int err;

if (pci_dma_range_parser_init(&parser, np))
if (of_pci_dma_range_parser_init(&parser, np))
return -EINVAL;

/* Get the dma-ranges from DT */
Expand Down
Loading

0 comments on commit 2b61a44

Please sign in to comment.