b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: "Linus Lüssing" <linus.luessing@ascom.ch>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: "Linus Lüssing" <linus.luessing@ascom.ch>
Subject: [B.A.T.M.A.N.] [PATCH 07/10] batman-adv: Adding batman_if specific sysfs wrapper macros for UINT
Date: Fri, 31 Dec 2010 16:46:22 +0100	[thread overview]
Message-ID: <1293810385-31761-8-git-send-email-linus.luessing@ascom.ch> (raw)
In-Reply-To: <1293810385-31761-1-git-send-email-linus.luessing@ascom.ch>

This allows us to easily add a sysfs parameter for an unsigned int
later, which is not for a batman mesh interface (e.g. bat0), but for a
common interface instead. It allows reading and writing an atomic_t in
batman_if (instead of bat_priv compared to the mesh variant).

Signed-off-by: Linus Lüssing <linus.luessing@ascom.ch>
---
 bat_sysfs.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/bat_sysfs.c b/bat_sysfs.c
index cd7bb51..5954389 100644
--- a/bat_sysfs.c
+++ b/bat_sysfs.c
@@ -94,6 +94,49 @@ ssize_t show_##_name(struct kobject *kobj, struct attribute *attr,	\
 	static BAT_ATTR(_name, _mode, show_##_name, store_##_name)
 
 
+#define BAT_ATTR_IF_STORE_UINT(_name, _min, _max, _post_func)		\
+ssize_t store_##_name(struct kobject *kobj, struct attribute *attr,	\
+			     char *buff, size_t count)			\
+{									\
+	struct net_device *net_dev = kobj_to_netdev(kobj);		\
+	struct batman_if *batman_if = get_batman_if_by_netdev(net_dev);	\
+	ssize_t length;							\
+									\
+	if (!batman_if)							\
+		return 0;						\
+									\
+	length = __store_uint_attr(buff, count, _min, _max, _post_func,	\
+				 attr, &batman_if->_name, net_dev);	\
+									\
+	kref_put(&batman_if->refcount, hardif_free_ref);		\
+	return length;							\
+}
+
+#define BAT_ATTR_IF_SHOW_UINT(_name)					\
+ssize_t show_##_name(struct kobject *kobj, struct attribute *attr,	\
+			    char *buff)					\
+{									\
+	struct net_device *net_dev = kobj_to_netdev(kobj);		\
+	struct batman_if *batman_if = get_batman_if_by_netdev(net_dev);	\
+	ssize_t length;							\
+									\
+	if (!batman_if)							\
+		return 0;						\
+									\
+	length = sprintf(buff, "%i\n", atomic_read(&batman_if->_name));	\
+									\
+	kref_put(&batman_if->refcount, hardif_free_ref);		\
+	return length;							\
+}
+
+/* Use this, if you are going to set [name] in batman_if to unsigned integer
+ * values only */
+#define BAT_ATTR_IF_UINT(_name, _mode, _min, _max, _post_func)		\
+	static BAT_ATTR_IF_STORE_UINT(_name, _min, _max, _post_func)	\
+	static BAT_ATTR_IF_SHOW_UINT(_name)				\
+	static BAT_ATTR(_name, _mode, show_##_name, store_##_name)
+
+
 static int store_bool_attr(char *buff, size_t count,
 			   struct net_device *net_dev,
 			   char *attr_name, atomic_t *attr)
-- 
1.7.1


  parent reply	other threads:[~2010-12-31 15:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-31 15:46 [B.A.T.M.A.N.] NDP patches v4 Linus Lüssing
2010-12-31 15:46 ` [B.A.T.M.A.N.] [PATCH 01/10] batman-adv: Rename packet type / structure / functions for OGMs Linus Lüssing
2010-12-31 15:46 ` [B.A.T.M.A.N.] [PATCH 02/10] batman-adv: Adding workqueue for new ndp packets Linus Lüssing
2010-12-31 15:46 ` [B.A.T.M.A.N.] [PATCH 03/10] batman-adv: Send neighbor discovery packets Linus Lüssing
2010-12-31 15:46 ` [B.A.T.M.A.N.] [PATCH 04/10] batman-adv: Creating neighbor structures, updating LQs Linus Lüssing
2010-12-31 15:46 ` [B.A.T.M.A.N.] [PATCH 05/10] batman-adv: Purge outdated ndp neighbours Linus Lüssing
2010-12-31 15:46 ` [B.A.T.M.A.N.] [PATCH 06/10] batman-adv: Adding ndp debugfs output Linus Lüssing
2010-12-31 15:46 ` Linus Lüssing [this message]
2010-12-31 15:46 ` [B.A.T.M.A.N.] [PATCH 08/10] batman-adv: Adding sysfs parameter for ndp interval Linus Lüssing
2010-12-31 15:46 ` [B.A.T.M.A.N.] [PATCH 09/10] batman-adv: Use local tq values determined by NDP on OGMs Linus Lüssing
2010-12-31 15:46 ` [B.A.T.M.A.N.] [PATCH 10/10] batman-adv: Use rcu locking + ref-counting for neigh_list Linus Lüssing
2011-01-02  1:27   ` Linus Lüssing
2011-01-05 12:12 ` [B.A.T.M.A.N.] NDP patches v4 Marek Lindner
2011-01-12 15:32   ` Linus Lüssing
2011-01-12 15:48     ` [B.A.T.M.A.N.] NDP patches v4y Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1293810385-31761-8-git-send-email-linus.luessing@ascom.ch \
    --to=linus.luessing@ascom.ch \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).