Commit 0744ff8f authored by Linus Luessing's avatar Linus Luessing Committed by Antonio Quartulli

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: default avatarLinus Luessing <linus.luessing@web.de>
Signed-off-by: default avatarMarek Lindner <mareklindner@neomailbox.ch>
[antonio@open-mesh.com: rename functions and move macros]
Signed-off-by: default avatarAntonio Quartulli <antonio@open-mesh.com>
parent f12d33f4
...@@ -242,6 +242,55 @@ ssize_t batadv_show_vlan_##_name(struct kobject *kobj, \ ...@@ -242,6 +242,55 @@ ssize_t batadv_show_vlan_##_name(struct kobject *kobj, \
static BATADV_ATTR_VLAN(_name, _mode, batadv_show_vlan_##_name, \ static BATADV_ATTR_VLAN(_name, _mode, batadv_show_vlan_##_name, \
batadv_store_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, static int batadv_store_bool_attr(char *buff, size_t count,
struct net_device *net_dev, struct net_device *net_dev,
const char *attr_name, atomic_t *attr, const char *attr_name, atomic_t *attr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment