0052-PCI-designware-Simplify-control-flow.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. From 610b32220391c9d271290bdf8f2b8fe1cf8da9a0 Mon Sep 17 00:00:00 2001
  2. From: Bjorn Helgaas <bhelgaas@google.com>
  3. Date: Tue, 5 Jan 2016 15:48:11 -0600
  4. Subject: [PATCH 52/70] PCI: designware: Simplify control flow
  5. Return values immediately when possible to simplify the control flow.
  6. No functional change intended. Folded in unused variable removal as
  7. pointed out by Fabio Estevam <fabio.estevam@nxp.com>, Arnd Bergmann
  8. <arnd@arndb.de>, and Thierry Reding <thierry.reding@gmail.com>.
  9. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
  10. Acked-by: Pratyush Anand <pratyush.anand@gmail.com>
  11. ---
  12. drivers/pci/host/pcie-designware.c | 54 ++++++++++++------------------------
  13. 1 file changed, 18 insertions(+), 36 deletions(-)
  14. --- a/drivers/pci/host/pcie-designware.c
  15. +++ b/drivers/pci/host/pcie-designware.c
  16. @@ -128,27 +128,19 @@ static inline void dw_pcie_writel_rc(str
  17. static int dw_pcie_rd_own_conf(struct pcie_port *pp, int where, int size,
  18. u32 *val)
  19. {
  20. - int ret;
  21. -
  22. if (pp->ops->rd_own_conf)
  23. - ret = pp->ops->rd_own_conf(pp, where, size, val);
  24. - else
  25. - ret = dw_pcie_cfg_read(pp->dbi_base + where, size, val);
  26. + return pp->ops->rd_own_conf(pp, where, size, val);
  27. - return ret;
  28. + return dw_pcie_cfg_read(pp->dbi_base + where, size, val);
  29. }
  30. static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,
  31. u32 val)
  32. {
  33. - int ret;
  34. -
  35. if (pp->ops->wr_own_conf)
  36. - ret = pp->ops->wr_own_conf(pp, where, size, val);
  37. - else
  38. - ret = dw_pcie_cfg_write(pp->dbi_base + where, size, val);
  39. + return pp->ops->wr_own_conf(pp, where, size, val);
  40. - return ret;
  41. + return dw_pcie_cfg_write(pp->dbi_base + where, size, val);
  42. }
  43. static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index,
  44. @@ -392,8 +384,8 @@ int dw_pcie_link_up(struct pcie_port *pp
  45. {
  46. if (pp->ops->link_up)
  47. return pp->ops->link_up(pp);
  48. - else
  49. - return 0;
  50. +
  51. + return 0;
  52. }
  53. static int dw_pcie_msi_map(struct irq_domain *domain, unsigned int irq,
  54. @@ -666,46 +658,36 @@ static int dw_pcie_rd_conf(struct pci_bu
  55. int size, u32 *val)
  56. {
  57. struct pcie_port *pp = bus->sysdata;
  58. - int ret;
  59. if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0) {
  60. *val = 0xffffffff;
  61. return PCIBIOS_DEVICE_NOT_FOUND;
  62. }
  63. - if (bus->number != pp->root_bus_nr)
  64. - if (pp->ops->rd_other_conf)
  65. - ret = pp->ops->rd_other_conf(pp, bus, devfn,
  66. - where, size, val);
  67. - else
  68. - ret = dw_pcie_rd_other_conf(pp, bus, devfn,
  69. - where, size, val);
  70. - else
  71. - ret = dw_pcie_rd_own_conf(pp, where, size, val);
  72. + if (bus->number == pp->root_bus_nr)
  73. + return dw_pcie_rd_own_conf(pp, where, size, val);
  74. - return ret;
  75. + if (pp->ops->rd_other_conf)
  76. + return pp->ops->rd_other_conf(pp, bus, devfn, where, size, val);
  77. +
  78. + return dw_pcie_rd_other_conf(pp, bus, devfn, where, size, val);
  79. }
  80. static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
  81. int where, int size, u32 val)
  82. {
  83. struct pcie_port *pp = bus->sysdata;
  84. - int ret;
  85. if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0)
  86. return PCIBIOS_DEVICE_NOT_FOUND;
  87. - if (bus->number != pp->root_bus_nr)
  88. - if (pp->ops->wr_other_conf)
  89. - ret = pp->ops->wr_other_conf(pp, bus, devfn,
  90. - where, size, val);
  91. - else
  92. - ret = dw_pcie_wr_other_conf(pp, bus, devfn,
  93. - where, size, val);
  94. - else
  95. - ret = dw_pcie_wr_own_conf(pp, where, size, val);
  96. + if (bus->number == pp->root_bus_nr)
  97. + return dw_pcie_wr_own_conf(pp, where, size, val);
  98. - return ret;
  99. + if (pp->ops->wr_other_conf)
  100. + return pp->ops->wr_other_conf(pp, bus, devfn, where, size, val);
  101. +
  102. + return dw_pcie_wr_other_conf(pp, bus, devfn, where, size, val);
  103. }
  104. static struct pci_ops dw_pcie_ops = {