| .. | .. |
|---|
| 1 | | -/****************************************************************************** |
|---|
| 2 | | - * |
|---|
| 3 | | - * Copyright(c) 2009-2012 Realtek Corporation. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms of version 2 of the GNU General Public License as |
|---|
| 7 | | - * published by the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 10 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 11 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 12 | | - * more details. |
|---|
| 13 | | - * |
|---|
| 14 | | - * The full GNU General Public License is included in this distribution in the |
|---|
| 15 | | - * file called LICENSE. |
|---|
| 16 | | - * |
|---|
| 17 | | - * Contact Information: |
|---|
| 18 | | - * wlanfae <wlanfae@realtek.com> |
|---|
| 19 | | - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, |
|---|
| 20 | | - * Hsinchu 300, Taiwan. |
|---|
| 21 | | - * |
|---|
| 22 | | - * Larry Finger <Larry.Finger@lwfinger.net> |
|---|
| 23 | | - *****************************************************************************/ |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | +/* Copyright(c) 2009-2012 Realtek Corporation.*/ |
|---|
| 24 | 3 | |
|---|
| 25 | 4 | #include "wifi.h" |
|---|
| 26 | 5 | #include "cam.h" |
|---|
| .. | .. |
|---|
| 29 | 8 | #include <linux/vmalloc.h> |
|---|
| 30 | 9 | |
|---|
| 31 | 10 | #ifdef CONFIG_RTLWIFI_DEBUG |
|---|
| 32 | | -void _rtl_dbg_trace(struct rtl_priv *rtlpriv, u64 comp, int level, |
|---|
| 33 | | - const char *fmt, ...) |
|---|
| 34 | | -{ |
|---|
| 35 | | - if (unlikely((comp & rtlpriv->cfg->mod_params->debug_mask) && |
|---|
| 36 | | - level <= rtlpriv->cfg->mod_params->debug_level)) { |
|---|
| 37 | | - struct va_format vaf; |
|---|
| 38 | | - va_list args; |
|---|
| 39 | | - |
|---|
| 40 | | - va_start(args, fmt); |
|---|
| 41 | | - |
|---|
| 42 | | - vaf.fmt = fmt; |
|---|
| 43 | | - vaf.va = &args; |
|---|
| 44 | | - |
|---|
| 45 | | - pr_info(":<%lx> %pV", in_interrupt(), &vaf); |
|---|
| 46 | | - |
|---|
| 47 | | - va_end(args); |
|---|
| 48 | | - } |
|---|
| 49 | | -} |
|---|
| 50 | | -EXPORT_SYMBOL_GPL(_rtl_dbg_trace); |
|---|
| 51 | | - |
|---|
| 52 | 11 | void _rtl_dbg_print(struct rtl_priv *rtlpriv, u64 comp, int level, |
|---|
| 53 | 12 | const char *fmt, ...) |
|---|
| 54 | 13 | { |
|---|
| .. | .. |
|---|
| 370 | 329 | |
|---|
| 371 | 330 | tmp_len = (count > sizeof(tmp) - 1 ? sizeof(tmp) - 1 : count); |
|---|
| 372 | 331 | |
|---|
| 373 | | - if (!buffer || copy_from_user(tmp, buffer, tmp_len)) |
|---|
| 374 | | - return count; |
|---|
| 332 | + if (copy_from_user(tmp, buffer, tmp_len)) |
|---|
| 333 | + return -EFAULT; |
|---|
| 375 | 334 | |
|---|
| 376 | 335 | tmp[tmp_len] = '\0'; |
|---|
| 377 | 336 | |
|---|
| .. | .. |
|---|
| 381 | 340 | &h2c_data[4], &h2c_data[5], |
|---|
| 382 | 341 | &h2c_data[6], &h2c_data[7]); |
|---|
| 383 | 342 | |
|---|
| 384 | | - if (h2c_len <= 0) |
|---|
| 385 | | - return count; |
|---|
| 343 | + if (h2c_len == 0) |
|---|
| 344 | + return -EINVAL; |
|---|
| 386 | 345 | |
|---|
| 387 | 346 | for (i = 0; i < h2c_len; i++) |
|---|
| 388 | 347 | h2c_data_packed[i] = (u8)h2c_data[i]; |
|---|
| .. | .. |
|---|
| 425 | 384 | &path, &addr, &bitmask, &data); |
|---|
| 426 | 385 | |
|---|
| 427 | 386 | if (num != 4) { |
|---|
| 428 | | - RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG, |
|---|
| 429 | | - "Format is <path> <addr> <mask> <data>\n"); |
|---|
| 387 | + rtl_dbg(rtlpriv, COMP_ERR, DBG_DMESG, |
|---|
| 388 | + "Format is <path> <addr> <mask> <data>\n"); |
|---|
| 430 | 389 | return count; |
|---|
| 431 | 390 | } |
|---|
| 432 | 391 | |
|---|
| .. | .. |
|---|
| 463 | 422 | #define RTL_DEBUGFS_ADD_CORE(name, mode, fopname) \ |
|---|
| 464 | 423 | do { \ |
|---|
| 465 | 424 | rtl_debug_priv_ ##name.rtlpriv = rtlpriv; \ |
|---|
| 466 | | - if (!debugfs_create_file(#name, mode, \ |
|---|
| 467 | | - parent, &rtl_debug_priv_ ##name, \ |
|---|
| 468 | | - &file_ops_ ##fopname)) \ |
|---|
| 469 | | - pr_err("Unable to initialize debugfs:%s/%s\n", \ |
|---|
| 470 | | - rtlpriv->dbg.debugfs_name, \ |
|---|
| 471 | | - #name); \ |
|---|
| 425 | + debugfs_create_file(#name, mode, parent, \ |
|---|
| 426 | + &rtl_debug_priv_ ##name, \ |
|---|
| 427 | + &file_ops_ ##fopname); \ |
|---|
| 472 | 428 | } while (0) |
|---|
| 473 | 429 | |
|---|
| 474 | 430 | #define RTL_DEBUGFS_ADD(name) \ |
|---|
| .. | .. |
|---|
| 486 | 442 | |
|---|
| 487 | 443 | rtlpriv->dbg.debugfs_dir = |
|---|
| 488 | 444 | debugfs_create_dir(rtlpriv->dbg.debugfs_name, debugfs_topdir); |
|---|
| 489 | | - if (!rtlpriv->dbg.debugfs_dir) { |
|---|
| 490 | | - pr_err("Unable to init debugfs:/%s/%s\n", rtlpriv->cfg->name, |
|---|
| 491 | | - rtlpriv->dbg.debugfs_name); |
|---|
| 492 | | - return; |
|---|
| 493 | | - } |
|---|
| 494 | 445 | |
|---|
| 495 | 446 | parent = rtlpriv->dbg.debugfs_dir; |
|---|
| 496 | 447 | |
|---|