blob: c146e484ef54d2a35fc2e4b3cb7012f7e9408b8c [file] [log] [blame]
Sujith88b126a2008-11-28 22:19:02 +05301/*
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
19static unsigned int ath9k_debug = DBG_DEFAULT;
20module_param_named(debug, ath9k_debug, uint, 0);
21
22void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...)
23{
24 if (!sc)
25 return;
26
Sujith826d2682008-11-28 22:20:23 +053027 if (sc->sc_debug.debug_mask & dbg_mask) {
Sujith88b126a2008-11-28 22:19:02 +053028 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
Sujith826d2682008-11-28 22:20:23 +053037int ath9k_init_debug(struct ath_softc *sc)
Sujith88b126a2008-11-28 22:19:02 +053038{
Sujith826d2682008-11-28 22:20:23 +053039 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;
51err:
52 ath9k_exit_debug(sc);
53 return -ENOMEM;
54}
55
56void ath9k_exit_debug(struct ath_softc *sc)
57{
58 debugfs_remove(sc->sc_debug.debugfs_phy);
59 debugfs_remove(sc->sc_debug.debugfs_root);
Sujith88b126a2008-11-28 22:19:02 +053060}