[linux-next] LinuxNextTracking branch, master, updated. next-20160302

batman at open-mesh.org batman at open-mesh.org
Thu Mar 3 00:15:40 CET 2016


The following commit has been merged in the master branch:
commit 0744ff8fa8fad7aae669b73fd78f3efe1d8e31ca
Author: Linus Luessing <linus.luessing at web.de>
Date:   Sat Jan 16 16:40:08 2016 +0800

    batman-adv: Add hard_iface specific sysfs wrapper macros for UINT
    
    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 hard_iface (instead of
    bat_priv compared to the mesh variant).
    
    Developed by Linus during a 6 months trainee study period in
    Ascom (Switzerland) AG.
    
    Signed-off-by: Linus Luessing <linus.luessing at web.de>
    Signed-off-by: Marek Lindner <mareklindner at neomailbox.ch>
    [antonio at open-mesh.com: rename functions and move macros]
    Signed-off-by: Antonio Quartulli <antonio at open-mesh.com>

diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 4d70d44..d3f69d5 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -242,6 +242,55 @@ ssize_t batadv_show_vlan_##_name(struct kobject *kobj,			\
 	static BATADV_ATTR_VLAN(_name, _mode, batadv_show_vlan_##_name,	\
 				batadv_store_vlan_##_name)
 
+#define BATADV_ATTR_HIF_STORE_UINT(_name, _var, _min, _max, _post_func)	\
+ssize_t batadv_store_##_name(struct kobject *kobj,			\
+			     struct attribute *attr, char *buff,	\
+			     size_t count)				\
+{									\
+	struct net_device *net_dev = batadv_kobj_to_netdev(kobj);	\
+	struct batadv_hard_iface *hard_iface;				\
+	ssize_t length;							\
+									\
+	hard_iface = batadv_hardif_get_by_netdev(net_dev);		\
+	if (!hard_iface)						\
+		return 0;						\
+									\
+	length = __batadv_store_uint_attr(buff, count, _min, _max,	\
+					  _post_func, attr,		\
+					  &hard_iface->_var, net_dev);	\
+									\
+	batadv_hardif_put(hard_iface);				\
+	return length;							\
+}
+
+#define BATADV_ATTR_HIF_SHOW_UINT(_name, _var)				\
+ssize_t batadv_show_##_name(struct kobject *kobj,			\
+			    struct attribute *attr, char *buff)		\
+{									\
+	struct net_device *net_dev = batadv_kobj_to_netdev(kobj);	\
+	struct batadv_hard_iface *hard_iface;				\
+	ssize_t length;							\
+									\
+	hard_iface = batadv_hardif_get_by_netdev(net_dev);		\
+	if (!hard_iface)						\
+		return 0;						\
+									\
+	length = sprintf(buff, "%i\n", atomic_read(&hard_iface->_var));	\
+									\
+	batadv_hardif_put(hard_iface);				\
+	return length;							\
+}
+
+/* Use this, if you are going to set [name] in hard_iface to an
+ * unsigned integer value
+ */
+#define BATADV_ATTR_HIF_UINT(_name, _var, _mode, _min, _max, _post_func)\
+	static BATADV_ATTR_HIF_STORE_UINT(_name, _var, _min,		\
+					  _max, _post_func)		\
+	static BATADV_ATTR_HIF_SHOW_UINT(_name, _var)			\
+	static BATADV_ATTR(_name, _mode, batadv_show_##_name,		\
+			   batadv_store_##_name)
+
 static int batadv_store_bool_attr(char *buff, size_t count,
 				  struct net_device *net_dev,
 				  const char *attr_name, atomic_t *attr,

-- 
LinuxNextTracking


More information about the linux-merge mailing list