All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] compat: add __always_unused
@ 2011-08-31 22:20 Hauke Mehrtens
  2011-08-31 22:20 ` [PATCH 2/3] compat: add skb_frag_dma_map Hauke Mehrtens
  2011-08-31 22:20 ` [PATCH 3/3] compat: add kstrtou8_from_user Hauke Mehrtens
  0 siblings, 2 replies; 4+ messages in thread
From: Hauke Mehrtens @ 2011-08-31 22:20 UTC (permalink / raw)
  To: mcgrof, mcgrof; +Cc: linux-wireless, Hauke Mehrtens


Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 include/linux/compat-2.6.33.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h
index 8aabda0..43f1989 100644
--- a/include/linux/compat-2.6.33.h
+++ b/include/linux/compat-2.6.33.h
@@ -138,6 +138,12 @@ static inline bool pci_is_pcie(struct pci_dev *dev)
 #endif
 }
 
+#ifdef __GNUC__
+#define __always_unused			__attribute__((unused))
+#else
+#define __always_unused			/* unimplemented */
+#endif
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */
 
 #endif /* LINUX_26_33_COMPAT_H */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] compat: add skb_frag_dma_map
  2011-08-31 22:20 [PATCH 1/3] compat: add __always_unused Hauke Mehrtens
@ 2011-08-31 22:20 ` Hauke Mehrtens
  2011-08-31 22:20 ` [PATCH 3/3] compat: add kstrtou8_from_user Hauke Mehrtens
  1 sibling, 0 replies; 4+ messages in thread
From: Hauke Mehrtens @ 2011-08-31 22:20 UTC (permalink / raw)
  To: mcgrof, mcgrof; +Cc: linux-wireless, Hauke Mehrtens


Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 include/linux/compat-3.2.h |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h
index d10495c..009e341 100644
--- a/include/linux/compat-3.2.h
+++ b/include/linux/compat-3.2.h
@@ -5,6 +5,9 @@
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0))
 
