032-PCI-iproc-Delete-unnecessary-checks-before-phy-calls.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From 93972d18bbaba6f34e21742400b6e7461edc4837 Mon Sep 17 00:00:00 2001
  2. From: Markus Elfring <elfring@users.sourceforge.net>
  3. Date: Sun, 28 Jun 2015 16:42:04 +0200
  4. Subject: [PATCH] PCI: iproc: Delete unnecessary checks before phy calls
  5. The functions phy_exit() and phy_power_off() test whether their argument is
  6. NULL and then return immediately. Thus the test around the calls is not
  7. needed.
  8. This issue was detected by using the Coccinelle software.
  9. [bhelgaas: also phy_init() and phy_power_on(), as Ray Jui suggested]
  10. [bhelgaas: also remove tests in iproc_pcie_remove()]
  11. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
  12. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
  13. Reviewed-by: Ray Jui <rjui@broadcom.com>
  14. ---
  15. drivers/pci/host/pcie-iproc.c | 34 +++++++++++++---------------------
  16. 1 file changed, 13 insertions(+), 21 deletions(-)
  17. --- a/drivers/pci/host/pcie-iproc.c
  18. +++ b/drivers/pci/host/pcie-iproc.c
  19. @@ -191,19 +191,16 @@ int iproc_pcie_setup(struct iproc_pcie *
  20. if (!pcie || !pcie->dev || !pcie->base)
  21. return -EINVAL;
  22. - if (pcie->phy) {
  23. - ret = phy_init(pcie->phy);
  24. - if (ret) {
  25. - dev_err(pcie->dev, "unable to initialize PCIe PHY\n");
  26. - return ret;
  27. - }
  28. -
  29. - ret = phy_power_on(pcie->phy);
  30. - if (ret) {
  31. - dev_err(pcie->dev, "unable to power on PCIe PHY\n");
  32. - goto err_exit_phy;
  33. - }
  34. + ret = phy_init(pcie->phy);
  35. + if (ret) {
  36. + dev_err(pcie->dev, "unable to initialize PCIe PHY\n");
  37. + return ret;
  38. + }
  39. + ret = phy_power_on(pcie->phy);
  40. + if (ret) {
  41. + dev_err(pcie->dev, "unable to power on PCIe PHY\n");
  42. + goto err_exit_phy;
  43. }
  44. iproc_pcie_reset(pcie);
  45. @@ -239,12 +236,9 @@ err_rm_root_bus:
  46. pci_remove_root_bus(bus);
  47. err_power_off_phy:
  48. - if (pcie->phy)
  49. - phy_power_off(pcie->phy);
  50. + phy_power_off(pcie->phy);
  51. err_exit_phy:
  52. - if (pcie->phy)
  53. - phy_exit(pcie->phy);
  54. -
  55. + phy_exit(pcie->phy);
  56. return ret;
  57. }
  58. EXPORT_SYMBOL(iproc_pcie_setup);
  59. @@ -254,10 +248,8 @@ int iproc_pcie_remove(struct iproc_pcie
  60. pci_stop_root_bus(pcie->root_bus);
  61. pci_remove_root_bus(pcie->root_bus);
  62. - if (pcie->phy) {
  63. - phy_power_off(pcie->phy);
  64. - phy_exit(pcie->phy);
  65. - }
  66. + phy_power_off(pcie->phy);
  67. + phy_exit(pcie->phy);
  68. return 0;
  69. }