From: Lars-Peter Clausen <lars@metafoo.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 1/2] driver-core: Move kobj_to_dev from genhd.h to device.h
Date: Tue, 3 Jul 2012 18:49:35 +0200 [thread overview]
Message-ID: <1341334176-8801-1-git-send-email-lars@metafoo.de> (raw)
This function is not really specific to the genhd layer and there are various
re-implementations or open-coded variants of it all throughout the kernel. To
avoid further duplications move the function to a more generic place.
While moving also convert it from a macro to a inline function.
Potential users of this function can be detected and converted using the
following coccinelle patch:
// <smpl>
@@
expression k;
@@
-container_of(k, struct device, kobj)
+kobj_to_dev(kobj)
// </smpl>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
include/linux/device.h | 5 +++++
include/linux/genhd.h | 1 -
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/linux/device.h b/include/linux/device.h
index 161d962..5c4495c 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -689,6 +689,11 @@ struct device {
void (*release)(struct device *dev);
};
+static inline struct device *kobj_to_dev(struct kobject *kobj)
+{
+ return container_of(kobj, struct device, kobj);
+}
+
/* Get the wakeup routines, which depend on struct device */
#include <linux/pm_wakeup.h>
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 017a7fb..ae0aaa9 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -16,7 +16,6 @@
#ifdef CONFIG_BLOCK
-#define kobj_to_dev(k) container_of((k), struct device, kobj)
#define dev_to_disk(device) container_of((device), struct gendisk, part0.__dev)
#define dev_to_part(device) container_of((device), struct hd_struct, __dev)
#define disk_to_dev(disk) (&(disk)->part0.__dev)
--
1.7.10
next reply other threads:[~2012-07-03 16:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-03 16:49 Lars-Peter Clausen [this message]
2012-07-03 16:49 ` [PATCH 2/2] driver-core: Use kobj_to_dev instead of re-implementing it Lars-Peter Clausen
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=1341334176-8801-1-git-send-email-lars@metafoo.de \
--to=lars@metafoo.de \
--cc=gregkh@linuxfoundation.org \
--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
all inboxes | Powered by JetHome®