diff options
author | Marc Gonzalez <marc_gonzalez@sigmadesigns.com> | 2017-09-26 06:26:55 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2017-10-05 16:52:34 -0400 |
commit | 1e61a57cac560844580ab532a4e2f5061ef77039 (patch) | |
tree | 5326edc886070c8c09829c3ade143be234acbb98 /drivers | |
parent | a060c2104ef83e62346b7e893947a940471c0d7c (diff) |
PCI: Use of_pci_dma_range_parser_init() to reduce duplication
Use the new of_pci_dma_range_parser_init() to reduce code duplication.
Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pci/host/pci-ftpci100.c | 20 | ||||
-rw-r--r-- | drivers/pci/host/pci-rcar-gen2.c | 20 | ||||
-rw-r--r-- | drivers/pci/host/pci-xgene.c | 20 | ||||
-rw-r--r-- | drivers/pci/host/pcie-iproc.c | 20 | ||||
-rw-r--r-- | drivers/pci/host/pcie-rcar.c | 20 |
5 files changed, 5 insertions, 95 deletions
diff --git a/drivers/pci/host/pci-ftpci100.c b/drivers/pci/host/pci-ftpci100.c index 96028f01bc90..06d9687e038a 100644 --- a/drivers/pci/host/pci-ftpci100.c +++ b/drivers/pci/host/pci-ftpci100.c | |||
@@ -370,24 +370,6 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p) | |||
370 | return 0; | 370 | return 0; |
371 | } | 371 | } |
372 | 372 | ||
373 | static int pci_dma_range_parser_init(struct of_pci_range_parser *parser, | ||
374 | struct device_node *node) | ||
375 | { | ||
376 | const int na = 3, ns = 2; | ||
377 | int rlen; | ||
378 | |||
379 | parser->node = node; | ||
380 | parser->pna = of_n_addr_cells(node); | ||
381 | parser->np = parser->pna + na + ns; | ||
382 | |||
383 | parser->range = of_get_property(node, "dma-ranges", &rlen); | ||
384 | if (!parser->range) | ||
385 | return -ENOENT; | ||
386 | parser->end = parser->range + rlen / sizeof(__be32); | ||
387 | |||
388 | return 0; | ||
389 | } | ||
390 | |||
391 | static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p, | 373 | static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p, |
392 | struct device_node *np) | 374 | struct device_node *np) |
393 | { | 375 | { |
@@ -402,7 +384,7 @@ static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p, | |||
402 | int i = 0; | 384 | int i = 0; |
403 | u32 val; | 385 | u32 val; |
404 | 386 | ||
405 | if (pci_dma_range_parser_init(&parser, np)) { | 387 | if (of_pci_dma_range_parser_init(&parser, np)) { |
406 | dev_err(dev, "missing dma-ranges property\n"); | 388 | dev_err(dev, "missing dma-ranges property\n"); |
407 | return -EINVAL; | 389 | return -EINVAL; |
408 | } | 390 | } |
diff --git a/drivers/pci/host/pci-rcar-gen2.c b/drivers/pci/host/pci-rcar-gen2.c index 6f879685fedd..e46de69f0380 100644 --- a/drivers/pci/host/pci-rcar-gen2.c +++ b/drivers/pci/host/pci-rcar-gen2.c | |||
@@ -293,24 +293,6 @@ static struct pci_ops rcar_pci_ops = { | |||
293 | .write = pci_generic_config_write, | 293 | .write = pci_generic_config_write, |
294 | }; | 294 | }; |
295 | 295 | ||
296 | static int pci_dma_range_parser_init(struct of_pci_range_parser *parser, | ||
297 | struct device_node *node) | ||
298 | { | ||
299 | const int na = 3, ns = 2; | ||
300 | int rlen; | ||
301 | |||
302 | parser->node = node; | ||
303 | parser->pna = of_n_addr_cells(node); | ||
304 | parser->np = parser->pna + na + ns; | ||
305 | |||
306 | parser->range = of_get_property(node, "dma-ranges", &rlen); | ||
307 | if (!parser->range) | ||
308 | return -ENOENT; | ||
309 | |||
310 | parser->end = parser->range + rlen / sizeof(__be32); | ||
311 | return 0; | ||
312 | } | ||
313 | |||
314 | static int rcar_pci_parse_map_dma_ranges(struct rcar_pci_priv *pci, | 296 | static int rcar_pci_parse_map_dma_ranges(struct rcar_pci_priv *pci, |
315 | struct device_node *np) | 297 | struct device_node *np) |
316 | { | 298 | { |
@@ -320,7 +302,7 @@ static int rcar_pci_parse_map_dma_ranges(struct rcar_pci_priv *pci, | |||
320 | int index = 0; | 302 | int index = 0; |
321 | 303 | ||
322 | /* Failure to parse is ok as we fall back to defaults */ | 304 | /* Failure to parse is ok as we fall back to defaults */ |
323 | if (pci_dma_range_parser_init(&parser, np)) | 305 | if (of_pci_dma_range_parser_init(&parser, np)) |
324 | return 0; | 306 | return 0; |
325 | 307 | ||
326 | /* Get the dma-ranges from DT */ | 308 | /* Get the dma-ranges from DT */ |
diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c index 087645116ecb..8fc45d95edab 100644 --- a/drivers/pci/host/pci-xgene.c +++ b/drivers/pci/host/pci-xgene.c | |||
@@ -542,24 +542,6 @@ static void xgene_pcie_setup_ib_reg(struct xgene_pcie_port *port, | |||
542 | xgene_pcie_setup_pims(port, pim_reg, pci_addr, ~(size - 1)); | 542 | xgene_pcie_setup_pims(port, pim_reg, pci_addr, ~(size - 1)); |
543 | } | 543 | } |
544 | 544 | ||
545 | static int pci_dma_range_parser_init(struct of_pci_range_parser *parser, | ||
546 | struct device_node *node) | ||
547 | { | ||
548 | const int na = 3, ns = 2; | ||
549 | int rlen; | ||
550 | |||
551 | parser->node = node; | ||
552 | parser->pna = of_n_addr_cells(node); | ||
553 | parser->np = parser->pna + na + ns; | ||
554 | |||
555 | parser->range = of_get_property(node, "dma-ranges", &rlen); | ||
556 | if (!parser->range) | ||
557 | return -ENOENT; | ||
558 | parser->end = parser->range + rlen / sizeof(__be32); | ||
559 | |||
560 | return 0; | ||
561 | } | ||
562 | |||
563 | static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie_port *port) | 545 | static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie_port *port) |
564 | { | 546 | { |
565 | struct device_node *np = port->node; | 547 | struct device_node *np = port->node; |
@@ -568,7 +550,7 @@ static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie_port *port) | |||
568 | struct device *dev = port->dev; | 550 | struct device *dev = port->dev; |
569 | u8 ib_reg_mask = 0; | 551 | u8 ib_reg_mask = 0; |
570 | 552 | ||
571 | if (pci_dma_range_parser_init(&parser, np)) { | 553 | if (of_pci_dma_range_parser_init(&parser, np)) { |
572 | dev_err(dev, "missing dma-ranges property\n"); | 554 | dev_err(dev, "missing dma-ranges property\n"); |
573 | return -EINVAL; | 555 | return -EINVAL; |
574 | } | 556 | } |
diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c index 3a8b9d20ee57..935909bbe5c4 100644 --- a/drivers/pci/host/pcie-iproc.c +++ b/drivers/pci/host/pcie-iproc.c | |||
@@ -1097,24 +1097,6 @@ err_ib: | |||
1097 | return ret; | 1097 | return ret; |
1098 | } | 1098 | } |
1099 | 1099 | ||
1100 | static int pci_dma_range_parser_init(struct of_pci_range_parser *parser, | ||
1101 | struct device_node *node) | ||
1102 | { | ||
1103 | const int na = 3, ns = 2; | ||
1104 | int rlen; | ||
1105 | |||
1106 | parser->node = node; | ||
1107 | parser->pna = of_n_addr_cells(node); | ||
1108 | parser->np = parser->pna + na + ns; | ||
1109 | |||
1110 | parser->range = of_get_property(node, "dma-ranges", &rlen); | ||
1111 | if (!parser->range) | ||
1112 | return -ENOENT; | ||
1113 | |||
1114 | parser->end = parser->range + rlen / sizeof(__be32); | ||
1115 | return 0; | ||
1116 | } | ||
1117 | |||
1118 | static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie) | 1100 | static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie) |
1119 | { | 1101 | { |
1120 | struct of_pci_range range; | 1102 | struct of_pci_range range; |
@@ -1122,7 +1104,7 @@ static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie) | |||
1122 | int ret; | 1104 | int ret; |
1123 | 1105 | ||
1124 | /* Get the dma-ranges from DT */ | 1106 | /* Get the dma-ranges from DT */ |
1125 | ret = pci_dma_range_parser_init(&parser, pcie->dev->of_node); | 1107 | ret = of_pci_dma_range_parser_init(&parser, pcie->dev->of_node); |
1126 | if (ret) | 1108 | if (ret) |
1127 | return ret; | 1109 | return ret; |
1128 | 1110 | ||
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 4e0b25d09b0c..12796eccb2be 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c | |||
@@ -1027,24 +1027,6 @@ static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, | |||
1027 | return 0; | 1027 | return 0; |
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | static int pci_dma_range_parser_init(struct of_pci_range_parser *parser, | ||
1031 | struct device_node *node) | ||
1032 | { | ||
1033 | const int na = 3, ns = 2; | ||
1034 | int rlen; | ||
1035 | |||
1036 | parser->node = node; | ||
1037 | parser->pna = of_n_addr_cells(node); | ||
1038 | parser->np = parser->pna + na + ns; | ||
1039 | |||
1040 | parser->range = of_get_property(node, "dma-ranges", &rlen); | ||
1041 | if (!parser->range) | ||
1042 | return -ENOENT; | ||
1043 | |||
1044 | parser->end = parser->range + rlen / sizeof(__be32); | ||
1045 | return 0; | ||
1046 | } | ||
1047 | |||
1048 | static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie, | 1030 | static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie, |
1049 | struct device_node *np) | 1031 | struct device_node *np) |
1050 | { | 1032 | { |
@@ -1053,7 +1035,7 @@ static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie, | |||
1053 | int index = 0; | 1035 | int index = 0; |
1054 | int err; | 1036 | int err; |
1055 | 1037 | ||
1056 | if (pci_dma_range_parser_init(&parser, np)) | 1038 | if (of_pci_dma_range_parser_init(&parser, np)) |
1057 | return -EINVAL; | 1039 | return -EINVAL; |
1058 | 1040 | ||
1059 | /* Get the dma-ranges from DT */ | 1041 | /* Get the dma-ranges from DT */ |