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

PCI: dwc: Remove unnecessary wrappers around dw_pcie_host_init()

Many calls to dw_pcie_host_init() are in a wrapper function with
nothing else now. Let's remove the pointless extra layer.

Link: https://lore.kernel.org/r/20201105211159.1814485-14-robh@kernel.org
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Murali Karicheri <m-karicheri2@ti.com>
Cc: Minghuan Lian <minghuan.Lian@nxp.com>
Cc: Mingkai Hu <mingkai.hu@nxp.com>
Cc: Roy Zang <roy.zang@nxp.com>
Cc: Yue Wang <yue.wang@Amlogic.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Jonathan Chocron <jonnyc@amazon.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Xiaowei Song <songxiaowei@hisilicon.com>
Cc: Binghui Wang <wangbinghui@hisilicon.com>
Cc: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-amlogic@lists.infradead.org
Cc: linux-arm-kernel@axis.com

authored by

Rob Herring and committed by
Lorenzo Pieralisi
60f5b73f b9ac0f9d

+17 -149
+2 -20
drivers/pci/controller/dwc/pci-imx6.c
··· 842 842 .host_init = imx6_pcie_host_init, 843 843 }; 844 844 845 - static int imx6_add_pcie_port(struct imx6_pcie *imx6_pcie, 846 - struct platform_device *pdev) 847 - { 848 - struct dw_pcie *pci = imx6_pcie->pci; 849 - struct pcie_port *pp = &pci->pp; 850 - struct device *dev = &pdev->dev; 851 - int ret; 852 - 853 - pp->ops = &imx6_pcie_host_ops; 854 - 855 - ret = dw_pcie_host_init(pp); 856 - if (ret) { 857 - dev_err(dev, "failed to initialize host\n"); 858 - return ret; 859 - } 860 - 861 - return 0; 862 - } 863 - 864 845 static const struct dw_pcie_ops dw_pcie_ops = { 865 846 .start_link = imx6_pcie_start_link, 866 847 }; ··· 986 1005 987 1006 pci->dev = dev; 988 1007 pci->ops = &dw_pcie_ops; 1008 + pci->pp.ops = &imx6_pcie_host_ops; 989 1009 990 1010 imx6_pcie->pci = pci; 991 1011 imx6_pcie->drvdata = of_device_get_match_data(dev); ··· 1136 1154 if (ret) 1137 1155 return ret; 1138 1156 1139 - ret = imx6_add_pcie_port(imx6_pcie, pdev); 1157 + ret = dw_pcie_host_init(&pci->pp); 1140 1158 if (ret < 0) 1141 1159 return ret; 1142 1160
+1 -18
drivers/pci/controller/dwc/pci-keystone.c
··· 844 844 return ks_pcie_handle_error_irq(ks_pcie); 845 845 } 846 846 847 - static int __init ks_pcie_add_pcie_port(struct keystone_pcie *ks_pcie, 848 - struct platform_device *pdev) 849 - { 850 - struct dw_pcie *pci = ks_pcie->pci; 851 - struct pcie_port *pp = &pci->pp; 852 - struct device *dev = &pdev->dev; 853 - int ret; 854 - 855 - ret = dw_pcie_host_init(pp); 856 - if (ret) { 857 - dev_err(dev, "failed to initialize host\n"); 858 - return ret; 859 - } 860 - 861 - return 0; 862 - } 863 - 864 847 static void ks_pcie_am654_write_dbi2(struct dw_pcie *pci, void __iomem *base, 865 848 u32 reg, size_t size, u32 val) 866 849 { ··· 1238 1255 } 1239 1256 1240 1257 pci->pp.ops = host_ops; 1241 - ret = ks_pcie_add_pcie_port(ks_pcie, pdev); 1258 + ret = dw_pcie_host_init(&pci->pp); 1242 1259 if (ret < 0) 1243 1260 goto err_get_sync; 1244 1261 break;
+2 -24
drivers/pci/controller/dwc/pci-layerscape.c
··· 232 232 { }, 233 233 }; 234 234 235 - static int __init ls_add_pcie_port(struct ls_pcie *pcie) 236 - { 237 - struct dw_pcie *pci = pcie->pci; 238 - struct pcie_port *pp = &pci->pp; 239 - struct device *dev = pci->dev; 240 - int ret; 241 - 242 - pp->ops = pcie->drvdata->ops; 243 - 244 - ret = dw_pcie_host_init(pp); 245 - if (ret) { 246 - dev_err(dev, "failed to initialize host\n"); 247 - return ret; 248 - } 249 - 250 - return 0; 251 - } 252 - 253 235 static int __init ls_pcie_probe(struct platform_device *pdev) 254 236 { 255 237 struct device *dev = &pdev->dev; 256 238 struct dw_pcie *pci; 257 239 struct ls_pcie *pcie; 258 240 struct resource *dbi_base; 259 - int ret; 260 241 261 242 pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); 262 243 if (!pcie) ··· 251 270 252 271 pci->dev = dev; 253 272 pci->ops = pcie->drvdata->dw_pcie_ops; 273 + pci->pp.ops = pcie->drvdata->ops; 254 274 255 275 pcie->pci = pci; 256 276 ··· 267 285 268 286 platform_set_drvdata(pdev, pcie); 269 287 270 - ret = ls_add_pcie_port(pcie); 271 - if (ret < 0) 272 - return ret; 273 - 274 - return 0; 288 + return dw_pcie_host_init(&pci->pp); 275 289 } 276 290 277 291 static struct platform_driver ls_pcie_driver = {
+2 -20
drivers/pci/controller/dwc/pci-meson.c
··· 387 387 .host_init = meson_pcie_host_init, 388 388 }; 389 389 390 - static int meson_add_pcie_port(struct meson_pcie *mp, 391 - struct platform_device *pdev) 392 - { 393 - struct dw_pcie *pci = &mp->pci; 394 - struct pcie_port *pp = &pci->pp; 395 - struct device *dev = &pdev->dev; 396 - int ret; 397 - 398 - pp->ops = &meson_pcie_host_ops; 399 - 400 - ret = dw_pcie_host_init(pp); 401 - if (ret) { 402 - dev_err(dev, "failed to initialize host\n"); 403 - return ret; 404 - } 405 - 406 - return 0; 407 - } 408 - 409 390 static const struct dw_pcie_ops dw_pcie_ops = { 410 391 .link_up = meson_pcie_link_up, 411 392 .start_link = meson_pcie_start_link, ··· 406 425 pci = &mp->pci; 407 426 pci->dev = dev; 408 427 pci->ops = &dw_pcie_ops; 428 + pci->pp.ops = &meson_pcie_host_ops; 409 429 pci->num_lanes = 1; 410 430 411 431 mp->phy = devm_phy_get(dev, "pcie"); ··· 453 471 454 472 platform_set_drvdata(pdev, mp); 455 473 456 - ret = meson_add_pcie_port(mp, pdev); 474 + ret = dw_pcie_host_init(&pci->pp); 457 475 if (ret < 0) { 458 476 dev_err(dev, "Add PCIe port failed, %d\n", ret); 459 477 goto err_phy;
+2 -18
drivers/pci/controller/dwc/pcie-al.c
··· 322 322 .host_init = al_pcie_host_init, 323 323 }; 324 324 325 - static int al_add_pcie_port(struct pcie_port *pp, 326 - struct platform_device *pdev) 327 - { 328 - struct device *dev = &pdev->dev; 329 - int ret; 330 - 331 - pp->ops = &al_pcie_host_ops; 332 - 333 - ret = dw_pcie_host_init(pp); 334 - if (ret) { 335 - dev_err(dev, "failed to initialize host\n"); 336 - return ret; 337 - } 338 - 339 - return 0; 340 - } 341 - 342 325 static const struct dw_pcie_ops dw_pcie_ops = { 343 326 }; 344 327 ··· 343 360 344 361 pci->dev = dev; 345 362 pci->ops = &dw_pcie_ops; 363 + pci->pp.ops = &al_pcie_host_ops; 346 364 347 365 al_pcie->pci = pci; 348 366 al_pcie->dev = dev; ··· 368 384 369 385 platform_set_drvdata(pdev, al_pcie); 370 386 371 - return al_add_pcie_port(&pci->pp, pdev); 387 + return dw_pcie_host_init(&pci->pp); 372 388 } 373 389 374 390 static const struct of_device_id al_pcie_of_match[] = {
+3 -20
drivers/pci/controller/dwc/pcie-artpec6.c
··· 336 336 .host_init = artpec6_pcie_host_init, 337 337 }; 338 338 339 - static int artpec6_add_pcie_port(struct artpec6_pcie *artpec6_pcie, 340 - struct platform_device *pdev) 341 - { 342 - struct dw_pcie *pci = artpec6_pcie->pci; 343 - struct pcie_port *pp = &pci->pp; 344 - struct device *dev = pci->dev; 345 - int ret; 346 - 347 - pp->ops = &artpec6_pcie_host_ops; 348 - 349 - ret = dw_pcie_host_init(pp); 350 - if (ret) { 351 - dev_err(dev, "failed to initialize host\n"); 352 - return ret; 353 - } 354 - 355 - return 0; 356 - } 357 - 358 339 static void artpec6_pcie_ep_init(struct dw_pcie_ep *ep) 359 340 { 360 341 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); ··· 426 445 if (!IS_ENABLED(CONFIG_PCIE_ARTPEC6_HOST)) 427 446 return -ENODEV; 428 447 429 - ret = artpec6_add_pcie_port(artpec6_pcie, pdev); 448 + pci->pp.ops = &artpec6_pcie_host_ops; 449 + 450 + ret = dw_pcie_host_init(&pci->pp); 430 451 if (ret < 0) 431 452 return ret; 432 453 break;
+2 -9
drivers/pci/controller/dwc/pcie-kirin.c
··· 419 419 .host_init = kirin_pcie_host_init, 420 420 }; 421 421 422 - static int kirin_add_pcie_port(struct dw_pcie *pci, 423 - struct platform_device *pdev) 424 - { 425 - pci->pp.ops = &kirin_pcie_host_ops; 426 - 427 - return dw_pcie_host_init(&pci->pp); 428 - } 429 - 430 422 static int kirin_pcie_probe(struct platform_device *pdev) 431 423 { 432 424 struct device *dev = &pdev->dev; ··· 441 449 442 450 pci->dev = dev; 443 451 pci->ops = &kirin_dw_pcie_ops; 452 + pci->pp.ops = &kirin_pcie_host_ops; 444 453 kirin_pcie->pci = pci; 445 454 446 455 ret = kirin_pcie_get_clk(kirin_pcie, pdev); ··· 467 474 468 475 platform_set_drvdata(pdev, kirin_pcie); 469 476 470 - return kirin_add_pcie_port(pci, pdev); 477 + return dw_pcie_host_init(&pci->pp); 471 478 } 472 479 473 480 static const struct of_device_id kirin_pcie_match[] = {
+3 -20
drivers/pci/controller/dwc/pcie-uniphier.c
··· 321 321 .host_init = uniphier_pcie_host_init, 322 322 }; 323 323 324 - static int uniphier_add_pcie_port(struct uniphier_pcie_priv *priv, 325 - struct platform_device *pdev) 326 - { 327 - struct dw_pcie *pci = &priv->pci; 328 - struct pcie_port *pp = &pci->pp; 329 - struct device *dev = &pdev->dev; 330 - int ret; 331 - 332 - pp->ops = &uniphier_pcie_host_ops; 333 - 334 - ret = dw_pcie_host_init(pp); 335 - if (ret) { 336 - dev_err(dev, "Failed to initialize host (%d)\n", ret); 337 - return ret; 338 - } 339 - 340 - return 0; 341 - } 342 - 343 324 static int uniphier_pcie_host_enable(struct uniphier_pcie_priv *priv) 344 325 { 345 326 int ret; ··· 396 415 if (ret) 397 416 return ret; 398 417 399 - return uniphier_add_pcie_port(priv, pdev); 418 + priv->pci.pp.ops = &uniphier_pcie_host_ops; 419 + 420 + return dw_pcie_host_init(&priv->pci.pp); 400 421 } 401 422 402 423 static const struct of_device_id uniphier_pcie_match[] = {