All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 0/2] platform/x86: asus-wmi: Substitute quirk_no_rfkill with a generic fix
@ 2017-02-20 19:50 João Paulo Rechi Vita
  2017-02-20 19:50 ` [PATCHv2 1/2] platform/x86: asus-wmi: Detect quirk_no_rfkill from the DSDT João Paulo Rechi Vita
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: João Paulo Rechi Vita @ 2017-02-20 19:50 UTC (permalink / raw)
  To: Corentin Chary, Darren Hart, Andy Shevchenko
  Cc: platform-driver-x86, acpi4asus-user, linux-kernel, linux,
	João Paulo Rechi Vita

The quirk avoids the conflicting usage of ASUS_WMI_DEVID_WLAN_LED (0x00010002)
by both asus-wireless and asus-wmi on machines where the BIOS can't set and
record the wlan status (wlan_ctrl_by_user in asus-wmi.c). At the moment we have
six models quirked upstream, but another fifteen downstream, and we expect this
list to continue growing.

This series makes use of ASUS_WMI_DSTS_USER_BIT plus the status of the ASHS
device to skip asus_wmi_rfkill_init(), instead of static DMI-based quirks.

João Paulo Rechi Vita (2):
  platform/x86: asus-wmi: Detect quirk_no_rfkill from the DSDT
  platform/x86: asus-wmi: Remove quirk_no_rfkill

 drivers/platform/x86/asus-nb-wmi.c | 49 ++------------------------------------
 drivers/platform/x86/asus-wmi.c    | 22 +++++++++++++----
 drivers/platform/x86/asus-wmi.h    |  1 -
 3 files changed, 19 insertions(+), 53 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCHv2 1/2] platform/x86: asus-wmi: Detect quirk_no_rfkill from the DSDT
  2017-02-20 19:50 [PATCHv2 0/2] platform/x86: asus-wmi: Substitute quirk_no_rfkill with a generic fix João Paulo Rechi Vita
@ 2017-02-20 19:50 ` João Paulo Rechi Vita
  2017-02-20 19:50 ` [PATCHv2 2/2] platform/x86: asus-wmi: Remove quirk_no_rfkill João Paulo Rechi Vita
  2017-02-24 20:32 ` [PATCHv2 0/2] platform/x86: asus-wmi: Substitute quirk_no_rfkill with a generic fix Andy Shevchenko
  2 siblings, 0 replies; 4+ messages in thread
From: João Paulo Rechi Vita @ 2017-02-20 19:50 UTC (permalink / raw)
  To: Corentin Chary, Darren Hart, Andy Shevchenko
  Cc: platform-driver-x86, acpi4asus-user, linux-kernel, linux,
	João Paulo Rechi Vita

Some Asus laptops that have an airplane-mode indicator LED, also have
the WMI WLAN user bit set, and the following bits in their DSDT:

    Scope (_SB)
    {
      (...)
      Device (ATKD)
      {
        (...)
        Method (WMNB, 3, Serialized)
        {
          (...)
          If (LEqual (IIA0, 0x00010002))
          {
            OWGD (IIA1)
            Return (One)
          }
        }
      }
    }

So when asus-wmi uses ASUS_WMI_DEVID_WLAN_LED (0x00010002) to store the
wlan state, it drives the airplane-mode indicator LED (through the call
to OWGD) in an inverted fashion: the LED is ON when airplane mode is OFF
(since wlan is ON), and vice-versa.

This commit skips registering RFKill switches at all for these laptops,
to allow the asus-wireless driver to drive the airplane mode LED
correctly through the ASHS ACPI device. Relying on the presence of ASHS
and ASUS_WMI_DSTS_USER_BIT avoids adding DMI-based quirks for at least
21 different laptops.

Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
---
 drivers/platform/x86/asus-wmi.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 43cb680adbb4..8499d3ae4257 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -159,6 +159,8 @@ MODULE_LICENSE("GPL");
 #define USB_INTEL_XUSB2PR		0xD0
 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI	0x9c31
 
+static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL };
+
 struct bios_args {
 	u32 arg0;
 	u32 arg1;
@@ -2051,6 +2053,16 @@ static int asus_wmi_fan_init(struct asus_wmi *asus)
 	return 0;
 }
 
+static bool ashs_present(void)
+{
+	int i = 0;
+	while (ashs_ids[i]) {
+		if (acpi_dev_found(ashs_ids[i++]))
+			return true;
+	}
+	return false;
+}
+
 /*
  * WMI Driver
  */
@@ -2095,6 +2107,13 @@ static int asus_wmi_add(struct platform_device *pdev)
 	if (err)
 		goto fail_leds;
 
