diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/batman-adv/bat_sysfs.c | 43 |
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) \ | ||
121 | ssize_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) \ | ||
139 | ssize_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 | |||
120 | static int store_bool_attr(char *buff, size_t count, | 163 | static 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) |