aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLinus Luessing <linus.luessing@web.de>2016-01-16 03:40:08 -0500
committerAntonio Quartulli <a@unstable.cc>2016-02-29 03:05:29 -0500
commit0744ff8fa8fad7aae669b73fd78f3efe1d8e31ca (patch)
tree2b77cc58902d48ea182e774f485238f9b190eb8f /net
parentf12d33f4d83c6837d176e1aef337914089c77957 (diff)
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@web.de> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch> [antonio@open-mesh.com: rename functions and move macros] Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Diffstat (limited to 'net')
-rw-r--r--net/batman-adv/sysfs.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 4d70d4413e40..d3f69d5e79d9 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, \
242 static BATADV_ATTR_VLAN(_name, _mode, batadv_show_vlan_##_name, \ 242 static BATADV_ATTR_VLAN(_name, _mode, batadv_show_vlan_##_name, \
243 batadv_store_vlan_##_name) 243 batadv_store_vlan_##_name)
244 244
245#define BATADV_ATTR_HIF_STORE_UINT(_name, _var, _min, _max, _post_func) \
246ssize_t batadv_store_##_name(struct kobject *kobj, \
247 struct attribute *attr, char *buff, \
248 size_t count) \
249{ \
250 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
251 struct batadv_hard_iface *hard_iface; \
252 ssize_t length; \
253 \
254 hard_iface = batadv_hardif_get_by_netdev(net_dev); \
255 if (!hard_iface) \
256 return 0; \
257 \
258 length = __batadv_store_uint_attr(buff, count, _min, _max, \
259 _post_func, attr, \
260 &hard_iface->_var, net_dev); \
261 \
262 batadv_hardif_put(hard_iface); \
263 return length; \
264}
265
266#define BATADV_ATTR_HIF_SHOW_UINT(_name, _var) \
267ssize_t batadv_show_##_name(struct kobject *kobj, \
268 struct attribute *attr, char *buff) \
269{ \
270 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \
271 struct batadv_hard_iface *hard_iface; \
272 ssize_t length; \
273 \
274 hard_iface = batadv_hardif_get_by_netdev(net_dev); \
275 if (!hard_iface) \
276 return 0; \
277 \
278 length = sprintf(buff, "%i\n", atomic_read(&hard_iface->_var)); \
279 \
280 batadv_hardif_put(hard_iface); \
281 return length; \
282}
283
284/* Use this, if you are going to set [name] in hard_iface to an
285 * unsigned integer value
286 */
287#define BATADV_ATTR_HIF_UINT(_name, _var, _mode, _min, _max, _post_func)\
288 static BATADV_ATTR_HIF_STORE_UINT(_name, _var, _min, \
289 _max, _post_func) \
290 static BATADV_ATTR_HIF_SHOW_UINT(_name, _var) \
291 static BATADV_ATTR(_name, _mode, batadv_show_##_name, \
292 batadv_store_##_name)
293
245static int batadv_store_bool_attr(char *buff, size_t count, 294static int batadv_store_bool_attr(char *buff, size_t count,
246 struct net_device *net_dev, 295 struct net_device *net_dev,
247 const char *attr_name, atomic_t *attr, 296 const char *attr_name, atomic_t *attr,