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

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>

authored by

Marc Gonzalez and committed by
Bjorn Helgaas
1e61a57c a060c210

+5 -95
+1 -19
drivers/pci/host/pci-ftpci100.c
··· 370 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 373 static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p, 392 374 struct device_node *np) 393 375 { ··· 384 402 int i = 0; 385 403 u32 val; 386 404 387 - if (pci_dma_range_parser_init(&parser, np)) { 405 + if (of_pci_dma_range_parser_init(&parser, np)) { 388 406 dev_err(dev, "missing dma-ranges property\n"); 389 407 return -EINVAL; 390 408 }
+1 -19
drivers/pci/host/pci-rcar-gen2.c
··· 293 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 296 static int rcar_pci_parse_map_dma_ranges(struct rcar_pci_priv *pci, 315 297 struct device_node *np) 316 298 { ··· 302 320 int index = 0; 303 321 304 322 /* Failure to parse is ok as we fall back to defaults */ 305 - if (pci_dma_range_parser_init(&parser, np)) 323 + if (of_pci_dma_range_parser_init(&parser, np)) 306 324 return 0; 307 325 308 326 /* Get the dma-ranges from DT */
+1 -19
drivers/pci/host/pci-xgene.c
··· 542 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 545 static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie_port *port) 564 546 { 565 547 struct device_node *np = port->node; ··· 550 568 struct device *dev = port->dev; 551 569 u8 ib_reg_mask = 0; 552 570 553 - if (pci_dma_range_parser_init(&parser, np)) { 571 + if (of_pci_dma_range_parser_init(&parser, np)) { 554 572 dev_err(dev, "missing dma-ranges property\n"); 555 573 return -EINVAL; 556 574 }
+1 -19
drivers/pci/host/pcie-iproc.c
··· 1097 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 1100 static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie) 1119 1101 { 1120 1102 struct of_pci_range range; ··· 1104 1122 int ret; 1105 1123 1106 1124 /* Get the dma-ranges from DT */ 1107 - ret = pci_dma_range_parser_init(&parser, pcie->dev->of_node); 1125 + ret = of_pci_dma_range_parser_init(&parser, pcie->dev->of_node); 1108 1126 if (ret) 1109 1127 return ret; 1110 1128
+1 -19
drivers/pci/host/pcie-rcar.c
··· 1027 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 1030 static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie, 1049 1031 struct device_node *np) 1050 1032 { ··· 1035 1053 int index = 0; 1036 1054 int err; 1037 1055 1038 - if (pci_dma_range_parser_init(&parser, np)) 1056 + if (of_pci_dma_range_parser_init(&parser, np)) 1039 1057 return -EINVAL; 1040 1058 1041 1059 /* Get the dma-ranges from DT */