diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2023-01-17 16:07:18 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-01-17 16:07:18 +0100 |
commit | d4d9c75f96dccd673104ada4a9a19149325ace89 (patch) | |
tree | 49dea856fd9c13c1e6f9c82d09829e93e24dbe37 /include | |
parent | 26b942ded55dda5a701c9fd01d5ac771cab3578e (diff) | |
parent | 905e124f1c476f79d863e028934c6881ee4ee3be (diff) | |
download | barebox-d4d9c75f96dccd673104ada4a9a19149325ace89.tar.gz |
Merge branch 'for-next/kernelcode-helpers' into HEAD
Diffstat (limited to 'include')
-rw-r--r-- | include/driver.h | 4 | ||||
-rw-r--r-- | include/io-64-nonatomic-hi-lo.h | 90 | ||||
-rw-r--r-- | include/io-64-nonatomic-lo-hi.h | 90 | ||||
-rw-r--r-- | include/linux/barebox-wrapper.h | 1 | ||||
-rw-r--r-- | include/linux/clk.h | 2 | ||||
-rw-r--r-- | include/linux/slab.h | 13 | ||||
-rw-r--r-- | include/of.h | 15 |
7 files changed, 213 insertions, 2 deletions
diff --git a/include/driver.h b/include/driver.h index 10ff1321e9..b7d6ea1e52 100644 --- a/include/driver.h +++ b/include/driver.h @@ -642,12 +642,12 @@ static inline struct device_node *dev_of_node(struct device *dev) return IS_ENABLED(CONFIG_OFDEVICE) ? dev->of_node : NULL; } -static inline void *dev_get_priv(struct device *dev) +static inline void *dev_get_priv(const struct device *dev) { return dev->priv; } -static inline bool dev_is_probed(struct device *dev) +static inline bool dev_is_probed(const struct device *dev) { return dev->driver ? true : false; } diff --git a/include/io-64-nonatomic-hi-lo.h b/include/io-64-nonatomic-hi-lo.h index 3393e6317e..bac2bc6a74 100644 --- a/include/io-64-nonatomic-hi-lo.h +++ b/include/io-64-nonatomic-hi-lo.h @@ -3,6 +3,7 @@ #define _LINUX_IO_64_NONATOMIC_HI_LO_H_ #include <io.h> +#include <asm-generic/int-ll64.h> static inline __u64 hi_lo_readq(const volatile void __iomem *addr) { @@ -21,6 +22,23 @@ static inline void hi_lo_writeq(__u64 val, volatile void __iomem *addr) writel(val, addr); } +static inline __u64 hi_lo_readq_relaxed(const volatile void __iomem *addr) +{ + const volatile u32 __iomem *p = addr; + u32 low, high; + + high = readl_relaxed(p + 1); + low = readl_relaxed(p); + + return low + ((u64)high << 32); +} + +static inline void hi_lo_writeq_relaxed(__u64 val, volatile void __iomem *addr) +{ + writel_relaxed(val >> 32, addr + 4); + writel_relaxed(val, addr); +} + #ifndef readq #define readq hi_lo_readq #endif @@ -29,4 +47,76 @@ static inline void hi_lo_writeq(__u64 val, volatile void __iomem *addr) #define writeq hi_lo_writeq #endif +#ifndef readq_relaxed +#define readq_relaxed hi_lo_readq_relaxed +#endif + +#ifndef writeq_relaxed +#define writeq_relaxed hi_lo_writeq_relaxed +#endif + +#ifndef ioread64_hi_lo +#define ioread64_hi_lo ioread64_hi_lo +static inline u64 ioread64_hi_lo(const void __iomem *addr) +{ + u32 low, high; + + high = ioread32(addr + sizeof(u32)); + low = ioread32(addr); + + return low + ((u64)high << 32); +} +#endif + +#ifndef iowrite64_hi_lo +#define iowrite64_hi_lo iowrite64_hi_lo +static inline void iowrite64_hi_lo(u64 val, void __iomem *addr) +{ + iowrite32(val >> 32, addr + sizeof(u32)); + iowrite32(val, addr); +} +#endif + +#ifndef ioread64be_hi_lo +#define ioread64be_hi_lo ioread64be_hi_lo +static inline u64 ioread64be_hi_lo(const void __iomem *addr) +{ + u32 low, high; + + high = ioread32be(addr); + low = ioread32be(addr + sizeof(u32)); + + return low + ((u64)high << 32); +} +#endif + +#ifndef iowrite64be_hi_lo +#define iowrite64be_hi_lo iowrite64be_hi_lo +static inline void iowrite64be_hi_lo(u64 val, void __iomem *addr) +{ + iowrite32be(val >> 32, addr); + iowrite32be(val, addr + sizeof(u32)); +} +#endif + +#ifndef ioread64 +#define ioread64_is_nonatomic +#define ioread64 ioread64_hi_lo +#endif + +#ifndef iowrite64 +#define iowrite64_is_nonatomic +#define iowrite64 iowrite64_hi_lo +#endif + +#ifndef ioread64be +#define ioread64be_is_nonatomic +#define ioread64be ioread64be_hi_lo +#endif + +#ifndef iowrite64be +#define iowrite64be_is_nonatomic +#define iowrite64be iowrite64be_hi_lo +#endif + #endif /* _LINUX_IO_64_NONATOMIC_HI_LO_H_ */ diff --git a/include/io-64-nonatomic-lo-hi.h b/include/io-64-nonatomic-lo-hi.h index 62b4022794..6d50204b85 100644 --- a/include/io-64-nonatomic-lo-hi.h +++ b/include/io-64-nonatomic-lo-hi.h @@ -3,6 +3,7 @@ #define _LINUX_IO_64_NONATOMIC_LO_HI_H_ #include <io.h> +#include <asm-generic/int-ll64.h> static inline __u64 lo_hi_readq(const volatile void __iomem *addr) { @@ -21,6 +22,23 @@ static inline void lo_hi_writeq(__u64 val, volatile void __iomem *addr) writel(val >> 32, addr + 4); } +static inline __u64 lo_hi_readq_relaxed(const volatile void __iomem *addr) +{ + const volatile u32 __iomem *p = addr; + u32 low, high; + + low = readl_relaxed(p); + high = readl_relaxed(p + 1); + + return low + ((u64)high << 32); +} + +static inline void lo_hi_writeq_relaxed(__u64 val, volatile void __iomem *addr) +{ + writel_relaxed(val, addr); + writel_relaxed(val >> 32, addr + 4); +} + #ifndef readq #define readq lo_hi_readq #endif @@ -29,4 +47,76 @@ static inline void lo_hi_writeq(__u64 val, volatile void __iomem *addr) #define writeq lo_hi_writeq #endif +#ifndef readq_relaxed +#define readq_relaxed lo_hi_readq_relaxed +#endif + +#ifndef writeq_relaxed +#define writeq_relaxed lo_hi_writeq_relaxed +#endif + +#ifndef ioread64_lo_hi +#define ioread64_lo_hi ioread64_lo_hi +static inline u64 ioread64_lo_hi(const void __iomem *addr) +{ + u32 low, high; + + low = ioread32(addr); + high = ioread32(addr + sizeof(u32)); + + return low + ((u64)high << 32); +} +#endif + +#ifndef iowrite64_lo_hi +#define iowrite64_lo_hi iowrite64_lo_hi +static inline void iowrite64_lo_hi(u64 val, void __iomem *addr) +{ + iowrite32(val, addr); + iowrite32(val >> 32, addr + sizeof(u32)); +} +#endif + +#ifndef ioread64be_lo_hi +#define ioread64be_lo_hi ioread64be_lo_hi +static inline u64 ioread64be_lo_hi(const void __iomem *addr) +{ + u32 low, high; + + low = ioread32be(addr + sizeof(u32)); + high = ioread32be(addr); + + return low + ((u64)high << 32); +} +#endif + +#ifndef iowrite64be_lo_hi +#define iowrite64be_lo_hi iowrite64be_lo_hi +static inline void iowrite64be_lo_hi(u64 val, void __iomem *addr) +{ + iowrite32be(val, addr + sizeof(u32)); + iowrite32be(val >> 32, addr); +} +#endif + +#ifndef ioread64 +#define ioread64_is_nonatomic +#define ioread64 ioread64_lo_hi +#endif + +#ifndef iowrite64 +#define iowrite64_is_nonatomic +#define iowrite64 iowrite64_lo_hi +#endif + +#ifndef ioread64be +#define ioread64be_is_nonatomic +#define ioread64be ioread64be_lo_hi +#endif + +#ifndef iowrite64be +#define iowrite64be_is_nonatomic +#define iowrite64be iowrite64be_lo_hi +#endif + #endif /* _LINUX_IO_64_NONATOMIC_LO_HI_H_ */ diff --git a/include/linux/barebox-wrapper.h b/include/linux/barebox-wrapper.h index 83fa9223de..8f2473abe8 100644 --- a/include/linux/barebox-wrapper.h +++ b/include/linux/barebox-wrapper.h @@ -20,6 +20,7 @@ static inline void vfree(const void *addr) #define MODULE_DESCRIPTION(x) #define MODULE_LICENSE(x) #define MODULE_ALIAS(x) +#define MODULE_DEVICE_TABLE(bus, table) #define __user #define __init diff --git a/include/linux/clk.h b/include/linux/clk.h index 4cece8ba5e..bffed2bdcf 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -71,6 +71,7 @@ struct clk *clk_get(struct device *dev, const char *id); * Returns success (0) or negative errno. */ int clk_enable(struct clk *clk); +#define clk_prepare_enable(clk) clk_enable(clk) /** * clk_disable - inform the system when the clock source is no longer required. @@ -85,6 +86,7 @@ int clk_enable(struct clk *clk); * disabled. */ void clk_disable(struct clk *clk); +#define clk_disable_unprepare(clk) clk_disable(clk) /** * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. diff --git a/include/linux/slab.h b/include/linux/slab.h index eb14c58e34..dc80808938 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -3,6 +3,9 @@ #ifndef _LINUX_SLAB_H #define _LINUX_SLAB_H +#include <malloc.h> +#include <linux/string.h> + #define SLAB_CONSISTENCY_CHECKS 0 #define SLAB_RED_ZONE 0 #define SLAB_POISON 0 @@ -103,6 +106,16 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags) return calloc(n, size); } +static inline void *krealloc(void *ptr, size_t size, gfp_t flags) +{ + return realloc(ptr, size); +} + +static inline char *kstrdup(const char *str, gfp_t flags) +{ + return strdup(str); +} + #define kstrdup_const(str, flags) strdup(str) #define kfree_const(ptr) kfree((void *)ptr) diff --git a/include/of.h b/include/of.h index c69fa96054..4f4e9248ad 100644 --- a/include/of.h +++ b/include/of.h @@ -101,6 +101,11 @@ static inline const void *of_property_get_value(const struct property *pp) return pp->value ? pp->value : pp->value_const; } +static inline struct device_node *of_node_get(struct device_node *node) +{ + return node; +} +static inline void of_node_put(struct device_node *node) { } void of_print_property(const void *data, int len); void of_print_cmdline(struct device_node *root); @@ -332,6 +337,11 @@ int of_autoenable_device_by_path(char *path); int of_autoenable_i2c_by_component(char *path); int of_prepend_machine_compatible(struct device_node *root, const char *compat); +static inline const char *of_node_full_name(const struct device_node *np) +{ + return np ? np->full_name : "<no-node>"; +} + #else static inline struct of_reserve_map *of_get_reserve_map(void) { @@ -893,6 +903,11 @@ static inline int of_prepend_machine_compatible(struct device_node *root, return -ENODEV; } +static inline const char *of_node_full_name(const struct device_node *np) +{ + return "<no-node>"; +} + #endif #define for_each_property_of_node(dn, pp) \ |