* [PATCH] driver: move some inline getters for struct device into device.h
@ 2024-05-17 5:57 Ahmad Fatoum
2024-05-21 11:00 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-05-17 5:57 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-21 11:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-17 5:57 [PATCH] driver: move some inline getters for struct device into device.h Ahmad Fatoum
2024-05-21 11:00 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox