.. | .. |
---|
1 | | -/* This program is free software; you can redistribute it and/or modify |
---|
2 | | - * it under the terms of the GNU General Public License version 2 |
---|
3 | | - * as published by the Free Software Foundation. |
---|
4 | | - * |
---|
5 | | - * This program is distributed in the hope that it will be useful, |
---|
6 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
7 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
8 | | - * GNU General Public License for more details. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
| 2 | +/* |
---|
9 | 3 | * |
---|
10 | 4 | * Authors: |
---|
11 | 5 | * (C) 2015 Pengutronix, Alexander Aring <aar@pengutronix.de> |
---|
.. | .. |
---|
41 | 35 | return 0; |
---|
42 | 36 | } |
---|
43 | 37 | |
---|
44 | | -DEFINE_SIMPLE_ATTRIBUTE(lowpan_ctx_flag_active_fops, |
---|
45 | | - lowpan_ctx_flag_active_get, |
---|
46 | | - lowpan_ctx_flag_active_set, "%llu\n"); |
---|
| 38 | +DEFINE_DEBUGFS_ATTRIBUTE(lowpan_ctx_flag_active_fops, |
---|
| 39 | + lowpan_ctx_flag_active_get, |
---|
| 40 | + lowpan_ctx_flag_active_set, "%llu\n"); |
---|
47 | 41 | |
---|
48 | 42 | static int lowpan_ctx_flag_c_set(void *data, u64 val) |
---|
49 | 43 | { |
---|
.. | .. |
---|
66 | 60 | return 0; |
---|
67 | 61 | } |
---|
68 | 62 | |
---|
69 | | -DEFINE_SIMPLE_ATTRIBUTE(lowpan_ctx_flag_c_fops, lowpan_ctx_flag_c_get, |
---|
70 | | - lowpan_ctx_flag_c_set, "%llu\n"); |
---|
| 63 | +DEFINE_DEBUGFS_ATTRIBUTE(lowpan_ctx_flag_c_fops, lowpan_ctx_flag_c_get, |
---|
| 64 | + lowpan_ctx_flag_c_set, "%llu\n"); |
---|
71 | 65 | |
---|
72 | 66 | static int lowpan_ctx_plen_set(void *data, u64 val) |
---|
73 | 67 | { |
---|
.. | .. |
---|
97 | 91 | return 0; |
---|
98 | 92 | } |
---|
99 | 93 | |
---|
100 | | -DEFINE_SIMPLE_ATTRIBUTE(lowpan_ctx_plen_fops, lowpan_ctx_plen_get, |
---|
101 | | - lowpan_ctx_plen_set, "%llu\n"); |
---|
| 94 | +DEFINE_DEBUGFS_ATTRIBUTE(lowpan_ctx_plen_fops, lowpan_ctx_plen_get, |
---|
| 95 | + lowpan_ctx_plen_set, "%llu\n"); |
---|
102 | 96 | |
---|
103 | 97 | static int lowpan_ctx_pfx_show(struct seq_file *file, void *offset) |
---|
104 | 98 | { |
---|
.. | .. |
---|
169 | 163 | .release = single_release, |
---|
170 | 164 | }; |
---|
171 | 165 | |
---|
172 | | -static int lowpan_dev_debugfs_ctx_init(struct net_device *dev, |
---|
173 | | - struct dentry *ctx, u8 id) |
---|
| 166 | +static void lowpan_dev_debugfs_ctx_init(struct net_device *dev, |
---|
| 167 | + struct dentry *ctx, u8 id) |
---|
174 | 168 | { |
---|
175 | 169 | struct lowpan_dev *ldev = lowpan_dev(dev); |
---|
176 | | - struct dentry *dentry, *root; |
---|
| 170 | + struct dentry *root; |
---|
177 | 171 | char buf[32]; |
---|
178 | 172 | |
---|
179 | | - WARN_ON_ONCE(id > LOWPAN_IPHC_CTX_TABLE_SIZE); |
---|
| 173 | + if (WARN_ON_ONCE(id >= LOWPAN_IPHC_CTX_TABLE_SIZE)) |
---|
| 174 | + return; |
---|
180 | 175 | |
---|
181 | 176 | sprintf(buf, "%d", id); |
---|
182 | 177 | |
---|
183 | 178 | root = debugfs_create_dir(buf, ctx); |
---|
184 | | - if (!root) |
---|
185 | | - return -EINVAL; |
---|
186 | 179 | |
---|
187 | | - dentry = debugfs_create_file("active", 0644, root, |
---|
188 | | - &ldev->ctx.table[id], |
---|
189 | | - &lowpan_ctx_flag_active_fops); |
---|
190 | | - if (!dentry) |
---|
191 | | - return -EINVAL; |
---|
| 180 | + debugfs_create_file("active", 0644, root, &ldev->ctx.table[id], |
---|
| 181 | + &lowpan_ctx_flag_active_fops); |
---|
192 | 182 | |
---|
193 | | - dentry = debugfs_create_file("compression", 0644, root, |
---|
194 | | - &ldev->ctx.table[id], |
---|
195 | | - &lowpan_ctx_flag_c_fops); |
---|
196 | | - if (!dentry) |
---|
197 | | - return -EINVAL; |
---|
| 183 | + debugfs_create_file("compression", 0644, root, &ldev->ctx.table[id], |
---|
| 184 | + &lowpan_ctx_flag_c_fops); |
---|
198 | 185 | |
---|
199 | | - dentry = debugfs_create_file("prefix", 0644, root, |
---|
200 | | - &ldev->ctx.table[id], |
---|
201 | | - &lowpan_ctx_pfx_fops); |
---|
202 | | - if (!dentry) |
---|
203 | | - return -EINVAL; |
---|
| 186 | + debugfs_create_file("prefix", 0644, root, &ldev->ctx.table[id], |
---|
| 187 | + &lowpan_ctx_pfx_fops); |
---|
204 | 188 | |
---|
205 | | - dentry = debugfs_create_file("prefix_len", 0644, root, |
---|
206 | | - &ldev->ctx.table[id], |
---|
207 | | - &lowpan_ctx_plen_fops); |
---|
208 | | - if (!dentry) |
---|
209 | | - return -EINVAL; |
---|
210 | | - |
---|
211 | | - return 0; |
---|
| 189 | + debugfs_create_file("prefix_len", 0644, root, &ldev->ctx.table[id], |
---|
| 190 | + &lowpan_ctx_plen_fops); |
---|
212 | 191 | } |
---|
213 | 192 | |
---|
214 | 193 | static int lowpan_context_show(struct seq_file *file, void *offset) |
---|
.. | .. |
---|
232 | 211 | |
---|
233 | 212 | return 0; |
---|
234 | 213 | } |
---|
235 | | - |
---|
236 | | -static int lowpan_context_open(struct inode *inode, struct file *file) |
---|
237 | | -{ |
---|
238 | | - return single_open(file, lowpan_context_show, inode->i_private); |
---|
239 | | -} |
---|
240 | | - |
---|
241 | | -static const struct file_operations lowpan_context_fops = { |
---|
242 | | - .open = lowpan_context_open, |
---|
243 | | - .read = seq_read, |
---|
244 | | - .llseek = seq_lseek, |
---|
245 | | - .release = single_release, |
---|
246 | | -}; |
---|
| 214 | +DEFINE_SHOW_ATTRIBUTE(lowpan_context); |
---|
247 | 215 | |
---|
248 | 216 | static int lowpan_short_addr_get(void *data, u64 *val) |
---|
249 | 217 | { |
---|
.. | .. |
---|
256 | 224 | return 0; |
---|
257 | 225 | } |
---|
258 | 226 | |
---|
259 | | -DEFINE_SIMPLE_ATTRIBUTE(lowpan_short_addr_fops, lowpan_short_addr_get, |
---|
260 | | - NULL, "0x%04llx\n"); |
---|
| 227 | +DEFINE_DEBUGFS_ATTRIBUTE(lowpan_short_addr_fops, lowpan_short_addr_get, NULL, |
---|
| 228 | + "0x%04llx\n"); |
---|
261 | 229 | |
---|
262 | | -static int lowpan_dev_debugfs_802154_init(const struct net_device *dev, |
---|
| 230 | +static void lowpan_dev_debugfs_802154_init(const struct net_device *dev, |
---|
263 | 231 | struct lowpan_dev *ldev) |
---|
264 | 232 | { |
---|
265 | | - struct dentry *dentry, *root; |
---|
| 233 | + struct dentry *root; |
---|
266 | 234 | |
---|
267 | 235 | if (!lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154)) |
---|
268 | | - return 0; |
---|
| 236 | + return; |
---|
269 | 237 | |
---|
270 | 238 | root = debugfs_create_dir("ieee802154", ldev->iface_debugfs); |
---|
271 | | - if (!root) |
---|
272 | | - return -EINVAL; |
---|
273 | 239 | |
---|
274 | | - dentry = debugfs_create_file("short_addr", 0444, root, |
---|
275 | | - lowpan_802154_dev(dev)->wdev->ieee802154_ptr, |
---|
276 | | - &lowpan_short_addr_fops); |
---|
277 | | - if (!dentry) |
---|
278 | | - return -EINVAL; |
---|
279 | | - |
---|
280 | | - return 0; |
---|
| 240 | + debugfs_create_file("short_addr", 0444, root, |
---|
| 241 | + lowpan_802154_dev(dev)->wdev->ieee802154_ptr, |
---|
| 242 | + &lowpan_short_addr_fops); |
---|
281 | 243 | } |
---|
282 | 244 | |
---|
283 | | -int lowpan_dev_debugfs_init(struct net_device *dev) |
---|
| 245 | +void lowpan_dev_debugfs_init(struct net_device *dev) |
---|
284 | 246 | { |
---|
285 | 247 | struct lowpan_dev *ldev = lowpan_dev(dev); |
---|
286 | | - struct dentry *contexts, *dentry; |
---|
287 | | - int ret, i; |
---|
| 248 | + struct dentry *contexts; |
---|
| 249 | + int i; |
---|
288 | 250 | |
---|
289 | 251 | /* creating the root */ |
---|
290 | 252 | ldev->iface_debugfs = debugfs_create_dir(dev->name, lowpan_debugfs); |
---|
291 | | - if (!ldev->iface_debugfs) |
---|
292 | | - goto fail; |
---|
293 | 253 | |
---|
294 | 254 | contexts = debugfs_create_dir("contexts", ldev->iface_debugfs); |
---|
295 | | - if (!contexts) |
---|
296 | | - goto remove_root; |
---|
297 | 255 | |
---|
298 | | - dentry = debugfs_create_file("show", 0644, contexts, |
---|
299 | | - &lowpan_dev(dev)->ctx, |
---|
300 | | - &lowpan_context_fops); |
---|
301 | | - if (!dentry) |
---|
302 | | - goto remove_root; |
---|
| 256 | + debugfs_create_file("show", 0644, contexts, &lowpan_dev(dev)->ctx, |
---|
| 257 | + &lowpan_context_fops); |
---|
303 | 258 | |
---|
304 | | - for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++) { |
---|
305 | | - ret = lowpan_dev_debugfs_ctx_init(dev, contexts, i); |
---|
306 | | - if (ret < 0) |
---|
307 | | - goto remove_root; |
---|
308 | | - } |
---|
| 259 | + for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++) |
---|
| 260 | + lowpan_dev_debugfs_ctx_init(dev, contexts, i); |
---|
309 | 261 | |
---|
310 | | - ret = lowpan_dev_debugfs_802154_init(dev, ldev); |
---|
311 | | - if (ret < 0) |
---|
312 | | - goto remove_root; |
---|
313 | | - |
---|
314 | | - return 0; |
---|
315 | | - |
---|
316 | | -remove_root: |
---|
317 | | - lowpan_dev_debugfs_exit(dev); |
---|
318 | | -fail: |
---|
319 | | - return -EINVAL; |
---|
| 262 | + lowpan_dev_debugfs_802154_init(dev, ldev); |
---|
320 | 263 | } |
---|
321 | 264 | |
---|
322 | 265 | void lowpan_dev_debugfs_exit(struct net_device *dev) |
---|
.. | .. |
---|
324 | 267 | debugfs_remove_recursive(lowpan_dev(dev)->iface_debugfs); |
---|
325 | 268 | } |
---|
326 | 269 | |
---|
327 | | -int __init lowpan_debugfs_init(void) |
---|
| 270 | +void __init lowpan_debugfs_init(void) |
---|
328 | 271 | { |
---|
329 | 272 | lowpan_debugfs = debugfs_create_dir("6lowpan", NULL); |
---|
330 | | - if (!lowpan_debugfs) |
---|
331 | | - return -EINVAL; |
---|
332 | | - |
---|
333 | | - return 0; |
---|
334 | 273 | } |
---|
335 | 274 | |
---|
336 | 275 | void lowpan_debugfs_exit(void) |
---|