aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/bat_sysfs.c
diff options
context:
space:
mode:
authorLinus Luessing <linus.luessing@web.de>2012-03-10 17:17:52 -0500
committerAntonio Quartulli <ordex@autistici.org>2012-05-11 07:56:03 -0400
commit9d853f624691776232a675768bcdb239d7b837ea (patch)
treef329ab2db9f0faba5720d0dc905cfa3947a7b70d /net/batman-adv/bat_sysfs.c
parentf245c38ba74e1433294b5f41c9d6eb3e97b88e5b (diff)
batman-adv: Adding 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 <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/bat_sysfs.c')
-rw-r--r--net/batman-adv/bat_sysfs.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c
index 913299d03f4a..5bc7b66d32dc 100644
--- a/net/batman-adv/bat_sysfs.c
+++ b/net/batman-adv/bat_sysfs.c
@@ -117,6 +117,49 @@ ssize_t show_##_name(struct kobject *kobj, \
117 static BAT_ATTR(_name, _mode, show_##_name, store_##_name) 117 static BAT_ATTR(_name, _mode, show_##_name, store_##_name)
118 118
119 119
120#define BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \
121ssize_t store_##_name(struct kobject *kobj, struct attribute *attr, \
122 char *buff, size_t count) \
123{ \
124 struct net_device *net_dev = kobj_to_netdev(kobj); \
125 struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); \
126 ssize_t length; \
127 \
128 if (!hard_iface) \
129 return 0; \
130 \
131 length = __store_uint_attr(buff, count, _min, _max, _post_func, \
132 attr, &hard_iface->_name, net_dev); \
133 \
134 hardif_free_ref(hard_iface); \
135 return length; \
136}
137
138#define BAT_ATTR_HIF_SHOW_UINT(_name) \
139ssize_t show_##_name(struct kobject *kobj, \
140 struct attribute *attr, char *buff) \
141{ \
142 struct net_device *net_dev = kobj_to_netdev(kobj); \
143 struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); \
144 ssize_t length; \
145 \
146 if (!hard_iface) \
147 return 0; \
148 \
149 length = sprintf(buff, "%i\n", atomic_read(&hard_iface->_name));\
150 \
151 hardif_free_ref(hard_iface); \
152 return length; \
153}
154
155/* Use this, if you are going to set [name] in hard_iface to an
156 * unsigned integer value*/
157#define BAT_ATTR_HIF_UINT(_name, _mode, _min, _max, _post_func) \
158 static BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \
159 static BAT_ATTR_HIF_SHOW_UINT(_name) \
160 static BAT_ATTR(_name, _mode, show_##_name, store_##_name)
161
162
120static int store_bool_attr(char *buff, size_t count, 163static int store_bool_attr(char *buff, size_t count,
121 struct net_device *net_dev, 164 struct net_device *net_dev,
122 const char *attr_name, atomic_t *attr) 165 const char *attr_name, atomic_t *attr)