From patchwork Fri Aug 23 08:58:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugene Krasnikov X-Patchwork-Id: 2848629 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0BF1DBF546 for ; Fri, 23 Aug 2013 08:59:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BD46F202DD for ; Fri, 23 Aug 2013 08:59:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE3AB202EA for ; Fri, 23 Aug 2013 08:59:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754982Ab3HWI70 (ORCPT ); Fri, 23 Aug 2013 04:59:26 -0400 Received: from mail-lb0-f180.google.com ([209.85.217.180]:54008 "EHLO mail-lb0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755161Ab3HWI7Y (ORCPT ); Fri, 23 Aug 2013 04:59:24 -0400 Received: by mail-lb0-f180.google.com with SMTP id a16so278323lbj.11 for ; Fri, 23 Aug 2013 01:59:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vGZ4z2DPi4usFm12dNrgxh1dlRUAVUCFROOjGWMDYIE=; b=C5KzKtKIzL31/lmILVUpnc5QSfy3hR3UBs0H3bdb04Oym+xy4bgeSOzdxng3e/uaLO B5z6RW6f29HLh2kGGQx30GACMNXM+vD8XV0payp8a7L2kjr7bWEcfSGt9vUCmmpEz5Xp OsSH5FLYrfKHqLYrLle0ti8NGvpfY+6MQu+wjHm7AdlLITNWLXmOqEsq/mj5ZzzPHRrt NN+W3oZQ9VRTuCWzCL0tvWgnLScuqeHQcyfPDltdR5A31kl4LjcWHVPMQjGte6FwsEZO +GvLDBBIPpTE1DRlx6Lecve2/3Wp7HoEhDf6S9+rhTlVGlTo8D1FqcXvXsCXdbKdrmVO 4usg== X-Received: by 10.152.45.106 with SMTP id l10mr14655484lam.12.1377248362457; Fri, 23 Aug 2013 01:59:22 -0700 (PDT) Received: from seldlx6523.corpusers.net. (host-95-195-223-171.mobileonline.telia.com. [95.195.223.171]) by mx.google.com with ESMTPSA id bg3sm3436442lbb.15.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 23 Aug 2013 01:59:21 -0700 (PDT) From: Eugene Krasnikov To: linux-wireless@vger.kernel.org Cc: wcn36xx@lists.infradead.org, Eugene Krasnikov Subject: [PATCH v2 02/16] wcn36xx: add debug.c Date: Fri, 23 Aug 2013 10:58:05 +0200 Message-Id: <1377248299-21007-3-git-send-email-k.eugene.e@gmail.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1377248299-21007-1-git-send-email-k.eugene.e@gmail.com> References: <1377248299-21007-1-git-send-email-k.eugene.e@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP adding debug.c file Signed-off-by: Eugene Krasnikov --- drivers/net/wireless/ath/wcn36xx/debug.c | 166 +++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 drivers/net/wireless/ath/wcn36xx/debug.c diff --git a/drivers/net/wireless/ath/wcn36xx/debug.c b/drivers/net/wireless/ath/wcn36xx/debug.c new file mode 100644 index 0000000..91508f3 --- /dev/null +++ b/drivers/net/wireless/ath/wcn36xx/debug.c @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2013 Eugene Krasnikov + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include "wcn36xx.h" +#include "debug.h" +#include "pmc.h" + +#ifdef CONFIG_WCN36XX_DEBUGFS + +static int wcn36xx_debugfs_open(struct inode *inode, struct file *file) +{ + file->private_data = inode->i_private; + + return 0; +} + +static ssize_t read_file_bool_bmps(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wcn36xx *wcn = file->private_data; + char buf[3]; + + if (wcn->pw_state == WCN36XX_BMPS) + buf[0] = '1'; + else + buf[0] = '0'; + + buf[1] = '\n'; + buf[2] = 0x00; + + return simple_read_from_buffer(user_buf, count, ppos, buf, 2); +} + +static ssize_t write_file_bool_bmps(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wcn36xx *wcn = file->private_data; + struct ieee80211_vif *vif = container_of((void *)wcn->current_vif, + struct ieee80211_vif, + drv_priv); + char buf[32]; + int buf_size; + + buf_size = min(count, (sizeof(buf)-1)); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + + switch (buf[0]) { + case 'y': + case 'Y': + case '1': + wcn36xx_enable_keep_alive_null_packet(wcn); + wcn36xx_pmc_enter_bmps_state(wcn, vif->bss_conf.sync_tsf); + break; + case 'n': + case 'N': + case '0': + wcn36xx_pmc_exit_bmps_state(wcn); + break; + } + + return count; +} + +static const struct file_operations fops_wcn36xx_bmps = { + .open = wcn36xx_debugfs_open, + .read = read_file_bool_bmps, + .write = write_file_bool_bmps, +}; + +static ssize_t write_file_dump(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wcn36xx *wcn = file->private_data; + char buf[255], *tmp; + int buf_size; + u32 arg[WCN36xx_MAX_DUMP_ARGS]; + int i; + + memset(buf, 0, sizeof(buf)); + memset(arg, 0, sizeof(arg)); + + buf_size = min(count, (sizeof(buf) - 1)); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + + tmp = buf; + + for (i = 0; i < WCN36xx_MAX_DUMP_ARGS; i++) { + char *begin; + begin = strsep(&tmp, " "); + if (begin == NULL) + break; + + if (kstrtoul(begin, 0, (unsigned long *)(arg + i)) != 0) + break; + } + + wcn36xx_info("DUMP args is %d %d %d %d %d\n", arg[0], arg[1], arg[2], + arg[3], arg[4]); + wcn36xx_smd_dump_cmd_req(wcn, arg[0], arg[1], arg[2], arg[3], arg[4]); + + return count; +} + +static const struct file_operations fops_wcn36xx_dump = { + .open = wcn36xx_debugfs_open, + .write = write_file_dump, +}; + +#define ADD_FILE(name, mode, fop, priv_data) \ + do { \ + struct dentry *d; \ + d = debugfs_create_file(__stringify(name), \ + mode, dfs->rootdir, \ + priv_data, fop); \ + dfs->file_##name.dentry = d; \ + if (IS_ERR(d)) { \ + wcn36xx_warn("Create the debugfs entry failed");\ + dfs->file_##name.dentry = NULL; \ + } \ + } while (0) + + +void wcn36xx_debugfs_init(struct wcn36xx *wcn) +{ + struct wcn36xx_dfs_entry *dfs = &wcn->dfs; + + dfs->rootdir = debugfs_create_dir(KBUILD_MODNAME, + wcn->hw->wiphy->debugfsdir); + if (IS_ERR(dfs->rootdir)) { + wcn36xx_warn("Create the debugfs failed\n"); + dfs->rootdir = NULL; + } + + ADD_FILE(bmps_switcher, S_IRUSR | S_IWUSR, + &fops_wcn36xx_bmps, wcn); + ADD_FILE(dump, S_IWUSR, &fops_wcn36xx_dump, wcn); +} + +void wcn36xx_debugfs_exit(struct wcn36xx *wcn) +{ + struct wcn36xx_dfs_entry *dfs = &wcn->dfs; + debugfs_remove_recursive(dfs->rootdir); +} + +#endif /* CONFIG_WCN36XX_DEBUGFS */