linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tsuchiya Yuto <kitakar@gmail.com>
To: Amitkumar Karwar <amitkarwar@gmail.com>,
	Ganapathi Bhat <ganapathi.bhat@nxp.com>,
	Xinming Hu <huxinming820@gmail.com>,
	Kalle Valo <kvalo@codeaurora.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Maximilian Luz <luzmaximilian@gmail.com>,
	Andy Shevchenko <andriy.shevchenko@intel.com>,
	verdre@v0yd.nl, Tsuchiya Yuto <kitakar@gmail.com>
Subject: [PATCH 2/3] mwifiex: add allow_ps_mode module parameter
Date: Wed, 28 Oct 2020 23:24:32 +0900	[thread overview]
Message-ID: <20201028142433.18501-3-kitakar@gmail.com> (raw)
In-Reply-To: <20201028142433.18501-1-kitakar@gmail.com>

To make the ps_mode (power_save) control easier, this commit adds a new
module parameter allow_ps_mode and set it false (disallowed) by default.

When this parameter is set to false, changing the power_save mode will
be disallowed like the following:

    $ sudo iw dev mlan0 set power_save on
    command failed: Operation not permitted (-1)

Signed-off-by: Tsuchiya Yuto <kitakar@gmail.com>
---
 drivers/net/wireless/marvell/mwifiex/cfg80211.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index a6b9dc6700b14..943bc1e8ceaee 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -25,6 +25,11 @@
 static char *reg_alpha2;
 module_param(reg_alpha2, charp, 0);
 
+static bool allow_ps_mode;
+module_param(allow_ps_mode, bool, 0644);
+MODULE_PARM_DESC(allow_ps_mode,
+		 "allow WiFi power management to be enabled. (default: disallowed)");
+
 static const struct ieee80211_iface_limit mwifiex_ap_sta_limits[] = {
 	{
 		.max = MWIFIEX_MAX_BSS_NUM,
@@ -435,6 +440,17 @@ mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy,
 
 	ps_mode = enabled;
 
+	/* Allow ps_mode to be enabled only when allow_ps_mode is true */
+	if (ps_mode && !allow_ps_mode) {
+		mwifiex_dbg(priv->adapter, MSG,
+			    "Enabling ps_mode disallowed by modparam\n");
+
+		/* Return -EPERM to inform userspace tools that setting
+		 * power_save to be enabled is not permitted.
+		 */
+		return -EPERM;
+	}
+
 	return mwifiex_drv_set_power(priv, &ps_mode);
 }
 
-- 
2.29.1


  parent reply	other threads:[~2020-10-28 21:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28 14:24 [PATCH 0/3] mwifiex: disable ps_mode by default for stability Tsuchiya Yuto
2020-10-28 14:24 ` [PATCH 1/3] mwifiex: disable ps_mode explicitly by default instead Tsuchiya Yuto
2020-10-29 18:25   ` Brian Norris
2020-10-29 18:36     ` Andy Shevchenko
2020-10-29 18:56       ` Brian Norris
2020-10-30  8:04     ` Tsuchiya Yuto
2020-11-20 21:04       ` Brian Norris
2020-11-26 19:44         ` Tsuchiya Yuto
2020-10-28 14:24 ` Tsuchiya Yuto [this message]
2020-10-28 22:04   ` [PATCH 2/3] mwifiex: add allow_ps_mode module parameter Brian Norris
2020-10-29 17:04     ` Willem de Bruijn
2020-10-30  8:02       ` Tsuchiya Yuto
2020-10-30  7:58     ` Tsuchiya Yuto
2020-10-30 11:02       ` Andy Shevchenko
2020-11-02  9:18         ` Tsuchiya Yuto
2020-10-28 14:24 ` [PATCH 3/3] mwifiex: print message when changing ps_mode Tsuchiya Yuto
     [not found] ` <20201028152115.GT4077@smile.fi.intel.com>
2020-10-30  8:26   ` [PATCH 0/3] mwifiex: disable ps_mode by default for stability Tsuchiya Yuto
2020-12-20 21:43 ` Pali Rohár

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201028142433.18501-3-kitakar@gmail.com \
    --to=kitakar@gmail.com \
    --cc=amitkarwar@gmail.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=davem@davemloft.net \
    --cc=ganapathi.bhat@nxp.com \
    --cc=huxinming820@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luzmaximilian@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=verdre@v0yd.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).