+	asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_WLAN, &result);
+	if (result & (ASUS_WMI_DSTS_PRESENCE_BIT | ASUS_WMI_DSTS_USER_BIT))
+		asus->driver->wlan_ctrl_by_user = 1;
+
+	if (asus->driver->wlan_ctrl_by_user && ashs_present())
+		asus->driver->quirks->no_rfkill = 1;
+
 	if (!asus->driver->quirks->no_rfkill) {
 		err = asus_wmi_rfkill_init(asus);
 		if (err)
@@ -2134,10 +2153,6 @@ static int asus_wmi_add(struct platform_device *pdev)
 	if (err)
 		goto fail_debugfs;
 
-	asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_WLAN, &result);
-	if (result & (ASUS_WMI_DSTS_PRESENCE_BIT | ASUS_WMI_DSTS_USER_BIT))
-		asus->driver->wlan_ctrl_by_user = 1;
-
 	return 0;
 
 fail_debugfs:
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCHv2 2/2] platform/x86: asus-wmi: Remove quirk_no_rfkill
  2017-02-20 19:50 [PATCHv2 0/2] platform/x86: asus-wmi: Substitute quirk_no_rfkill with a generic fix João Paulo Rechi Vita
  2017-02-20 19:50 ` [PATCHv2 1/2] platform/x86: asus-wmi: Detect quirk_no_rfkill from the DSDT João Paulo Rechi Vita
@ 2017-02-20 19:50 ` João Paulo Rechi Vita
  2017-02-24 20:32 ` [PATCHv2 0/2] platform/x86: asus-wmi: Substitute quirk_no_rfkill with a generic fix Andy Shevchenko
  2 siblings, 0 replies; 4+ messages in thread
From: João Paulo Rechi Vita @ 2017-02-20 19:50 UTC (permalink / raw)
  To: Corentin Chary, Darren Hart, Andy Shevchenko
  Cc: platform-driver-x86, acpi4asus-user, linux-kernel, linux,
	João Paulo Rechi Vita

With the detection introduced in the previou patche, we don't need these
static DMI-based quirks anymore.

This reverts the following commits:
56a37a72002b "asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UA"
a961a285b479 "asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UF"
6b7ff2af5286 "asus-wmi: Add quirk_no_rfkill for the Asus Z550MA"
02db9ff7af18 "asus-wmi: Add quirk_no_rfkill for the Asus U303LB"
2d735244b798 "asus-wmi: Add quirk_no_rfkill for the Asus N552VW"
a977e59c0c67 "asus-wmi: Create quirk for airplane_mode LED"

Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
---
 drivers/platform/x86/asus-nb-wmi.c | 49 ++------------------------------------
 drivers/platform/x86/asus-wmi.c    |  5 +---
 drivers/platform/x86/asus-wmi.h    |  1 -
 3 files changed, 3 insertions(+), 52 deletions(-)

diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
index 5be4783e40d4..dea98ffb6f60 100644
--- a/drivers/platform/x86/asus-nb-wmi.c
+++ b/drivers/platform/x86/asus-nb-wmi.c
@@ -103,15 +103,6 @@ static struct quirk_entry quirk_asus_x200ca = {
 	.wapf = 2,
 };
 
-static struct quirk_entry quirk_no_rfkill = {
-	.no_rfkill = true,
-};
-
-static struct quirk_entry quirk_no_rfkill_wapf4 = {
-	.wapf = 4,
-	.no_rfkill = true,
-};
-
 static struct quirk_entry quirk_asus_ux303ub = {
 	.wmi_backlight_native = true,
 };
@@ -194,7 +185,7 @@ static const struct dmi_system_id asus_quirks[] = {
 			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
 			DMI_MATCH(DMI_PRODUCT_NAME, "X456UA"),
 		},
-		.driver_data = &quirk_no_rfkill_wapf4,
+		.driver_data = &quirk_asus_wapf4,
 	},
 	{
 		.callback = dmi_matched,
@@ -203,7 +194,7 @@ static const struct dmi_system_id asus_quirks[] = {
 			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
 			DMI_MATCH(DMI_PRODUCT_NAME, "X456UF"),
 		},
-		.driver_data = &quirk_no_rfkill_wapf4,
+		.driver_data = &quirk_asus_wapf4,
 	},
 	{
 		.callback = dmi_matched,
@@ -369,42 +360,6 @@ static const struct dmi_system_id asus_quirks[] = {
 	},
 	{
 		.callback = dmi_matched,
-		.ident = "ASUSTeK COMPUTER INC. X555UB",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
-			DMI_MATCH(DMI_PRODUCT_NAME, "X555UB"),
-		},
-		.driver_data = &quirk_no_rfkill,
-	},
-	{
-		.callback = dmi_matched,
-		.ident = "ASUSTeK COMPUTER INC. N552VW",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
-			DMI_MATCH(DMI_PRODUCT_NAME, "N552VW"),
-		},
-		.driver_data = &quirk_no_rfkill,
-	},
-	{
-		.callback = dmi_matched,
-		.ident = "ASUSTeK COMPUTER INC. U303LB",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
-			DMI_MATCH(DMI_PRODUCT_NAME, "U303LB"),
-		},
-		.driver_data = &quirk_no_rfkill,
-	},
-	{
-		.callback = dmi_matched,
-		.ident = "ASUSTeK COMPUTER INC. Z550MA",
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Z550MA"),
-		},
-		.driver_data = &quirk_no_rfkill,
-	},
-	{
-		.callback = dmi_matched,
 		.ident = "ASUSTeK COMPUTER INC. UX303UB",
 		.matches = {
 			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 8499d3ae4257..8fe5890bf539 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -2111,10 +2111,7 @@ static int asus_wmi_add(struct platform_device *pdev)
 	if (result & (ASUS_WMI_DSTS_PRESENCE_BIT | ASUS_WMI_DSTS_USER_BIT))
 		asus->driver->wlan_ctrl_by_user = 1;
 
-	if (asus->driver->wlan_ctrl_by_user && ashs_present())
-		asus->driver->quirks->no_rfkill = 1;
-
-	if (!asus->driver->quirks->no_rfkill) {
+	if (!(asus->driver->wlan_ctrl_by_user && ashs_present())) {
 		err = asus_wmi_rfkill_init(asus);
 		if (err)
 			goto fail_rfkill;
diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h
index fdff626c3b51..c9589d9342bb 100644
--- a/drivers/platform/x86/asus-wmi.h
+++ b/drivers/platform/x86/asus-wmi.h
@@ -39,7 +39,6 @@ struct key_entry;
 struct asus_wmi;
 
 struct quirk_entry {
-	bool no_rfkill;
 	bool hotplug_wireless;
 	bool scalar_panel_brightness;
 	bool store_backlight_power;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCHv2 0/2] platform/x86: asus-wmi: Substitute quirk_no_rfkill with a generic fix
  2017-02-20 19:50 [PATCHv2 0/2] platform/x86: asus-wmi: Substitute quirk_no_rfkill with a generic fix João Paulo Rechi Vita
  2017-02-20 19:50 ` [PATCHv2 1/2] platform/x86: asus-wmi: Detect quirk_no_rfkill from the DSDT João Paulo Rechi Vita
  2017-02-20 19:50 ` [PATCHv2 2/2] platform/x86: asus-wmi: Remove quirk_no_rfkill João Paulo Rechi Vita
@ 2017-02-24 20:32 ` Andy Shevchenko
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2017-02-24 20:32 UTC (permalink / raw)
  To: João Paulo Rechi Vita
  Cc: Corentin Chary, Darren Hart, Platform Driver, acpi4asus-user,
	linux-kernel, linux, João Paulo Rechi Vita

