.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * This file is part of wl1251 |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2009 Nokia Corporation |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or |
---|
7 | | - * modify it under the terms of the GNU General Public License |
---|
8 | | - * version 2 as published by the Free Software Foundation. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, but |
---|
11 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
13 | | - * General Public License for more details. |
---|
14 | | - * |
---|
15 | | - * You should have received a copy of the GNU General Public License |
---|
16 | | - * along with this program; if not, write to the Free Software |
---|
17 | | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
---|
18 | | - * 02110-1301 USA |
---|
19 | | - * |
---|
20 | 6 | */ |
---|
21 | 7 | |
---|
22 | 8 | #include "debugfs.h" |
---|
.. | .. |
---|
54 | 40 | #define DEBUGFS_ADD(name, parent) \ |
---|
55 | 41 | wl->debugfs.name = debugfs_create_file(#name, 0400, parent, \ |
---|
56 | 42 | wl, &name## _ops); \ |
---|
57 | | - if (IS_ERR(wl->debugfs.name)) { \ |
---|
58 | | - ret = PTR_ERR(wl->debugfs.name); \ |
---|
59 | | - wl->debugfs.name = NULL; \ |
---|
60 | | - goto out; \ |
---|
61 | | - } |
---|
62 | 43 | |
---|
63 | 44 | #define DEBUGFS_DEL(name) \ |
---|
64 | 45 | do { \ |
---|
.. | .. |
---|
354 | 335 | DEBUGFS_DEL(excessive_retries); |
---|
355 | 336 | } |
---|
356 | 337 | |
---|
357 | | -static int wl1251_debugfs_add_files(struct wl1251 *wl) |
---|
| 338 | +static void wl1251_debugfs_add_files(struct wl1251 *wl) |
---|
358 | 339 | { |
---|
359 | | - int ret = 0; |
---|
360 | | - |
---|
361 | 340 | DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow); |
---|
362 | 341 | |
---|
363 | 342 | DEBUGFS_FWSTATS_ADD(rx, out_of_mem); |
---|
.. | .. |
---|
453 | 432 | DEBUGFS_ADD(tx_queue_status, wl->debugfs.rootdir); |
---|
454 | 433 | DEBUGFS_ADD(retry_count, wl->debugfs.rootdir); |
---|
455 | 434 | DEBUGFS_ADD(excessive_retries, wl->debugfs.rootdir); |
---|
456 | | - |
---|
457 | | -out: |
---|
458 | | - if (ret < 0) |
---|
459 | | - wl1251_debugfs_delete_files(wl); |
---|
460 | | - |
---|
461 | | - return ret; |
---|
462 | 435 | } |
---|
463 | 436 | |
---|
464 | 437 | void wl1251_debugfs_reset(struct wl1251 *wl) |
---|
.. | .. |
---|
471 | 444 | |
---|
472 | 445 | int wl1251_debugfs_init(struct wl1251 *wl) |
---|
473 | 446 | { |
---|
474 | | - int ret; |
---|
| 447 | + wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats), GFP_KERNEL); |
---|
| 448 | + if (!wl->stats.fw_stats) |
---|
| 449 | + return -ENOMEM; |
---|
475 | 450 | |
---|
476 | 451 | wl->debugfs.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL); |
---|
477 | | - |
---|
478 | | - if (IS_ERR(wl->debugfs.rootdir)) { |
---|
479 | | - ret = PTR_ERR(wl->debugfs.rootdir); |
---|
480 | | - wl->debugfs.rootdir = NULL; |
---|
481 | | - goto err; |
---|
482 | | - } |
---|
483 | 452 | |
---|
484 | 453 | wl->debugfs.fw_statistics = debugfs_create_dir("fw-statistics", |
---|
485 | 454 | wl->debugfs.rootdir); |
---|
486 | 455 | |
---|
487 | | - if (IS_ERR(wl->debugfs.fw_statistics)) { |
---|
488 | | - ret = PTR_ERR(wl->debugfs.fw_statistics); |
---|
489 | | - wl->debugfs.fw_statistics = NULL; |
---|
490 | | - goto err_root; |
---|
491 | | - } |
---|
492 | | - |
---|
493 | | - wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats), |
---|
494 | | - GFP_KERNEL); |
---|
495 | | - |
---|
496 | | - if (!wl->stats.fw_stats) { |
---|
497 | | - ret = -ENOMEM; |
---|
498 | | - goto err_fw; |
---|
499 | | - } |
---|
500 | | - |
---|
501 | 456 | wl->stats.fw_stats_update = jiffies; |
---|
502 | 457 | |
---|
503 | | - ret = wl1251_debugfs_add_files(wl); |
---|
504 | | - |
---|
505 | | - if (ret < 0) |
---|
506 | | - goto err_file; |
---|
| 458 | + wl1251_debugfs_add_files(wl); |
---|
507 | 459 | |
---|
508 | 460 | return 0; |
---|
509 | | - |
---|
510 | | -err_file: |
---|
511 | | - kfree(wl->stats.fw_stats); |
---|
512 | | - wl->stats.fw_stats = NULL; |
---|
513 | | - |
---|
514 | | -err_fw: |
---|
515 | | - debugfs_remove(wl->debugfs.fw_statistics); |
---|
516 | | - wl->debugfs.fw_statistics = NULL; |
---|
517 | | - |
---|
518 | | -err_root: |
---|
519 | | - debugfs_remove(wl->debugfs.rootdir); |
---|
520 | | - wl->debugfs.rootdir = NULL; |
---|
521 | | - |
---|
522 | | -err: |
---|
523 | | - return ret; |
---|
524 | 461 | } |
---|
525 | 462 | |
---|
526 | 463 | void wl1251_debugfs_exit(struct wl1251 *wl) |
---|