| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * This file is part of wl1271 |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2009 Nokia Corporation |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Contact: Luciano Coelho <luciano.coelho@nokia.com> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or |
|---|
| 9 | | - * modify it under the terms of the GNU General Public License |
|---|
| 10 | | - * version 2 as published by the Free Software Foundation. |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 13 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 15 | | - * General Public License for more details. |
|---|
| 16 | | - * |
|---|
| 17 | | - * You should have received a copy of the GNU General Public License |
|---|
| 18 | | - * along with this program; if not, write to the Free Software |
|---|
| 19 | | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
|---|
| 20 | | - * 02110-1301 USA |
|---|
| 21 | | - * |
|---|
| 22 | 8 | */ |
|---|
| 23 | 9 | |
|---|
| 24 | 10 | #ifndef __DEBUGFS_H__ |
|---|
| .. | .. |
|---|
| 53 | 39 | |
|---|
| 54 | 40 | #define DEBUGFS_ADD(name, parent) \ |
|---|
| 55 | 41 | do { \ |
|---|
| 56 | | - entry = debugfs_create_file(#name, 0400, parent, \ |
|---|
| 57 | | - wl, &name## _ops); \ |
|---|
| 58 | | - if (!entry || IS_ERR(entry)) \ |
|---|
| 59 | | - goto err; \ |
|---|
| 42 | + debugfs_create_file(#name, 0400, parent, \ |
|---|
| 43 | + wl, &name## _ops); \ |
|---|
| 60 | 44 | } while (0) |
|---|
| 61 | 45 | |
|---|
| 62 | 46 | |
|---|
| 63 | 47 | #define DEBUGFS_ADD_PREFIX(prefix, name, parent) \ |
|---|
| 64 | 48 | do { \ |
|---|
| 65 | | - entry = debugfs_create_file(#name, 0400, parent, \ |
|---|
| 49 | + debugfs_create_file(#name, 0400, parent, \ |
|---|
| 66 | 50 | wl, &prefix## _## name## _ops); \ |
|---|
| 67 | | - if (!entry || IS_ERR(entry)) \ |
|---|
| 68 | | - goto err; \ |
|---|
| 69 | 51 | } while (0) |
|---|
| 70 | 52 | |
|---|
| 71 | 53 | #define DEBUGFS_FWSTATS_FILE(sub, name, fmt, struct_type) \ |
|---|
| .. | .. |
|---|
| 96 | 78 | struct wl1271 *wl = file->private_data; \ |
|---|
| 97 | 79 | struct struct_type *stats = wl->stats.fw_stats; \ |
|---|
| 98 | 80 | char buf[DEBUGFS_FORMAT_BUFFER_SIZE] = ""; \ |
|---|
| 99 | | - int res, i; \ |
|---|
| 81 | + int pos = 0; \ |
|---|
| 82 | + int i; \ |
|---|
| 100 | 83 | \ |
|---|
| 101 | 84 | wl1271_debugfs_update_stats(wl); \ |
|---|
| 102 | 85 | \ |
|---|
| 103 | | - for (i = 0; i < len; i++) \ |
|---|
| 104 | | - res = snprintf(buf, sizeof(buf), "%s[%d] = %d\n", \ |
|---|
| 105 | | - buf, i, stats->sub.name[i]); \ |
|---|
| 86 | + for (i = 0; i < len && pos < sizeof(buf); i++) \ |
|---|
| 87 | + pos += snprintf(buf + pos, sizeof(buf) - pos, \ |
|---|
| 88 | + "[%d] = %d\n", i, stats->sub.name[i]); \ |
|---|
| 106 | 89 | \ |
|---|
| 107 | 90 | return wl1271_format_buffer(userbuf, count, ppos, "%s", buf); \ |
|---|
| 108 | 91 | } \ |
|---|