+#include <linux/skbuff.h>
+#include <linux/dma-mapping.h>
+
 /*
  * This is not part of The 2.6.37 kernel yet but we
  * we use it to optimize the backport code we
@@ -24,6 +27,37 @@
 
 #define PMSG_IS_AUTO(msg)	(((msg).event & PM_EVENT_AUTO) != 0)
 
+/**
+ * skb_frag_page - retrieve the page refered to by a paged fragment
+ * @frag: the paged fragment
+ *
+ * Returns the &struct page associated with @frag.
+ */
+static inline struct page *skb_frag_page(const skb_frag_t *frag)
+{
+	return frag->page;
+}
+
+/**
+ * skb_frag_dma_map - maps a paged fragment via the DMA API
+ * @device: the device to map the fragment to
+ * @frag: the paged fragment to map
+ * @offset: the offset within the fragment (starting at the
+ *          fragment's own offset)
+ * @size: the number of bytes to map
+ * @direction: the direction of the mapping (%PCI_DMA_*)
+ *
+ * Maps the page associated with @frag to @device.
+ */
+static inline dma_addr_t skb_frag_dma_map(struct device *dev,
+					  const skb_frag_t *frag,
+					  size_t offset, size_t size,
+					  enum dma_data_direction dir)
+{
+	return dma_map_page(dev, skb_frag_page(frag),
+			    frag->page_offset + offset, size, dir);
+}
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */
 
 #endif /* LINUX_3_2_COMPAT_H */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] compat: add kstrtou8_from_user
  2011-08-31 22:20 [PATCH 1/3] compat: add __always_unused Hauke Mehrtens
  2011-08-31 22:20 ` [PATCH 2/3] compat: add skb_frag_dma_map Hauke Mehrtens
@ 2011-08-31 22:20 ` Hauke Mehrtens
  2011-08-31 22:24   ` Luis R. Rodriguez
  1 sibling, 1 reply; 4+ messages in thread
From: Hauke Mehrtens @ 2011-08-31 22:20 UTC (permalink / raw)
  To: mcgrof, mcgrof; +Cc: linux-wireless, Hauke Mehrtens


Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 compat/compat-3.0.c        |   25 +++++++++++++++++++++++++
 include/linux/compat-3.0.h |   31 +++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/compat/compat-3.0.c b/compat/compat-3.0.c
index 312eea0..f517e9f 100644
--- a/compat/compat-3.0.c
+++ b/compat/compat-3.0.c
@@ -35,3 +35,28 @@ int mac_pton(const char *s, u8 *mac)
 	return 1;
 }
 EXPORT_SYMBOL(mac_pton);
+
+#define kstrto_from_user(f, g, type)					\
+int f(const char __user *s, size_t count, unsigned int base, type *res)	\
+{									\
+	/* sign, base 2 representation, newline, terminator */		\
+	char buf[1 + sizeof(type) * 8 + 1 + 1];				\
+									\
+	count = min(count, sizeof(buf) - 1);				\
+	if (copy_from_user(buf, s, count))				\
+		return -EFAULT;						\
+	buf[count] = '\0';						\
+	return g(buf, base, res);					\
+}									\
+EXPORT_SYMBOL(f)
+
+kstrto_from_user(kstrtoull_from_user,	kstrtoull,	unsigned long long);
+kstrto_from_user(kstrtoll_from_user,	kstrtoll,	long long);
+kstrto_from_user(kstrtoul_from_user,	kstrtoul,	unsigned long);
+kstrto_from_user(kstrtol_from_user,	kstrtol,	long);
+kstrto_from_user(kstrtouint_from_user,	kstrtouint,	unsigned int);
+kstrto_from_user(kstrtoint_from_user,	kstrtoint,	int);
+kstrto_from_user(kstrtou16_from_user,	kstrtou16,	u16);
+kstrto_from_user(kstrtos16_from_user,	kstrtos16,	s16);
+kstrto_from_user(kstrtou8_from_user,	kstrtou8,	u8);
+kstrto_from_user(kstrtos8_from_user,	kstrtos8,	s8);
diff --git a/include/linux/compat-3.0.h b/include/linux/compat-3.0.h
index 7954ddb..8c8720e 100644
--- a/include/linux/compat-3.0.h
+++ b/include/linux/compat-3.0.h
@@ -48,6 +48,37 @@ struct bcma_device_id {
 
 int mac_pton(const char *s, u8 *mac);
 
+int __must_check kstrtoull_from_user(const char __user *s, size_t count, unsigned int base, unsigned long long *res);
+int __must_check kstrtoll_from_user(const char __user *s, size_t count, unsigned int base, long long *res);
+int __must_check kstrtoul_from_user(const char __user *s, size_t count, unsigned int base, unsigned long *res);
+int __must_check kstrtol_from_user(const char __user *s, size_t count, unsigned int base, long *res);
+int __must_check kstrtouint_from_user(const char __user *s, size_t count, unsigned int base, unsigned int *res);
+int __must_check kstrtoint_from_user(const char __user *s, size_t count, unsigned int base, int *res);
+int __must_check kstrtou16_from_user(const char __user *s, size_t count, unsigned int base, u16 *res);
+int __must_check kstrtos16_from_user(const char __user *s, size_t count, unsigned int base, s16 *res);
+int __must_check kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, u8 *res);
+int __must_check kstrtos8_from_user(const char __user *s, size_t count, unsigned int base, s8 *res);
+
+static inline int __must_check kstrtou64_from_user(const char __user *s, size_t count, unsigned int base, u64 *res)
+{
+	return kstrtoull_from_user(s, count, base, res);
+}
+
+static inline int __must_check kstrtos64_from_user(const char __user *s, size_t count, unsigned int base, s64 *res)
+{
+	return kstrtoll_from_user(s, count, base, res);
+}
+
+static inline int __must_check kstrtou32_from_user(const char __user *s, size_t count, unsigned int base, u32 *res)
+{
+	return kstrtouint_from_user(s, count, base, res);
+}
+
+static inline int __must_check kstrtos32_from_user(const char __user *s, size_t count, unsigned int base, s32 *res)
+{
+	return kstrtoint_from_user(s, count, base, res);
+}
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) */
 
 #endif /* LINUX_3_0_COMPAT_H */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 3/3] compat: add kstrtou8_from_user
  2011-08-31 22:20 ` [PATCH 3/3] compat: add kstrtou8_from_user Hauke Mehrtens
@ 2011-08-31 22:24   ` Luis R. Rodriguez
  0 siblings, 0 replies; 4+ messages in thread
From: Luis R. Rodriguez @ 2011-08-31 22:24 UTC (permalink / raw)
  To: Hauke Mehrtens; +Cc: linux-wireless

On Wed, Aug 31, 2011 at 3:20 PM, Hauke Mehrtens <hauke@hauke-m.de> wrote:
>
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

Thanks! Applied, I'll push when master.kernel.org recovers from the hangover.

  Luis

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-08-31 22:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-31 22:20 [PATCH 1/3] compat: add __always_unused Hauke Mehrtens
2011-08-31 22:20 ` [PATCH 2/3] compat: add skb_frag_dma_map Hauke Mehrtens
2011-08-31 22:20 ` [PATCH 3/3] compat: add kstrtou8_from_user Hauke Mehrtens
2011-08-31 22:24   ` Luis R. Rodriguez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.