mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>,
	Dave Young <hidave.darkstar@gmail.com>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 10/10] Driver core: Remove unneeded get_{device,driver}() calls.
Date: Sat,  2 Feb 2008 15:56:04 -0800	[thread overview]
Message-ID: <1201996564-21951-10-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20080202234357.GA21721@suse.de>

From: Cornelia Huck <cornelia.huck@de.ibm.com>

Driver core: Remove unneeded get_{device,driver}() calls.

Code trying to add/remove attributes must hold a reference to
the device resp. driver anyway, so let's remove those reference
count games.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Dave Young <hidave.darkstar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/base/core.c   |    8 ++------
 drivers/base/driver.c |    9 +++------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index a0cfda5..9c0070b 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -423,10 +423,8 @@ struct kset *devices_kset;
 int device_create_file(struct device *dev, struct device_attribute *attr)
 {
 	int error = 0;
-	if (get_device(dev)) {
+	if (dev)
 		error = sysfs_create_file(&dev->kobj, &attr->attr);
-		put_device(dev);
-	}
 	return error;
 }
 
@@ -437,10 +435,8 @@ int device_create_file(struct device *dev, struct device_attribute *attr)
  */
 void device_remove_file(struct device *dev, struct device_attribute *attr)
 {
-	if (get_device(dev)) {
+	if (dev)
 		sysfs_remove_file(&dev->kobj, &attr->attr);
-		put_device(dev);
-	}
 }
 
 /**
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index a35f041..ba75184 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -97,10 +97,9 @@ int driver_create_file(struct device_driver *drv,
 		       struct driver_attribute *attr)
 {
 	int error;
-	if (get_driver(drv)) {
+	if (drv)
 		error = sysfs_create_file(&drv->p->kobj, &attr->attr);
-		put_driver(drv);
-	} else
+	else
 		error = -EINVAL;
 	return error;
 }
@@ -114,10 +113,8 @@ EXPORT_SYMBOL_GPL(driver_create_file);
 void driver_remove_file(struct device_driver *drv,
 			struct driver_attribute *attr)
 {
-	if (get_driver(drv)) {
+	if (drv)
 		sysfs_remove_file(&drv->p->kobj, &attr->attr);
-		put_driver(drv);
-	}
 }
 EXPORT_SYMBOL_GPL(driver_remove_file);
 
-- 
1.5.3.8


      parent reply	other threads:[~2008-02-03  0:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-02 23:43 [GIT PATCH] driver core fixes against 2.6.24-git Greg KH
2008-02-02 23:55 ` [PATCH 01/10] kobject: Always build in kernel/ksysfs.o Greg Kroah-Hartman
2008-02-02 23:55 ` [PATCH 02/10] kobject: kerneldoc comment fix Greg Kroah-Hartman
2008-02-02 23:55 ` [PATCH 03/10] Add ja_JP translation of stable_kernel_rules.txt Greg Kroah-Hartman
2008-02-02 23:55 ` [PATCH 04/10] nozomi driver update Greg Kroah-Hartman
2008-02-02 23:55 ` [PATCH 05/10] nozomi: constify driver Greg Kroah-Hartman
2008-02-02 23:56 ` [PATCH 06/10] nozomi: finish constification Greg Kroah-Hartman
2008-02-02 23:56 ` [PATCH 07/10] PM: Export device_pm_schedule_removal Greg Kroah-Hartman
2008-02-02 23:56 ` [PATCH 08/10] driver core: convert to use class_find_device api Greg Kroah-Hartman
2008-02-02 23:56 ` [PATCH 09/10] Driver core: Update some prototypes in platform.txt Greg Kroah-Hartman
2008-02-02 23:56 ` Greg Kroah-Hartman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1201996564-21951-10-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=cornelia.huck@de.ibm.com \
    --cc=hidave.darkstar@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome