Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2008 Atheros Communications Inc. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #include "core.h" |
| 18 | |
| 19 | static unsigned int ath9k_debug = DBG_DEFAULT; |
| 20 | module_param_named(debug, ath9k_debug, uint, 0); |
| 21 | |
| 22 | void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...) |
| 23 | { |
| 24 | if (!sc) |
| 25 | return; |
| 26 | |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame^] | 27 | if (sc->sc_debug.debug_mask & dbg_mask) { |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 28 | va_list args; |
| 29 | |
| 30 | va_start(args, fmt); |
| 31 | printk(KERN_DEBUG "ath9k: "); |
| 32 | vprintk(fmt, args); |
| 33 | va_end(args); |
| 34 | } |
| 35 | } |
| 36 | |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame^] | 37 | int ath9k_init_debug(struct ath_softc *sc) |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 38 | { |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame^] | 39 | sc->sc_debug.debug_mask = ath9k_debug; |
| 40 | |
| 41 | sc->sc_debug.debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL); |
| 42 | if (!sc->sc_debug.debugfs_root) |
| 43 | goto err; |
| 44 | |
| 45 | sc->sc_debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy), |
| 46 | sc->sc_debug.debugfs_root); |
| 47 | if (!sc->sc_debug.debugfs_phy) |
| 48 | goto err; |
| 49 | |
| 50 | return 0; |
| 51 | err: |
| 52 | ath9k_exit_debug(sc); |
| 53 | return -ENOMEM; |
| 54 | } |
| 55 | |
| 56 | void ath9k_exit_debug(struct ath_softc *sc) |
| 57 | { |
| 58 | debugfs_remove(sc->sc_debug.debugfs_phy); |
| 59 | debugfs_remove(sc->sc_debug.debugfs_root); |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 60 | } |