Patchwork [v3,2/3] pci: remove redundant pci_dev_get/put() on kobject (un)register

login
register
mail settings
Submitter Veaceslav Falico
Date Oct. 29, 2013, 10:30 a.m.
Message ID <1383042632-7102-3-git-send-email-vfalico@redhat.com>
Download mbox | patch
Permalink /patch/286778/
State Not Applicable
Headers show

Comments

Veaceslav Falico - Oct. 29, 2013, 10:30 a.m.
Currently we're pci_dev_get/put()-ing pci device on every kobject
creation/removal. It's useless per se - the kobject is part of the device
itself, so it should be removed when there are no users of the pdev, and is
not a user of it.

CC: Bjorn Helgaas <bhelgaas@google.com>
CC: Neil Horman <nhorman@tuxdriver.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: linux-pci@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
 drivers/pci/msi.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
Neil Horman - Oct. 29, 2013, 11:34 a.m.
On Tue, Oct 29, 2013 at 11:30:31AM +0100, Veaceslav Falico wrote:
> Currently we're pci_dev_get/put()-ing pci device on every kobject
> creation/removal. It's useless per se - the kobject is part of the device
> itself, so it should be removed when there are no users of the pdev, and is
> not a user of it.
> 
> CC: Bjorn Helgaas <bhelgaas@google.com>
> CC: Neil Horman <nhorman@tuxdriver.com>
> CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> CC: linux-pci@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>

> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 5d70f49..0771508 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -511,7 +511,6 @@  static void msi_kobj_release(struct kobject *kobj)
 {
 	struct msi_desc *entry = to_msi_desc(kobj);
 
-	pci_dev_put(entry->dev);
 	kfree(entry);
 }
 
@@ -534,13 +533,10 @@  static int populate_msi_sysfs(struct pci_dev *pdev)
 	list_for_each_entry(entry, &pdev->msi_list, list) {
 		kobj = &entry->kobj;
 		kobj->kset = pdev->msi_kset;
-		pci_dev_get(pdev);
 		ret = kobject_init_and_add(kobj, &msi_irq_ktype, NULL,
 				     "%u", entry->irq);
-		if (ret) {
-			pci_dev_put(pdev);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;