From patchwork Thu Dec 18 23:18:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 5516461 X-Patchwork-Delegate: kvalo@adurom.com 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 5F51ABEEA8 for ; Thu, 18 Dec 2014 23:18:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8615A20108 for ; Thu, 18 Dec 2014 23:18:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 90028200DB for ; Thu, 18 Dec 2014 23:18:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751759AbaLRXSV (ORCPT ); Thu, 18 Dec 2014 18:18:21 -0500 Received: from mail-wi0-f170.google.com ([209.85.212.170]:40419 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751230AbaLRXSS (ORCPT ); Thu, 18 Dec 2014 18:18:18 -0500 Received: by mail-wi0-f170.google.com with SMTP id bs8so3115706wib.5 for ; Thu, 18 Dec 2014 15:18:17 -0800 (PST) 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=2uqbGLFbU4L602FU0KdKXeN1Q4ELWqFCdiRzdrDVfxU=; b=N+G0iNdaQE8ZEcH/zI5dXCsujpbym4ZCBJb/zS/MK2dErIBKHBkSZKz201OyJjTGKM 3z9YXvX1tNFFUbRawsVhzG+fFAWHpNquTZhL68gLEqg+YxebTwbR1V1yloQr8ro6Gjho yTyJQ0a7vB3S3R/3uLORFOuyFa8/9DTAcHocW7POG2bUNvdhQA5MNyec+BT+OaDmn61j /y95cQ/T4IV/P5KAnqC4m2ILraY7UTtm0KRT34tHsJYAn8AdzFmk1mEgpTuU8zoR0x4k 30E6gTJBQYBnWNB6sX+lEAclx38i+Rc2zzKVKSEsTsCIemeN3EN9Pgge+ZNdRJjyLMa0 97pw== X-Received: by 10.180.80.34 with SMTP id o2mr248583wix.53.1418944697478; Thu, 18 Dec 2014 15:18:17 -0800 (PST) Received: from kxps.lan (ppp-225-38.30-151.libero.it. [151.30.38.225]) by mx.google.com with ESMTPSA id mu5sm271566wic.18.2014.12.18.15.18.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Dec 2014 15:18:17 -0800 (PST) From: Lorenzo Bianconi To: linux-wireless@vger.kernel.org Cc: nbd@openwrt.org, thomas@net.t-labs.tu-berlin.de Subject: [PATCH 2/3] ath9k: add debugfs support for hw TPC Date: Fri, 19 Dec 2014 00:18:13 +0100 Message-Id: <1418944694-10614-3-git-send-email-lorenzo.bianconi83@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1418944694-10614-1-git-send-email-lorenzo.bianconi83@gmail.com> References: <1418944694-10614-1-git-send-email-lorenzo.bianconi83@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=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 Add tpc entry to ath9k debugfs in order to enable/disable hw TPC Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/ath/ath9k/debug.c | 71 ++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 696e3d5..346290a 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -1188,6 +1188,75 @@ static const struct file_operations fops_ackto = { }; #endif +static ssize_t read_file_tpc(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath_softc *sc = file->private_data; + struct ath_hw *ah = sc->sc_ah; + unsigned int len = 0, size = 32; + ssize_t retval; + char *buf; + + buf = kzalloc(size, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + len += scnprintf(buf + len, size - len, "%s\n", + ah->tpc_enabled ? "ENABLED" : "DISABLED"); + + if (len > size) + len = size; + + retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); + kfree(buf); + + return retval; +} + +static ssize_t write_file_tpc(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath_softc *sc = file->private_data; + struct ath_hw *ah = sc->sc_ah; + unsigned long val; + char buf[32]; + ssize_t len; + bool tpc_enabled; + + if (!AR_SREV_9300_20_OR_LATER(ah)) { + /* ar9002 does not support TPC for the moment */ + return -EOPNOTSUPP; + } + + len = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, len)) + return -EFAULT; + + buf[len] = '\0'; + if (kstrtoul(buf, 0, &val)) + return -EINVAL; + + if (val < 0 || val > 1) + return -EINVAL; + + tpc_enabled = !!val; + + if (tpc_enabled != ah->tpc_enabled) { + ah->tpc_enabled = tpc_enabled; + ath9k_hw_set_txpowerlimit(ah, sc->cur_chan->txpower, false); + } + + return count; +} + +static const struct file_operations fops_tpc = { + .read = read_file_tpc, + .write = write_file_tpc, + .open = simple_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + /* Ethtool support for get-stats */ #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO" @@ -1397,6 +1466,8 @@ int ath9k_init_debug(struct ath_hw *ah) debugfs_create_file("ack_to", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_ackto); #endif + debugfs_create_file("tpc", S_IRUSR | S_IWUSR, + sc->debug.debugfs_phy, sc, &fops_tpc); return 0; }