backports: add GENMASK and GENMASK_ULL
PATCH 1/3 backports: add GENMASK and GENMASK_ULL
I intend to use this for a new driver
Signed-off-by Felix Fietkau <[email protected]>
--- backport/backport-include/linux/bitops.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 backport/backport-include/linux/bitops.h
backport/backport-include/linux/bitops.h new file +19 -0
@@ -0,0 +1,19 @@ +#ifndef __BACKPORT_BITOPS_H +#define __BACKPORT_BITOPS_H +#include_next <linux/bitops.h> +#include <linux/version.h> +#include <generated/utsrelease.h> + +#ifndef GENMASK + +/* +* Create a contiguous bitmask starting at bit position @l and ending at +* position @h. For example +* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. +*/ +#define GENMASK (h, l) (((U32_C(1) << ((h) - (l) + 1)) - 1) << (l)) +#define GENMASK_ULL (h, l) (((U64_C(1) << ((h) - (l) + 1)) - 1) << (l)) + +#endif + +#endif /* __BACKPORT_BITOPS_H */
Signature · 1 line
2.1.2
PATCH 2/3 backports: add include/uapi/linux/pci_regs.h to copy-list
Fixes a recent iwlwifi build error
Signed-off-by Felix Fietkau <[email protected]>
--- copy-list | 1 + 1 file changed, 1 insertion(+)
copy-list +1 -0
@@ -23,6 +23,7 @@ include/linux/wireless.h include/uapi/linux/wireless.h include/linux/ieee80211.h include/linux/pci_ids.h +include/uapi/linux/pci_regs.h include/linux/mmc/sdio_ids.h include/linux/ath9k_platform.h include/uapi/linux/wil6210_uapi.h
Signature · 1 line
2.1.2
PATCH 3/3 backports: backport devm_kmemdup
In reply to Felix FietkauSigned-off-by Felix Fietkau <[email protected]>
--- backport/backport-include/linux/device.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
backport/backport-include/linux/device.h +16 -0
@@ -177,4 +177,20 @@ static inline void *devm_kmalloc_array(struct device *dev, }#endif +#if LINUX_VERSION_CODE <KERNEL_VERSION (3 ,15 ,0 ) +#define devm_kmemdup LINUX_BACKPORT(devm_kmemdup) +static inline void *devm_kmemdup (struct device *dev,const void *src, +size_t len,gfp_t gfp) +{ +void *p; + + p =devm_kmalloc (dev, len, gfp); +if (p) +memcpy (p, src, len); + +return p; +} +#endif + +#endif /* __BACKPORT_DEVICE_H */
Signature · 1 line
2.1.2
Re: [PATCH 3/3] backports: backport devm_kmemdup
Quoted 10 lines · Felix Fietkau
Signed-off-by Felix Fietkau <[email protected]>--- backport/backport-include/linux/device.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)backport/backport-include/linux/device.h +0
-0
backport/backport-include/linux/device.h static inline void *devm_kmalloc_array(struct device *dev, · line 180
Quoted 4 lines
backport/backport-include/linux/device.h +1
-0@@ -177,4 +177,20 @@ static inline void *devm_kmalloc_array(struct device *dev, }#endif +#if LINUX_VERSION_CODE <KERNEL_VERSION (3 ,15 ,0 )
devm_kmemdup() is not available in kernel 3.15, you should use #if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
Quoted 17 lines
backport/backport-include/linux/device.h +15
-0+#define devm_kmemdup LINUX_BACKPORT(devm_kmemdup) +static inline void *devm_kmemdup (struct device *dev,const void *src, +size_t len,gfp_t gfp) +{ +void *p; + + p =devm_kmalloc (dev, len, gfp); +if (p) +memcpy (p, src, len); + +return p; +} +#endif + +#endif /* __BACKPORT_DEVICE_H */
Quoted 14 lines · Felix Fietkau
I intend to use this for a new driver
Signed-off-by Felix Fietkau <[email protected]>--- backport/backport-include/linux/bitops.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 backport/backport-include/linux/bitops.hbackport/backport-include/linux/bitops.h new file +0
-0
backport/backport-include/linux/bitops.h line 5
Quoted 5 lines
backport/backport-include/linux/bitops.h new file +5
-0@@ -0,0 +1,19 @@ +#ifndef __BACKPORT_BITOPS_H +#define __BACKPORT_BITOPS_H +#include_next <linux/bitops.h> +#include <linux/version.h> +#include <generated/utsrelease.h>
These two includes are not needed.
backport/backport-include/linux/bitops.h line 15
Quoted 10 lines
backport/backport-include/linux/bitops.h new file +10
-0+ +#ifndef GENMASK + +/* +* Create a contiguous bitmask starting at bit position @l and ending at +* position @h. For example +* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. +*/ +#define GENMASK (h, l) (((U32_C(1) << ((h) - (l) + 1)) - 1) << (l)) +#define GENMASK_ULL (h, l) (((U64_C(1) << ((h) - (l) + 1)) - 1) << (l))
You should use tabs here and not spaces.
Quoted 5 lines
backport/backport-include/linux/bitops.h new file +4
-0+ +#endif + +#endif /* __BACKPORT_BITOPS_H */