summaryrefslogtreecommitdiff
path: root/include/linux/device.h
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2015-02-18 04:03:41 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-03-25 16:53:58 +0300
commite8a51e1b51ee5730ad3913f3962e3099a5e19359 (patch)
tree28b3f15d83a7de01e63084e0bc7111c756482db7 /include/linux/device.h
parentef518cc8aa4427043efe21cb2f0799be9cb1d74d (diff)
downloadlinux-e8a51e1b51ee5730ad3913f3962e3099a5e19359.tar.xz
device: Add dev_of_node() accessor
Suggested by Arnd Bergmann, this gives a practical accessor for the of_node field of struct device while instructing the compiler that it will be NULL if CONFIG_OF is not set. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 0eb8ee2dc6d1..f3f2c7e38060 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -916,6 +916,13 @@ static inline void device_lock_assert(struct device *dev)
lockdep_assert_held(&dev->mutex);
}
+static inline struct device_node *dev_of_node(struct device *dev)
+{
+ if (!IS_ENABLED(CONFIG_OF))
+ return NULL;
+ return dev->of_node;
+}
+
void driver_init(void);
/*