From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] driver: move some inline getters for struct device into device.h
Date: Fri, 17 May 2024 07:57:51 +0200 [thread overview]
Message-ID: <20240517055751.2016310-1-a.fatoum@pengutronix.de> (raw)
The purpose of device.h is to contain only the device related
definitions and have as few header dependencies as possible.
dev_of_node() and dev_is_dma_coherent() are accessors for struct device
and have no other dependencies, so move them into this header as well.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
include/device.h | 21 +++++++++++++++++++++
include/driver.h | 21 ---------------------
2 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/include/device.h b/include/device.h
index 8c3561e5a2f6..ad1bc7ca1eea 100644
--- a/include/device.h
+++ b/include/device.h
@@ -108,4 +108,25 @@ struct device_alias {
char name[];
};
+static inline struct device_node *dev_of_node(struct device *dev)
+{
+ return IS_ENABLED(CONFIG_OFDEVICE) ? dev->of_node : NULL;
+}
+
+static inline bool dev_is_dma_coherent(struct device *dev)
+{
+ if (dev) {
+ switch (dev->dma_coherent) {
+ case DEV_DMA_NON_COHERENT:
+ return false;
+ case DEV_DMA_COHERENT:
+ return true;
+ case DEV_DMA_COHERENCE_DEFAULT:
+ break;
+ }
+ }
+
+ return IS_ENABLED(CONFIG_ARCH_DMA_DEFAULT_COHERENT);
+}
+
#endif
diff --git a/include/driver.h b/include/driver.h
index 3401ab4f07f4..100761c7657e 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -677,27 +677,6 @@ int device_match_of_modalias(struct device *dev, struct driver *drv);
struct device *device_find_child(struct device *parent, void *data,
int (*match)(struct device *dev, void *data));
-static inline struct device_node *dev_of_node(struct device *dev)
-{
- return IS_ENABLED(CONFIG_OFDEVICE) ? dev->of_node : NULL;
-}
-
-static inline bool dev_is_dma_coherent(struct device *dev)
-{
- if (dev) {
- switch (dev->dma_coherent) {
- case DEV_DMA_NON_COHERENT:
- return false;
- case DEV_DMA_COHERENT:
- return true;
- case DEV_DMA_COHERENCE_DEFAULT:
- break;
- }
- }
-
- return IS_ENABLED(CONFIG_ARCH_DMA_DEFAULT_COHERENT);
-}
-
static inline void *dev_get_priv(const struct device *dev)
{
return dev->priv;
--
2.39.2
next reply other threads:[~2024-05-17 5:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-17 5:57 Ahmad Fatoum [this message]
2024-05-21 11:00 ` Sascha Hauer
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=20240517055751.2016310-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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