On Mon, Feb 20, 2017 at 9:50 PM, João Paulo Rechi Vita
<jprvita@gmail.com> wrote:
> The quirk avoids the conflicting usage of ASUS_WMI_DEVID_WLAN_LED (0x00010002)
> by both asus-wireless and asus-wmi on machines where the BIOS can't set and
> record the wlan status (wlan_ctrl_by_user in asus-wmi.c). At the moment we have
> six models quirked upstream, but another fifteen downstream, and we expect this
> list to continue growing.
>
> This series makes use of ASUS_WMI_DSTS_USER_BIT plus the status of the ASHS
> device to skip asus_wmi_rfkill_init(), instead of static DMI-based quirks.
>

Thanks, applied for testing.

> João Paulo Rechi Vita (2):
>   platform/x86: asus-wmi: Detect quirk_no_rfkill from the DSDT
>   platform/x86: asus-wmi: Remove quirk_no_rfkill
>
>  drivers/platform/x86/asus-nb-wmi.c | 49 ++------------------------------------
>  drivers/platform/x86/asus-wmi.c    | 22 +++++++++++++----
>  drivers/platform/x86/asus-wmi.h    |  1 -
>  3 files changed, 19 insertions(+), 53 deletions(-)
>
> --
> 2.11.0
>



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-24 20:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-20 19:50 [PATCHv2 0/2] platform/x86: asus-wmi: Substitute quirk_no_rfkill with a generic fix João Paulo Rechi Vita
2017-02-20 19:50 ` [PATCHv2 1/2] platform/x86: asus-wmi: Detect quirk_no_rfkill from the DSDT João Paulo Rechi Vita
2017-02-20 19:50 ` [PATCHv2 2/2] platform/x86: asus-wmi: Remove quirk_no_rfkill João Paulo Rechi Vita
2017-02-24 20:32 ` [PATCHv2 0/2] platform/x86: asus-wmi: Substitute quirk_no_rfkill with a generic fix Andy Shevchenko

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.