summaryrefslogtreecommitdiff
path: root/include/linux/device.h
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-07-03 20:49:35 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-17 05:05:45 +0400
commita4232963757e62b3b97bbba07cb92c6d448f6f4b (patch)
treebf91e17c13821f4463fbae1dc04be0b5e4f9fe7d /include/linux/device.h
parent8153584e3fdf78753bf653d5f583b6ecb86e5e70 (diff)
downloadlinux-a4232963757e62b3b97bbba07cb92c6d448f6f4b.tar.xz
driver-core: Move kobj_to_dev from genhd.h to device.h
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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 161d96241b1b..5c4495c8fe3f 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>