From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Rob Herring <robherring2@gmail.com>
Cc: Grant Likely <grant.likely@linaro.org>,
Olof Johansson <olof@lixom.net>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH 1/2] device: Add dev_of_node() accessor
Date: Mon, 16 Feb 2015 14:59:08 +1100 [thread overview]
Message-ID: <1424059148.21410.37.camel@kernel.crashing.org> (raw)
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>
---
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);
/*
next reply other threads:[~2015-02-16 3:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-16 3:59 Benjamin Herrenschmidt [this message]
2015-02-18 1:03 ` [PATCH 1/2] device: Add dev_of_node() accessor Rob Herring
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=1424059148.21410.37.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=arnd@arndb.de \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=robherring2@gmail.com \
/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