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: Dave Young <hidave.darkstar@gmail.com>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 08/10] driver core: convert to use class_find_device api
Date: Sat,  2 Feb 2008 15:56:02 -0800	[thread overview]
Message-ID: <1201996564-21951-8-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20080202234357.GA21721@suse.de>

From: Dave Young <hidave.darkstar@gmail.com>

Convert to use class_find_device api in drivers/base/core.c

Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/base/core.c |   32 +++++++++++---------------------
 1 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index b172787..a0cfda5 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1144,25 +1144,11 @@ error:
 }
 EXPORT_SYMBOL_GPL(device_create);
 
-/**
- * find_device - finds a device that was created with device_create()
- * @class: pointer to the struct class that this device was registered with
- * @devt: the dev_t of the device that was previously registered
- */
-static struct device *find_device(struct class *class, dev_t devt)
+static int __match_devt(struct device *dev, void *data)
 {
-	struct device *dev = NULL;
-	struct device *dev_tmp;
+	dev_t *devt = data;
 
-	down(&class->sem);
-	list_for_each_entry(dev_tmp, &class->devices, node) {
-		if (dev_tmp->devt == devt) {
-			dev = dev_tmp;
-			break;
-		}
-	}
-	up(&class->sem);
-	return dev;
+	return dev->devt == *devt;
 }
 
 /**
@@ -1177,9 +1163,11 @@ void device_destroy(struct class *class, dev_t devt)
 {
 	struct device *dev;
 
-	dev = find_device(class, devt);
-	if (dev)
+	dev = class_find_device(class, &devt, __match_devt);
+	if (dev) {
+		put_device(dev);
 		device_unregister(dev);
+	}
 }
 EXPORT_SYMBOL_GPL(device_destroy);
 
@@ -1203,9 +1191,11 @@ void destroy_suspended_device(struct class *class, dev_t devt)
 {
 	struct device *dev;
 
-	dev = find_device(class, devt);
-	if (dev)
+	dev = class_find_device(class, &devt, __match_devt);
+	if (dev) {
 		device_pm_schedule_removal(dev);
+		put_device(dev);
+	}
 }
 EXPORT_SYMBOL_GPL(destroy_suspended_device);
 #endif /* CONFIG_PM_SLEEP */
-- 
1.5.3.8


  parent reply	other threads:[~2008-02-03  0:00 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 ` Greg Kroah-Hartman [this message]
2008-02-02 23:56 ` [PATCH 09/10] Driver core: Update some prototypes in platform.txt Greg Kroah-Hartman
2008-02-02 23:56 ` [PATCH 10/10] Driver core: Remove unneeded get_{device,driver}() calls Greg Kroah-Hartman

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-8-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --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