* [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls [not found] ` <5317A59D.4@users.sourceforge.net> @ 2014-11-02 15:12 ` SF Markus Elfring 2014-11-11 4:07 ` Bjorn Helgaas 2014-11-20 16:47 ` [PATCH 1/1] PCI: hotplug: Deletion of an unnecessary check before the function call "pci_dev_put" SF Markus Elfring 2015-06-28 14:52 ` [PATCH] PCI-iproc: Delete unnecessary checks before two function calls SF Markus Elfring 2 siblings, 1 reply; 10+ messages in thread From: SF Markus Elfring @ 2014-11-02 15:12 UTC (permalink / raw) To: Bjorn Helgaas, Boris Ostrovsky, David Vrabel, Konrad Rzeszutek Wilk, Len Brown, Rafael J. Wysocki, linux-pci Cc: linux-acpi, linux-kernel, xen-devel, kernel-janitors, trivial, Coccinelle The functions pci_dev_put(), pci_pme_wakeup_bus() and put_device() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/pci/pci-acpi.c | 3 +-- drivers/pci/probe.c | 3 +-- drivers/pci/search.c | 3 +-- drivers/pci/xen-pcifront.c | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 37263b0..a8fe5de 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -60,8 +60,7 @@ static void pci_acpi_wake_dev(struct work_struct *work) pci_wakeup_event(pci_dev); pm_runtime_resume(&pci_dev->dev); - if (pci_dev->subordinate) - pci_pme_wakeup_bus(pci_dev->subordinate); + pci_pme_wakeup_bus(pci_dev->subordinate); } /** diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4170113..e93f16e 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -86,8 +86,7 @@ static void release_pcibus_dev(struct device *dev) { struct pci_bus *pci_bus = to_pci_bus(dev); - if (pci_bus->bridge) - put_device(pci_bus->bridge); + put_device(pci_bus->bridge); pci_bus_remove_resources(pci_bus); pci_release_bus_of_node(pci_bus); kfree(pci_bus); diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 827ad83..2d806bd 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c @@ -305,8 +305,7 @@ static struct pci_dev *pci_get_dev_by_id(const struct pci_device_id *id, match_pci_dev_by_id); if (dev) pdev = to_pci_dev(dev); - if (from) - pci_dev_put(from); + pci_dev_put(from); return pdev; } diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index 53df39a..46664cc 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c @@ -596,8 +596,7 @@ static pci_ers_result_t pcifront_common_process(int cmd, pcidev = pci_get_bus_and_slot(bus, devfn); if (!pcidev || !pcidev->driver) { dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n"); - if (pcidev) - pci_dev_put(pcidev); + pci_dev_put(pcidev); return result; } pdrv = pcidev->driver; -- 2.1.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls 2014-11-02 15:12 ` [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls SF Markus Elfring @ 2014-11-11 4:07 ` Bjorn Helgaas 0 siblings, 0 replies; 10+ messages in thread From: Bjorn Helgaas @ 2014-11-11 4:07 UTC (permalink / raw) To: SF Markus Elfring Cc: Boris Ostrovsky, David Vrabel, Konrad Rzeszutek Wilk, Len Brown, Rafael J. Wysocki, linux-pci, linux-acpi, linux-kernel, xen-devel, kernel-janitors, trivial, Coccinelle On Sun, Nov 02, 2014 at 04:12:30PM +0100, SF Markus Elfring wrote: > The functions pci_dev_put(), pci_pme_wakeup_bus() and put_device() test > whether their argument is NULL and then return immediately. Thus the test > around the call is not needed. > > This issue was detected by using the Coccinelle software. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Applied to pci/misc for v3.19, thanks! > --- > drivers/pci/pci-acpi.c | 3 +-- > drivers/pci/probe.c | 3 +-- > drivers/pci/search.c | 3 +-- > drivers/pci/xen-pcifront.c | 3 +-- > 4 files changed, 4 insertions(+), 8 deletions(-) > > diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c > index 37263b0..a8fe5de 100644 > --- a/drivers/pci/pci-acpi.c > +++ b/drivers/pci/pci-acpi.c > @@ -60,8 +60,7 @@ static void pci_acpi_wake_dev(struct work_struct *work) > pci_wakeup_event(pci_dev); > pm_runtime_resume(&pci_dev->dev); > > - if (pci_dev->subordinate) > - pci_pme_wakeup_bus(pci_dev->subordinate); > + pci_pme_wakeup_bus(pci_dev->subordinate); > } > > /** > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c > index 4170113..e93f16e 100644 > --- a/drivers/pci/probe.c > +++ b/drivers/pci/probe.c > @@ -86,8 +86,7 @@ static void release_pcibus_dev(struct device *dev) > { > struct pci_bus *pci_bus = to_pci_bus(dev); > > - if (pci_bus->bridge) > - put_device(pci_bus->bridge); > + put_device(pci_bus->bridge); > pci_bus_remove_resources(pci_bus); > pci_release_bus_of_node(pci_bus); > kfree(pci_bus); > diff --git a/drivers/pci/search.c b/drivers/pci/search.c > index 827ad83..2d806bd 100644 > --- a/drivers/pci/search.c > +++ b/drivers/pci/search.c > @@ -305,8 +305,7 @@ static struct pci_dev *pci_get_dev_by_id(const struct > pci_device_id *id, > match_pci_dev_by_id); > if (dev) > pdev = to_pci_dev(dev); > - if (from) > - pci_dev_put(from); > + pci_dev_put(from); > return pdev; > } > > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c > index 53df39a..46664cc 100644 > --- a/drivers/pci/xen-pcifront.c > +++ b/drivers/pci/xen-pcifront.c > @@ -596,8 +596,7 @@ static pci_ers_result_t pcifront_common_process(int cmd, > pcidev = pci_get_bus_and_slot(bus, devfn); > if (!pcidev || !pcidev->driver) { > dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n"); > - if (pcidev) > - pci_dev_put(pcidev); > + pci_dev_put(pcidev); > return result; > } > pdrv = pcidev->driver; > -- > 2.1.3 > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/1] PCI: hotplug: Deletion of an unnecessary check before the function call "pci_dev_put" [not found] ` <5317A59D.4@users.sourceforge.net> 2014-11-02 15:12 ` [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls SF Markus Elfring @ 2014-11-20 16:47 ` SF Markus Elfring 2014-12-11 0:06 ` Bjorn Helgaas 2015-06-28 14:52 ` [PATCH] PCI-iproc: Delete unnecessary checks before two function calls SF Markus Elfring 2 siblings, 1 reply; 10+ messages in thread From: SF Markus Elfring @ 2014-11-20 16:47 UTC (permalink / raw) To: Bjorn Helgaas, Scott Murray, linux-pci Cc: LKML, kernel-janitors, Julia Lawall From: Markus Elfring <elfring@users.sourceforge.net> Date: Thu, 20 Nov 2014 17:42:23 +0100 The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/pci/hotplug/cpci_hotplug_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c index e09cf78..82c969b 100644 --- a/drivers/pci/hotplug/cpci_hotplug_core.c +++ b/drivers/pci/hotplug/cpci_hotplug_core.c @@ -211,8 +211,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot) kfree(slot->hotplug_slot->info); kfree(slot->hotplug_slot); - if (slot->dev) - pci_dev_put(slot->dev); + pci_dev_put(slot->dev); kfree(slot); } -- 2.1.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/1] PCI: hotplug: Deletion of an unnecessary check before the function call "pci_dev_put" 2014-11-20 16:47 ` [PATCH 1/1] PCI: hotplug: Deletion of an unnecessary check before the function call "pci_dev_put" SF Markus Elfring @ 2014-12-11 0:06 ` Bjorn Helgaas 0 siblings, 0 replies; 10+ messages in thread From: Bjorn Helgaas @ 2014-12-11 0:06 UTC (permalink / raw) To: SF Markus Elfring Cc: Scott Murray, linux-pci, LKML, kernel-janitors, Julia Lawall On Thu, Nov 20, 2014 at 05:47:29PM +0100, SF Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Thu, 20 Nov 2014 17:42:23 +0100 > > The pci_dev_put() function tests whether its argument is NULL and then > returns immediately. Thus the test around the call is not needed. > > This issue was detected by using the Coccinelle software. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Applied to next-pci/misc for v3.19, thanks. This branch will be rebased when v3.19-rc1 is released. Bjorn > --- > drivers/pci/hotplug/cpci_hotplug_core.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c > index e09cf78..82c969b 100644 > --- a/drivers/pci/hotplug/cpci_hotplug_core.c > +++ b/drivers/pci/hotplug/cpci_hotplug_core.c > @@ -211,8 +211,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot) > > kfree(slot->hotplug_slot->info); > kfree(slot->hotplug_slot); > - if (slot->dev) > - pci_dev_put(slot->dev); > + pci_dev_put(slot->dev); > kfree(slot); > } > > -- > 2.1.3 > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] PCI-iproc: Delete unnecessary checks before two function calls [not found] ` <5317A59D.4@users.sourceforge.net> 2014-11-02 15:12 ` [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls SF Markus Elfring 2014-11-20 16:47 ` [PATCH 1/1] PCI: hotplug: Deletion of an unnecessary check before the function call "pci_dev_put" SF Markus Elfring @ 2015-06-28 14:52 ` SF Markus Elfring 2015-06-29 16:45 ` Ray Jui 2015-07-14 20:10 ` Bjorn Helgaas 2 siblings, 2 replies; 10+ messages in thread From: SF Markus Elfring @ 2015-06-28 14:52 UTC (permalink / raw) To: Bjorn Helgaas, Ray Jui, Scott Branden, linux-pci, linux-arm-kernel, bcm-kernel-feedback-list Cc: LKML, kernel-janitors, Hauke Mehrtens, Julia Lawall From: Markus Elfring <elfring@users.sourceforge.net> Date: Sun, 28 Jun 2015 16:42:04 +0200 The functions phy_exit() and phy_power_off() test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/pci/host/pcie-iproc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c index d77481e..f875821 100644 --- a/drivers/pci/host/pcie-iproc.c +++ b/drivers/pci/host/pcie-iproc.c @@ -239,12 +239,9 @@ err_rm_root_bus: pci_remove_root_bus(bus); err_power_off_phy: - if (pcie->phy) - phy_power_off(pcie->phy); + phy_power_off(pcie->phy); err_exit_phy: - if (pcie->phy) - phy_exit(pcie->phy); - + phy_exit(pcie->phy); return ret; } EXPORT_SYMBOL(iproc_pcie_setup); -- 2.4.4 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] PCI-iproc: Delete unnecessary checks before two function calls 2015-06-28 14:52 ` [PATCH] PCI-iproc: Delete unnecessary checks before two function calls SF Markus Elfring @ 2015-06-29 16:45 ` Ray Jui 2015-07-14 20:10 ` Bjorn Helgaas 1 sibling, 0 replies; 10+ messages in thread From: Ray Jui @ 2015-06-29 16:45 UTC (permalink / raw) To: SF Markus Elfring, Bjorn Helgaas, Scott Branden, linux-pci, linux-arm-kernel, bcm-kernel-feedback-list Cc: LKML, kernel-janitors, Hauke Mehrtens, Julia Lawall Hi Markus, On 6/28/2015 7:52 AM, SF Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Sun, 28 Jun 2015 16:42:04 +0200 > > The functions phy_exit() and phy_power_off() test whether their argument > is NULL and then return immediately. > Thus the test around the calls is not needed. > > This issue was detected by using the Coccinelle software. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > --- > drivers/pci/host/pcie-iproc.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c > index d77481e..f875821 100644 > --- a/drivers/pci/host/pcie-iproc.c > +++ b/drivers/pci/host/pcie-iproc.c > @@ -239,12 +239,9 @@ err_rm_root_bus: > pci_remove_root_bus(bus); > > err_power_off_phy: > - if (pcie->phy) > - phy_power_off(pcie->phy); > + phy_power_off(pcie->phy); > err_exit_phy: > - if (pcie->phy) > - phy_exit(pcie->phy); > - > + phy_exit(pcie->phy); > return ret; > } > EXPORT_SYMBOL(iproc_pcie_setup); > Thanks for catching this. Could you please help to make similar changes to both phy_init and phy_power_on calls in the driver, to make it consistent? Thanks, Ray ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] PCI-iproc: Delete unnecessary checks before two function calls 2015-06-28 14:52 ` [PATCH] PCI-iproc: Delete unnecessary checks before two function calls SF Markus Elfring 2015-06-29 16:45 ` Ray Jui @ 2015-07-14 20:10 ` Bjorn Helgaas 2015-07-14 20:23 ` Ray Jui 1 sibling, 1 reply; 10+ messages in thread From: Bjorn Helgaas @ 2015-07-14 20:10 UTC (permalink / raw) To: SF Markus Elfring Cc: Ray Jui, Scott Branden, linux-pci, linux-arm-kernel, bcm-kernel-feedback-list, LKML, kernel-janitors, Hauke Mehrtens, Julia Lawall On Sun, Jun 28, 2015 at 04:52:16PM +0200, SF Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Sun, 28 Jun 2015 16:42:04 +0200 > > The functions phy_exit() and phy_power_off() test whether their argument > is NULL and then return immediately. > Thus the test around the calls is not needed. > > This issue was detected by using the Coccinelle software. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> I haven't seen a followup to Ray's review, but in the interest of making progress, I updated and applied the patch as appended. I also reviewed other phy_*() calls under drivers/pci, and they all look OK (with no unnecessary tests for NULL). This is on the pci/host-iproc branch for v4.3. > --- > drivers/pci/host/pcie-iproc.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c > index d77481e..f875821 100644 > --- a/drivers/pci/host/pcie-iproc.c > +++ b/drivers/pci/host/pcie-iproc.c > @@ -239,12 +239,9 @@ err_rm_root_bus: > pci_remove_root_bus(bus); > > err_power_off_phy: > - if (pcie->phy) > - phy_power_off(pcie->phy); > + phy_power_off(pcie->phy); > err_exit_phy: > - if (pcie->phy) > - phy_exit(pcie->phy); > - > + phy_exit(pcie->phy); > return ret; > } > EXPORT_SYMBOL(iproc_pcie_setup); > -- > 2.4.4 commit 55b5e16332eb9ffc1cbaf975585f4521417ab427 Author: Markus Elfring <elfring@users.sourceforge.net> Date: Sun Jun 28 16:42:04 2015 +0200 PCI: iproc: Delete unnecessary checks before phy calls The functions phy_exit() and phy_power_off() test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed. This issue was detected by using the Coccinelle software. [bhelgaas: also phy_init() and phy_power_on(), as Ray Jui suggested] [bhelgaas: also remove tests in iproc_pcie_remove()] Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c index d77481e..9a00dca 100644 --- a/drivers/pci/host/pcie-iproc.c +++ b/drivers/pci/host/pcie-iproc.c @@ -191,19 +191,16 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) if (!pcie || !pcie->dev || !pcie->base) return -EINVAL; - if (pcie->phy) { - ret = phy_init(pcie->phy); - if (ret) { - dev_err(pcie->dev, "unable to initialize PCIe PHY\n"); - return ret; - } - - ret = phy_power_on(pcie->phy); - if (ret) { - dev_err(pcie->dev, "unable to power on PCIe PHY\n"); - goto err_exit_phy; - } + ret = phy_init(pcie->phy); + if (ret) { + dev_err(pcie->dev, "unable to initialize PCIe PHY\n"); + return ret; + } + ret = phy_power_on(pcie->phy); + if (ret) { + dev_err(pcie->dev, "unable to power on PCIe PHY\n"); + goto err_exit_phy; } iproc_pcie_reset(pcie); @@ -239,12 +236,9 @@ err_rm_root_bus: pci_remove_root_bus(bus); err_power_off_phy: - if (pcie->phy) - phy_power_off(pcie->phy); + phy_power_off(pcie->phy); err_exit_phy: - if (pcie->phy) - phy_exit(pcie->phy); - + phy_exit(pcie->phy); return ret; } EXPORT_SYMBOL(iproc_pcie_setup); @@ -254,10 +248,8 @@ int iproc_pcie_remove(struct iproc_pcie *pcie) pci_stop_root_bus(pcie->root_bus); pci_remove_root_bus(pcie->root_bus); - if (pcie->phy) { - phy_power_off(pcie->phy); - phy_exit(pcie->phy); - } + phy_power_off(pcie->phy); + phy_exit(pcie->phy); return 0; } ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] PCI-iproc: Delete unnecessary checks before two function calls 2015-07-14 20:10 ` Bjorn Helgaas @ 2015-07-14 20:23 ` Ray Jui 2015-07-14 20:51 ` Bjorn Helgaas 0 siblings, 1 reply; 10+ messages in thread From: Ray Jui @ 2015-07-14 20:23 UTC (permalink / raw) To: Bjorn Helgaas, SF Markus Elfring Cc: Scott Branden, linux-pci, linux-arm-kernel, bcm-kernel-feedback-list, LKML, kernel-janitors, Hauke Mehrtens, Julia Lawall Hi Bjorn, On 7/14/2015 1:10 PM, Bjorn Helgaas wrote: > On Sun, Jun 28, 2015 at 04:52:16PM +0200, SF Markus Elfring wrote: >> From: Markus Elfring <elfring@users.sourceforge.net> >> Date: Sun, 28 Jun 2015 16:42:04 +0200 >> >> The functions phy_exit() and phy_power_off() test whether their argument >> is NULL and then return immediately. >> Thus the test around the calls is not needed. >> >> This issue was detected by using the Coccinelle software. >> >> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > > I haven't seen a followup to Ray's review, but in the interest of making > progress, I updated and applied the patch as appended. I also reviewed > other phy_*() calls under drivers/pci, and they all look OK (with no > unnecessary tests for NULL). > > This is on the pci/host-iproc branch for v4.3. > Hmmm....I searched my mailbox but cannot find an email with this patch (while I remember I reviewed and commented on the initial version of this patch). It must have gone into some sub-folder or deleted by me by accident. My bad. Nevertheless,the current patch looks good to me! Thanks, Ray >> --- >> drivers/pci/host/pcie-iproc.c | 7 ++----- >> 1 file changed, 2 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c >> index d77481e..f875821 100644 >> --- a/drivers/pci/host/pcie-iproc.c >> +++ b/drivers/pci/host/pcie-iproc.c >> @@ -239,12 +239,9 @@ err_rm_root_bus: >> pci_remove_root_bus(bus); >> >> err_power_off_phy: >> - if (pcie->phy) >> - phy_power_off(pcie->phy); >> + phy_power_off(pcie->phy); >> err_exit_phy: >> - if (pcie->phy) >> - phy_exit(pcie->phy); >> - >> + phy_exit(pcie->phy); >> return ret; >> } >> EXPORT_SYMBOL(iproc_pcie_setup); >> -- >> 2.4.4 > > commit 55b5e16332eb9ffc1cbaf975585f4521417ab427 > Author: Markus Elfring <elfring@users.sourceforge.net> > Date: Sun Jun 28 16:42:04 2015 +0200 > > PCI: iproc: Delete unnecessary checks before phy calls > > The functions phy_exit() and phy_power_off() test whether their argument is > NULL and then return immediately. Thus the test around the calls is not > needed. > > This issue was detected by using the Coccinelle software. > > [bhelgaas: also phy_init() and phy_power_on(), as Ray Jui suggested] > [bhelgaas: also remove tests in iproc_pcie_remove()] > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> > > diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c > index d77481e..9a00dca 100644 > --- a/drivers/pci/host/pcie-iproc.c > +++ b/drivers/pci/host/pcie-iproc.c > @@ -191,19 +191,16 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) > if (!pcie || !pcie->dev || !pcie->base) > return -EINVAL; > > - if (pcie->phy) { > - ret = phy_init(pcie->phy); > - if (ret) { > - dev_err(pcie->dev, "unable to initialize PCIe PHY\n"); > - return ret; > - } > - > - ret = phy_power_on(pcie->phy); > - if (ret) { > - dev_err(pcie->dev, "unable to power on PCIe PHY\n"); > - goto err_exit_phy; > - } > + ret = phy_init(pcie->phy); > + if (ret) { > + dev_err(pcie->dev, "unable to initialize PCIe PHY\n"); > + return ret; > + } > > + ret = phy_power_on(pcie->phy); > + if (ret) { > + dev_err(pcie->dev, "unable to power on PCIe PHY\n"); > + goto err_exit_phy; > } > > iproc_pcie_reset(pcie); > @@ -239,12 +236,9 @@ err_rm_root_bus: > pci_remove_root_bus(bus); > > err_power_off_phy: > - if (pcie->phy) > - phy_power_off(pcie->phy); > + phy_power_off(pcie->phy); > err_exit_phy: > - if (pcie->phy) > - phy_exit(pcie->phy); > - > + phy_exit(pcie->phy); > return ret; > } > EXPORT_SYMBOL(iproc_pcie_setup); > @@ -254,10 +248,8 @@ int iproc_pcie_remove(struct iproc_pcie *pcie) > pci_stop_root_bus(pcie->root_bus); > pci_remove_root_bus(pcie->root_bus); > > - if (pcie->phy) { > - phy_power_off(pcie->phy); > - phy_exit(pcie->phy); > - } > + phy_power_off(pcie->phy); > + phy_exit(pcie->phy); > > return 0; > } > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] PCI-iproc: Delete unnecessary checks before two function calls 2015-07-14 20:23 ` Ray Jui @ 2015-07-14 20:51 ` Bjorn Helgaas 2015-07-14 20:53 ` Ray Jui 0 siblings, 1 reply; 10+ messages in thread From: Bjorn Helgaas @ 2015-07-14 20:51 UTC (permalink / raw) To: Ray Jui Cc: SF Markus Elfring, Scott Branden, linux-pci, linux-arm-kernel, bcm-kernel-feedback-list, LKML, kernel-janitors, Hauke Mehrtens, Julia Lawall On Tue, Jul 14, 2015 at 01:23:23PM -0700, Ray Jui wrote: > Hi Bjorn, > > On 7/14/2015 1:10 PM, Bjorn Helgaas wrote: > > On Sun, Jun 28, 2015 at 04:52:16PM +0200, SF Markus Elfring wrote: > >> From: Markus Elfring <elfring@users.sourceforge.net> > >> Date: Sun, 28 Jun 2015 16:42:04 +0200 > >> > >> The functions phy_exit() and phy_power_off() test whether their argument > >> is NULL and then return immediately. > >> Thus the test around the calls is not needed. > >> > >> This issue was detected by using the Coccinelle software. > >> > >> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > > > > I haven't seen a followup to Ray's review, but in the interest of making > > progress, I updated and applied the patch as appended. I also reviewed > > other phy_*() calls under drivers/pci, and they all look OK (with no > > unnecessary tests for NULL). > > > > This is on the pci/host-iproc branch for v4.3. > > > > Hmmm....I searched my mailbox but cannot find an email with this patch > (while I remember I reviewed and commented on the initial version of > this patch). It must have gone into some sub-folder or deleted by me by > accident. My bad. > > Nevertheless,the current patch looks good to me! Thanks for checking it out! Can I add your Reviewed-by to the patch below? > > commit 55b5e16332eb9ffc1cbaf975585f4521417ab427 > > Author: Markus Elfring <elfring@users.sourceforge.net> > > Date: Sun Jun 28 16:42:04 2015 +0200 > > > > PCI: iproc: Delete unnecessary checks before phy calls > > > > The functions phy_exit() and phy_power_off() test whether their argument is > > NULL and then return immediately. Thus the test around the calls is not > > needed. > > > > This issue was detected by using the Coccinelle software. > > > > [bhelgaas: also phy_init() and phy_power_on(), as Ray Jui suggested] > > [bhelgaas: also remove tests in iproc_pcie_remove()] > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > > Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> > > > > diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c > > index d77481e..9a00dca 100644 > > --- a/drivers/pci/host/pcie-iproc.c > > +++ b/drivers/pci/host/pcie-iproc.c > > @@ -191,19 +191,16 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) > > if (!pcie || !pcie->dev || !pcie->base) > > return -EINVAL; > > > > - if (pcie->phy) { > > - ret = phy_init(pcie->phy); > > - if (ret) { > > - dev_err(pcie->dev, "unable to initialize PCIe PHY\n"); > > - return ret; > > - } > > - > > - ret = phy_power_on(pcie->phy); > > - if (ret) { > > - dev_err(pcie->dev, "unable to power on PCIe PHY\n"); > > - goto err_exit_phy; > > - } > > + ret = phy_init(pcie->phy); > > + if (ret) { > > + dev_err(pcie->dev, "unable to initialize PCIe PHY\n"); > > + return ret; > > + } > > > > + ret = phy_power_on(pcie->phy); > > + if (ret) { > > + dev_err(pcie->dev, "unable to power on PCIe PHY\n"); > > + goto err_exit_phy; > > } > > > > iproc_pcie_reset(pcie); > > @@ -239,12 +236,9 @@ err_rm_root_bus: > > pci_remove_root_bus(bus); > > > > err_power_off_phy: > > - if (pcie->phy) > > - phy_power_off(pcie->phy); > > + phy_power_off(pcie->phy); > > err_exit_phy: > > - if (pcie->phy) > > - phy_exit(pcie->phy); > > - > > + phy_exit(pcie->phy); > > return ret; > > } > > EXPORT_SYMBOL(iproc_pcie_setup); > > @@ -254,10 +248,8 @@ int iproc_pcie_remove(struct iproc_pcie *pcie) > > pci_stop_root_bus(pcie->root_bus); > > pci_remove_root_bus(pcie->root_bus); > > > > - if (pcie->phy) { > > - phy_power_off(pcie->phy); > > - phy_exit(pcie->phy); > > - } > > + phy_power_off(pcie->phy); > > + phy_exit(pcie->phy); > > > > return 0; > > } > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] PCI-iproc: Delete unnecessary checks before two function calls 2015-07-14 20:51 ` Bjorn Helgaas @ 2015-07-14 20:53 ` Ray Jui 0 siblings, 0 replies; 10+ messages in thread From: Ray Jui @ 2015-07-14 20:53 UTC (permalink / raw) To: Bjorn Helgaas Cc: SF Markus Elfring, Scott Branden, linux-pci, linux-arm-kernel, bcm-kernel-feedback-list, LKML, kernel-janitors, Hauke Mehrtens, Julia Lawall On 7/14/2015 1:51 PM, Bjorn Helgaas wrote: > On Tue, Jul 14, 2015 at 01:23:23PM -0700, Ray Jui wrote: >> Hi Bjorn, >> >> On 7/14/2015 1:10 PM, Bjorn Helgaas wrote: >>> On Sun, Jun 28, 2015 at 04:52:16PM +0200, SF Markus Elfring wrote: >>>> From: Markus Elfring <elfring@users.sourceforge.net> >>>> Date: Sun, 28 Jun 2015 16:42:04 +0200 >>>> >>>> The functions phy_exit() and phy_power_off() test whether their argument >>>> is NULL and then return immediately. >>>> Thus the test around the calls is not needed. >>>> >>>> This issue was detected by using the Coccinelle software. >>>> >>>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> >>> >>> I haven't seen a followup to Ray's review, but in the interest of making >>> progress, I updated and applied the patch as appended. I also reviewed >>> other phy_*() calls under drivers/pci, and they all look OK (with no >>> unnecessary tests for NULL). >>> >>> This is on the pci/host-iproc branch for v4.3. >>> >> >> Hmmm....I searched my mailbox but cannot find an email with this patch >> (while I remember I reviewed and commented on the initial version of >> this patch). It must have gone into some sub-folder or deleted by me by >> accident. My bad. >> >> Nevertheless,the current patch looks good to me! > > Thanks for checking it out! Can I add your Reviewed-by to the patch below? > Sure thanks! Reviewed-by: Ray Jui <rjui@broadcom.com> Ray ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-07-14 20:53 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <5307CAA2.8060406@users.sourceforge.net> [not found] ` <alpine.DEB.2.02.1402212321410.2043@localhost6.localdomain6> [not found] ` <530A086E.8010901@users.sourceforge.net> [not found] ` <alpine.DEB.2.02.1402231635510.1985@localhost6.localdomain6> [not found] ` <530A72AA.3000601@users.sourceforge.net> [not found] ` <alpine.DEB.2.02.1402240658210.2090@localhost6.localdomain6> [not found] ` <530B5FB6.6010207@users.sourceforge.net> [not found] ` <alpine.DEB.2.10.1402241710370.2074@hadrien> [not found] ` <530C5E18.1020800@users.sourceforge.net> [not found] ` <alpine.DEB.2.10.1402251014170.2080@hadrien> [not found] ` <530CD2C4.4050903@users.sourceforge.net> [not found] ` <alpine.DEB.2.10.1402251840450.7035@hadrien> [not found] ` <530CF8FF.8080600@users.sourceforge.net> [not found] ` <alpine.DEB.2.02.1402252117150.2047@localhost6.localdomain6> [not found] ` <530DD06F.4090703@users.sourceforge.net> [not found] ` <alpine.DEB.2.02.1402262129250.2221@localhost6.localdomain6> [not found] ` <5317A59D.4@users.sourceforge.net> 2014-11-02 15:12 ` [PATCH 1/1] PCI: Deletion of unnecessary checks before three function calls SF Markus Elfring 2014-11-11 4:07 ` Bjorn Helgaas 2014-11-20 16:47 ` [PATCH 1/1] PCI: hotplug: Deletion of an unnecessary check before the function call "pci_dev_put" SF Markus Elfring 2014-12-11 0:06 ` Bjorn Helgaas 2015-06-28 14:52 ` [PATCH] PCI-iproc: Delete unnecessary checks before two function calls SF Markus Elfring 2015-06-29 16:45 ` Ray Jui 2015-07-14 20:10 ` Bjorn Helgaas 2015-07-14 20:23 ` Ray Jui 2015-07-14 20:51 ` Bjorn Helgaas 2015-07-14 20:53 ` Ray Jui
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).