Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5733884ybc; Wed, 27 Nov 2019 08:37:04 -0800 (PST) X-Google-Smtp-Source: APXvYqw6Re0DjbpU9+pCPkJPGCbnzmRJydSOonnyIAYWH437BGnbLtJB5uijXmj+vObINIsdRJiZ X-Received: by 2002:a50:e002:: with SMTP id e2mr33321140edl.278.1574872624632; Wed, 27 Nov 2019 08:37:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574872624; cv=none; d=google.com; s=arc-20160816; b=d/29F53djzB+7A/PxbzVY8w0xoBrdzz3kE2Kxwm4B8adH138Jqxif1HGGZsVoVb6r8 xzQn1iBHro4KBvIulqMq1TUTMsQ2cu6grL1SF0zaaMEX8tAItHZEZDLOjvlRAIRK54zX gy5A54BRbr9V6B6gMGsAg88QWw0huEOMEMPppoz7MJpTP2L6x1kZrP7Ym2k2INOvBOZ0 DxwfZH4uhy3JLZfgcPSYJPZ6+FXu87UKI0jSu/xcDcMRXYV7Vkj5K43010xZ7qou9UGr RdZThNE7zQRv/ZmCSYlcnkm9BVfMaNSW3cv8AGKeopJALhf6EpEhlSH1e381bppN4K/e pCQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3sFR/9WHrM+nfuUtfIXodH/byIV1jhP1T2qW4hSMQqg=; b=lUP9A321O/335ZxppCOExbkK/MfJnhIDBbDvUoBMMoHsSz1CVPlb8dvZjbzexDRplc JbhDT4Jwhqzf3FBveFFlps5iwLXLMQFvP/Q2kcBIaSHR56Pk2Hufvi6NH3YFHplMH8Bn STtZGyDysxuSUz2uNKEeuszg87fbX0+wdjkQ7ZLzGmS1A4IX1x+4zNdTLtNvycTssbrU bCebMG8RolBnc2G+grAgctPYeRHn+4g2FIy5zSRNOJar4XCEZp6JR84gYou+tr6kChga a9AKePOM1kLiyAy4qFJh8Qax0I/IYYaHHNu3+Ciihzbsf4f/koKGnmtjBG6ZpCq6pCFt 7tkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sBOBD7dq; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id df16si1630029edb.147.2019.11.27.08.36.39; Wed, 27 Nov 2019 08:37:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sBOBD7dq; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726909AbfK0Qg3 (ORCPT + 99 others); Wed, 27 Nov 2019 11:36:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:37634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726729AbfK0Qg3 (ORCPT ); Wed, 27 Nov 2019 11:36:29 -0500 Received: from localhost.localdomain (unknown [151.66.39.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D29CC206E0; Wed, 27 Nov 2019 16:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574872589; bh=3VLJqxCQjFvxAyrOFl2IE9KQg3hKgSQNKDerByq8aJg=; h=From:To:Cc:Subject:Date:From; b=sBOBD7dqjQbCliCEjJE5m4NgPa99JHh69iSGw9vQFqFIhcE/J57dKeph1o86VKOqv jL8K6Hk7DVPrpiWkLPSQQ/z3Ts7G+XFCxBNz11UYEXx6azcxiSsox/EEGPA1yXm6Yx 7nIdSLjwXK/nRptcn+PFMAzhluNQgW3yvoMOyBJo= From: Lorenzo Bianconi To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, toke@redhat.com, kyan@google.com Subject: [PATCH] mac80211: debugfs: improve airtime_flags handler readability Date: Wed, 27 Nov 2019 17:36:15 +0100 Message-Id: <9df7e40b45e95bb0b320317831455beaed1ee3ee.1574872357.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Improve airtime_flags debugfs handler readability reporting configured airtime flags in both numeric and human readable manner Signed-off-by: Lorenzo Bianconi --- net/mac80211/debugfs.c | 59 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index ad41d74530c6..f90d136bc1e0 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c @@ -150,6 +150,62 @@ static const struct file_operations aqm_ops = { .llseek = default_llseek, }; +static ssize_t airtime_flags_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ieee80211_local *local = file->private_data; + char buf[128] = {}, *pos, *end; + + pos = buf; + end = pos + sizeof(buf) - 1; + + if (local->airtime_flags & AIRTIME_USE_TX) + pos += scnprintf(pos, end - pos, "AIRTIME_TX\t(%lx)\n", + AIRTIME_USE_TX); + if (local->airtime_flags & AIRTIME_USE_RX) + pos += scnprintf(pos, end - pos, "AIRTIME_RX\t(%lx)\n", + AIRTIME_USE_RX); + if (local->airtime_flags & AIRTIME_USE_AQL) + pos += scnprintf(pos, end - pos, "AIRTIME_AQL\t(%lx)\n", + AIRTIME_USE_AQL); + + return simple_read_from_buffer(user_buf, count, ppos, buf, + strlen(buf)); +} + +static ssize_t airtime_flags_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ieee80211_local *local = file->private_data; + char buf[16]; + size_t len; + + if (count > sizeof(buf)) + return -EINVAL; + + if (copy_from_user(buf, user_buf, count)) + return -EFAULT; + + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); + if (len > 0 && buf[len - 1] == '\n') + buf[len - 1] = 0; + + if (kstrtou16(buf, 0, &local->airtime_flags)) + return -EINVAL; + + return count; +} + +static const struct file_operations airtime_flags_ops = { + .write = airtime_flags_write, + .read = airtime_flags_read, + .open = simple_open, + .llseek = default_llseek, +}; + static ssize_t aql_txq_limit_read(struct file *file, char __user *user_buf, size_t count, @@ -522,8 +578,7 @@ void debugfs_hw_add(struct ieee80211_local *local) if (local->ops->wake_tx_queue) DEBUGFS_ADD_MODE(aqm, 0600); - debugfs_create_u16("airtime_flags", 0600, - phyd, &local->airtime_flags); + DEBUGFS_ADD_MODE(airtime_flags, 0600); DEBUGFS_ADD(aql_txq_limit); debugfs_create_u32("aql_threshold", 0600, -- 2.21.0