All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Keri <ezhi99@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Oleg Keri <ezhi99@gmail.com>, Ike Panhc <ike.pan@canonical.com>,
	Darren Hart <dvhart@infradead.org>,
	Andy Shevchenko <andy@infradead.org>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] platform/x86: ideapad-laptop: Fix rfkill invert
Date: Thu, 24 May 2018 16:32:31 +0300	[thread overview]
Message-ID: <20180524133231.8433-1-ezhi99@gmail.com> (raw)

There are a lot of reports on the Internet about rfkill lock on
modern Yoga Ideapad laptops while loading ideapad_laptop platform module.
This patch offers the fix. Obviously it's impossible for me
to test this patch on all ideapad laptops, so i've made an module
parameter init_rfkill_inverted to keep old behavior. Comments are
welcome.

Signed-off-by: Oleg Keri <ezhi99@gmail.com>
---
 drivers/platform/x86/ideapad-laptop.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 535199c9e6bc..1eeda7bc74a3 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -110,6 +110,10 @@ static bool no_bt_rfkill;
 module_param(no_bt_rfkill, bool, 0444);
 MODULE_PARM_DESC(no_bt_rfkill, "No rfkill for bluetooth.");
 
+static bool init_rfkill_inverted;
+module_param(init_rfkill_inverted, bool, 0444);
+MODULE_PARM_DESC(init_rfkill_inverted, "Invert rfkill on initialization");
+
 /*
  * ACPI Helpers
  */
@@ -604,7 +608,9 @@ static int ideapad_register_rfkill(struct ideapad_private *priv, int dev)
 			 &sw_blocked)) {
 		rfkill_init_sw_state(priv->rfk[dev], 0);
 	} else {
-		sw_blocked = !sw_blocked;
+		/* Do not apply invert for ideapads which haven't hw switch */
+		if (priv->has_hw_rfkill_switch || init_rfkill_inverted)
+			sw_blocked = !sw_blocked;
 		rfkill_init_sw_state(priv->rfk[dev], sw_blocked);
 	}
 
-- 
2.17.0

WARNING: multiple messages have this Message-ID (diff)
From: Oleg Keri <ezhi99@gmail.com>
Cc: Oleg Keri <ezhi99@gmail.com>, Ike Panhc <ike.pan@canonical.com>,
	Darren Hart <dvhart@infradead.org>,
	Andy Shevchenko <andy@infradead.org>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] platform/x86: ideapad-laptop: Fix rfkill invert
Date: Thu, 24 May 2018 16:32:31 +0300	[thread overview]
Message-ID: <20180524133231.8433-1-ezhi99@gmail.com> (raw)

There are a lot of reports on the Internet about rfkill lock on
modern Yoga Ideapad laptops while loading ideapad_laptop platform module.
This patch offers the fix. Obviously it's impossible for me
to test this patch on all ideapad laptops, so i've made an module
parameter init_rfkill_inverted to keep old behavior. Comments are
welcome.

Signed-off-by: Oleg Keri <ezhi99@gmail.com>
---
 drivers/platform/x86/ideapad-laptop.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 535199c9e6bc..1eeda7bc74a3 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -110,6 +110,10 @@ static bool no_bt_rfkill;
 module_param(no_bt_rfkill, bool, 0444);
 MODULE_PARM_DESC(no_bt_rfkill, "No rfkill for bluetooth.");
 
+static bool init_rfkill_inverted;
+module_param(init_rfkill_inverted, bool, 0444);
+MODULE_PARM_DESC(init_rfkill_inverted, "Invert rfkill on initialization");
+
 /*
  * ACPI Helpers
  */
@@ -604,7 +608,9 @@ static int ideapad_register_rfkill(struct ideapad_private *priv, int dev)
 			 &sw_blocked)) {
 		rfkill_init_sw_state(priv->rfk[dev], 0);
 	} else {
-		sw_blocked = !sw_blocked;
+		/* Do not apply invert for ideapads which haven't hw switch */
+		if (priv->has_hw_rfkill_switch || init_rfkill_inverted)
+			sw_blocked = !sw_blocked;
 		rfkill_init_sw_state(priv->rfk[dev], sw_blocked);
 	}
 
-- 
2.17.0

             reply	other threads:[~2018-05-24 13:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-24 13:32 Oleg Keri [this message]
2018-05-24 13:32 ` [PATCH] platform/x86: ideapad-laptop: Fix rfkill invert Oleg Keri
2018-05-31 12:02 ` Andy Shevchenko

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=20180524133231.8433-1-ezhi99@gmail.com \
    --to=ezhi99@gmail.com \
    --cc=andy@infradead.org \
    --cc=dvhart@infradead.org \
    --cc=ike.pan@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.