[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1424059148.21410.37.camel@kernel.crashing.org>
Date: Mon, 16 Feb 2015 14:59:08 +1100
From: Benjamin Herrenschmidt <benh@...nel.crashing.org>
To: Rob Herring <robherring2@...il.com>
Cc: Grant Likely <grant.likely@...aro.org>,
Olof Johansson <olof@...om.net>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Arnd Bergmann <arnd@...db.de>
Subject: [PATCH 1/2] 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@...nel.crashing.org>
---
This is what we discussed back in November and I had forgotten
to finish :)
include/linux/device.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/linux/device.h b/include/linux/device.h
index fb50673..08128288 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);
/*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists