Skip to contentSkip to conversation

backports: add GENMASK and GENMASK_ULL

PATCH In review Felix Fietkau 2 participants 4 messages Nov 16, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 backports: add GENMASK and GENMASK_ULL

I intend to use this for a new driver

---
 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
new file mode 100644
index 0000000..b0e9283
@@ -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
#1 lore raw

PATCH v2 2/3 backports: add include/uapi/linux/pci_regs.h to copy-list

Fixes a recent iwlwifi build error

---
 copy-list | 1 +
 1 file changed, 1 insertion(+)
copy-list +1 -0
index 75ef52f..6a6cb01 100644
@@ -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
#2 lore raw

PATCH v2 3/3 backports: backport devm_kmemdup

In reply to Felix Fietkau
---
 backport/backport-include/linux/device.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
backport/backport-include/linux/device.h +16 -0
index 41f06c3..29dc077 100644
@@ -177,4 +177,20 @@ static inline void *devm_kmalloc_array(struct device *dev,
 }
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,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