linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] compat: add seq_hlist_next and seq_hlist_start_head
@ 2012-08-01 23:05 Hauke Mehrtens
  2012-08-01 23:05 ` [PATCH 2/3] compat: add sk_entry Hauke Mehrtens
  2012-08-01 23:05 ` [PATCH 3/3] compat: add sk_wmem_alloc_get and sk_has_allocations Hauke Mehrtens
  0 siblings, 2 replies; 4+ messages in thread
From: Hauke Mehrtens @ 2012-08-01 23:05 UTC (permalink / raw)
  To: mcgrof; +Cc: linux-wireless, Hauke Mehrtens

These functions are copied from the kernel and are needed by
net/bluetooth/af_bluetooth.c

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 compat/compat-2.6.34.c        |   55 +++++++++++++++++++++++++++++++++++++++++
 include/linux/compat-2.6.34.h |    6 +++++
 2 files changed, 61 insertions(+)

diff --git a/compat/compat-2.6.34.c b/compat/compat-2.6.34.c
index b905a26..80a6107 100644
--- a/compat/compat-2.6.34.c
+++ b/compat/compat-2.6.34.c
@@ -28,3 +28,58 @@ int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags)
 {
 	return -EINVAL;
 }
+
+/**
+ * seq_hlist_start - start an iteration of a hlist
+ * @head: the head of the hlist
+ * @pos:  the start position of the sequence
+ *
+ * Called at seq_file->op->start().
+ */
+struct hlist_node *seq_hlist_start(struct hlist_head *head, loff_t pos)
+{
+	struct hlist_node *node;
+
+	hlist_for_each(node, head)
+		if (pos-- == 0)
+			return node;
+	return NULL;
+}
+
+/**
+ * seq_hlist_start_head - start an iteration of a hlist
+ * @head: the head of the hlist
+ * @pos:  the start position of the sequence
+ *
+ * Called at seq_file->op->start(). Call this function if you want to
+ * print a header at the top of the output.
+ */
+struct hlist_node *seq_hlist_start_head(struct hlist_head *head, loff_t pos)
+{
+	if (!pos)
+		return SEQ_START_TOKEN;
+
+	return seq_hlist_start(head, pos - 1);
+}
+EXPORT_SYMBOL(seq_hlist_start_head);
+
+/**
+ * seq_hlist_next - move to the next position of the hlist
+ * @v:    the current iterator
+ * @head: the head of the hlist
+ * @ppos: the current position
+ *
+ * Called at seq_file->op->next().
+ */
+struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head,
+				  loff_t *ppos)
+{
+	struct hlist_node *node = v;
+
+	++*ppos;
+	if (v == SEQ_START_TOKEN)
+		return head->first;
+	else
+		return node->next;
+}
+EXPORT_SYMBOL(seq_hlist_next);
diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h
index b5a40e2..39bc13b 100644
--- a/include/linux/compat-2.6.34.h
+++ b/include/linux/compat-2.6.34.h
@@ -319,6 +319,12 @@ static inline int lockdep_rtnl_is_held(void)
 }
 #endif /* #ifdef CONFIG_PROVE_LOCKING */
 
+extern struct hlist_node *seq_hlist_start_head(struct hlist_head *head,
+					       loff_t pos);
+
+extern struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head,
+					 loff_t *ppos);
+
 #else /* Kernels >= 2.6.34 */
 
 static inline void init_compat_mmc_pm_flags(void)
-- 
1.7.9.5


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

* [PATCH 2/3] compat: add sk_entry
  2012-08-01 23:05 [PATCH 1/3] compat: add seq_hlist_next and seq_hlist_start_head Hauke Mehrtens
@ 2012-08-01 23:05 ` Hauke Mehrtens
  2012-08-01 23:05 ` [PATCH 3/3] compat: add sk_wmem_alloc_get and sk_has_allocations Hauke Mehrtens
  1 sibling, 0 replies; 4+ messages in thread
From: Hauke Mehrtens @ 2012-08-01 23:05 UTC (permalink / raw)
  To: mcgrof; +Cc: linux-wireless, Hauke Mehrtens

This function is copied from the kernel.

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

diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h
index 39bc13b..b8b48c0 100644
--- a/include/linux/compat-2.6.34.h
+++ b/include/linux/compat-2.6.34.h
@@ -8,6 +8,7 @@
 #include <linux/netdevice.h>
 #include <linux/usb.h>
 #include <linux/mmc/sdio_func.h>
+#include <net/sock.h>
 
 /*
  * Backports da68c4eb25
@@ -325,6 +326,11 @@ extern struct hlist_node *seq_hlist_start_head(struct hlist_head *head,
 extern struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head,
 					 loff_t *ppos);
 
+static inline struct sock *sk_entry(const struct hlist_node *node)
+{
+	return hlist_entry(node, struct sock, sk_node);
+}
+
 #else /* Kernels >= 2.6.34 */
 
 static inline void init_compat_mmc_pm_flags(void)
-- 
1.7.9.5


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

* [PATCH 3/3] compat: add sk_wmem_alloc_get and sk_has_allocations
  2012-08-01 23:05 [PATCH 1/3] compat: add seq_hlist_next and seq_hlist_start_head Hauke Mehrtens
  2012-08-01 23:05 ` [PATCH 2/3] compat: add sk_entry Hauke Mehrtens
@ 2012-08-01 23:05 ` Hauke Mehrtens
  2012-08-06 17:50   ` Luis R. Rodriguez
  1 sibling, 1 reply; 4+ messages in thread
From: Hauke Mehrtens @ 2012-08-01 23:05 UTC (permalink / raw)
  To: mcgrof; +Cc: linux-wireless, Hauke Mehrtens

These functions are copied from the kernel.

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

diff --git a/include/linux/compat-2.6.31.h b/include/linux/compat-2.6.31.h
index 25db973..347ae26 100644
--- a/include/linux/compat-2.6.31.h
+++ b/include/linux/compat-2.6.31.h
@@ -11,6 +11,7 @@
 #include <net/dst.h>
 #include <net/genetlink.h>
 #include <linux/ethtool.h>
+#include <net/sock.h>
 
 /*
  * These macros allow us to backport rfkill without any
@@ -215,6 +216,39 @@ extern long long atomic64_add_return(long long a, atomic64_t *v);
 
 #endif
 
+/**
+ * sk_rmem_alloc_get - returns read allocations
+ * @sk: socket
+ *
+ * Returns sk_rmem_alloc
+ */
+static inline int sk_rmem_alloc_get(const struct sock *sk)
+{
+	return atomic_read(&sk->sk_rmem_alloc);
+}
+
+/**
+ * sk_wmem_alloc_get - returns write allocations
+ * @sk: socket
+ *
+ * Returns sk_wmem_alloc minus initial offset of one
+ */
+static inline int sk_wmem_alloc_get(const struct sock *sk)
+{
+	return atomic_read(&sk->sk_wmem_alloc) - 1;
+}
+
+/**
+ * sk_has_allocations - check if allocations are outstanding
+ * @sk: socket
+ *
+ * Returns true if socket has write or read allocations
+ */
+static inline bool sk_has_allocations(const struct sock *sk)
+{
+	return sk_wmem_alloc_get(sk) || sk_rmem_alloc_get(sk);
+}
+
 
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */
 
-- 
1.7.9.5


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

* Re: [PATCH 3/3] compat: add sk_wmem_alloc_get and sk_has_allocations
  2012-08-01 23:05 ` [PATCH 3/3] compat: add sk_wmem_alloc_get and sk_has_allocations Hauke Mehrtens
@ 2012-08-06 17:50   ` Luis R. Rodriguez
  0 siblings, 0 replies; 4+ messages in thread
From: Luis R. Rodriguez @ 2012-08-06 17:50 UTC (permalink / raw)
  To: Hauke Mehrtens; +Cc: linux-wireless

On Wed, Aug 1, 2012 at 4:05 PM, Hauke Mehrtens <hauke@hauke-m.de> wrote:
> These functions are copied from the kernel.
>
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

Thanks, applied all 3 and pushed!

  Luis

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

end of thread, other threads:[~2012-08-06 17:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-01 23:05 [PATCH 1/3] compat: add seq_hlist_next and seq_hlist_start_head Hauke Mehrtens
2012-08-01 23:05 ` [PATCH 2/3] compat: add sk_entry Hauke Mehrtens
2012-08-01 23:05 ` [PATCH 3/3] compat: add sk_wmem_alloc_get and sk_has_allocations Hauke Mehrtens
2012-08-06 17:50   ` Luis R. Rodriguez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).