Skip to contentSkip to conversation

hp-wmi: Fix dock status and tablet mode reporting

PATCH Superseded Carlo Caione 4 participants 13 messages Apr 9, 2017 – Apr 19, 2017 x86 platform drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover hp-wmi: Fix dock status and tablet mode reporting

From: Carlo Caione <[email protected]>

Several HP laptops cannot be put to sleep using the LID since systemd complains that the system is docked even though the laptop is not even dockable (see [1]).

This is due to a bug in hp-wmi where the driver is failing to check for errors before creating the input switches.

[1]: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1574120

Carlo Caione (2):
hp-wmi: Fix error value for hp_wmi_tablet_state
hp-wmi: Fix detection for dock and tablet mode

 drivers/platform/x86/hp-wmi.c | 42 ++++++++++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 14 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/2 hp-wmi: Fix error value for hp_wmi_tablet_state

From: Carlo Caione <[email protected]>

hp_wmi_tablet_state() fails to return the correct error code when hp_wmi_perform_query() returns the HP WMI query specific error code that is a positive value.

---
 drivers/platform/x86/hp-wmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/hp-wmi.c +1 -1
index 96ffda4..13ba65c 100644
@@ -290,7 +290,7 @@ static int hp_wmi_tablet_state(void)
 	int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state,
 				       sizeof(state), sizeof(state));
 	if (ret)
-		return ret;
+		return -EINVAL;
 
 	return (state & 0x4) ? 1 : 0;
 }
Signature · 1 line
2.9.3
#2 lore raw

Re: [PATCH 1/2] hp-wmi: Fix error value for hp_wmi_tablet_state

drivers/platform/x86/hp-wmi.c static int hp_wmi_tablet_state(void) · line 293

Quoted 11 lines · Carlo Caione

From: Carlo Caione <[email protected]>

hp_wmi_tablet_state() fails to return the correct error code when hp_wmi_perform_query() returns the HP WMI query specific error code that is a positive value.

int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state,
sizeof(state), sizeof(state));
if (ret)

drivers/platform/x86/hp-wmi.c +1 -1
-               return ret;
+               return -EINVAL;

Shouldn't be something like

if (ret)
return ret < 0 ? ret : -EINVAL;

Looking into the code it looks like it may return all possible values:
0, negative, positive.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

Re: [PATCH 1/2] hp-wmi: Fix error value for hp_wmi_tablet_state

Quoted 13 lines · Andy Shevchenko

drivers/platform/x86/hp-wmi.c static int hp_wmi_tablet_state(void) · line 293

Quoted 11 lines · Carlo Caione

From: Carlo Caione <[email protected]>

hp_wmi_tablet_state() fails to return the correct error code when hp_wmi_perform_query() returns the HP WMI query specific error code that is a positive value.

int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state,
sizeof(state), sizeof(state));
if (ret)

drivers/platform/x86/hp-wmi.c +1 -1
-               return ret;
+               return -EINVAL;
Quoted 7 lines

Shouldn't be something like

if (ret)
return ret < 0 ? ret : -EINVAL;

Looking into the code it looks like it may return all possible values:
0, negative, positive.

When the HP WMI query returns a positive value something went wrong. hp_wmi_perform_query() returns 0 on success.

Signature · 1 line
Carlo Caione  |  +39.340.80.30.096  |  Endless
#4 lore raw

Re: [PATCH 1/2] hp-wmi: Fix error value for hp_wmi_tablet_state

Quoted 17 lines · Carlo Caione
Quoted 15 lines · Andy Shevchenko

drivers/platform/x86/hp-wmi.c static int hp_wmi_tablet_state(void) · line 293

Quoted 11 lines · Carlo Caione

From: Carlo Caione <[email protected]>

hp_wmi_tablet_state() fails to return the correct error code when hp_wmi_perform_query() returns the HP WMI query specific error code that is a positive value.

int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state,
sizeof(state), sizeof(state));
if (ret)

drivers/platform/x86/hp-wmi.c +1 -1
-               return ret;
+               return -EINVAL;

Shouldn't be something like

Quoted 8 lines
Quoted 5 lines

if (ret)
return ret < 0 ? ret : -EINVAL;

Looking into the code it looks like it may return all possible values:
0, negative, positive.

When the HP WMI query returns a positive value something went wrong. hp_wmi_perform_query() returns 0 on success.

Yes, that's what I didn't object anyhow. My point is not to shadow negative errors if any.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

PATCH 2/2 hp-wmi: Fix detection for dock and tablet mode

In reply to Carlo Caione

From: Carlo Caione <[email protected]>

The current driver code is not checking for the error values returned by 'hp_wmi_dock_state()' and 'hp_wmi_tablet_state()' before passing the returned values down to 'input_report_switch()'. This error code is being translated to '1' in the input subsystem, reporting the wrong status.

The biggest problem caused by this issue is that several laptops are wrongly reported by the driver as docked, preventing them to be put to sleep using the LID (and in most cases they are not even dockable).

With this patch we create the report switches only if we are able to read the dock and tablet mode status correctly from ACPI.

---
 drivers/platform/x86/hp-wmi.c | 40 +++++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 13 deletions(-)
drivers/platform/x86/hp-wmi.c +27 -13
index 13ba65c..2b721fd 100644
@@ -572,10 +572,12 @@ static void hp_wmi_notify(u32 value, void *context)
 
 	switch (event_id) {
 	case HPWMI_DOCK_EVENT:
-		input_report_switch(hp_wmi_input_dev, SW_DOCK,
-				    hp_wmi_dock_state());
-		input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
-				    hp_wmi_tablet_state());
+		if (test_bit(SW_DOCK, hp_wmi_input_dev->swbit))
+			input_report_switch(hp_wmi_input_dev, SW_DOCK,
+					    hp_wmi_dock_state());
+		if (test_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit))
+			input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
+					    hp_wmi_tablet_state());
 		input_sync(hp_wmi_input_dev);
 		break;
 	case HPWMI_PARK_HDD:
@@ -644,6 +646,7 @@ static int __init hp_wmi_input_setup(void)
 {
 	acpi_status status;
 	int err;
+	int val;
 
 	hp_wmi_input_dev = input_allocate_device();
 	if (!hp_wmi_input_dev)
@@ -654,17 +657,26 @@ static int __init hp_wmi_input_setup(void)
 	hp_wmi_input_dev->id.bustype = BUS_HOST;
 
 	__set_bit(EV_SW, hp_wmi_input_dev->evbit);
-	__set_bit(SW_DOCK, hp_wmi_input_dev->swbit);
-	__set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit);
+
+	/* Dock */
+	val = hp_wmi_dock_state();
+	if (!(val < 0)) {
+		__set_bit(SW_DOCK, hp_wmi_input_dev->swbit);
+		input_report_switch(hp_wmi_input_dev, SW_DOCK, val);
+	}
+
+	/* Tablet mode */
+	val = hp_wmi_tablet_state();
+	if (!(val < 0)) {
+		__set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit);
+		input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val);
+	}
 
 	err = sparse_keymap_setup(hp_wmi_input_dev, hp_wmi_keymap, NULL);
 	if (err)
 		goto err_free_dev;
 
 	/* Set initial hardware state */
-	input_report_switch(hp_wmi_input_dev, SW_DOCK, hp_wmi_dock_state());
-	input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
-			    hp_wmi_tablet_state());
 	input_sync(hp_wmi_input_dev);
 
 	if (!hp_wmi_bios_2009_later() && hp_wmi_bios_2008_later())
@@ -950,10 +962,12 @@ static int hp_wmi_resume_handler(struct device *device)
 	 * changed.
 	 */
 	if (hp_wmi_input_dev) {
-		input_report_switch(hp_wmi_input_dev, SW_DOCK,
-				    hp_wmi_dock_state());
-		input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
-				    hp_wmi_tablet_state());
+		if (test_bit(SW_DOCK, hp_wmi_input_dev->swbit))
+			input_report_switch(hp_wmi_input_dev, SW_DOCK,
+					    hp_wmi_dock_state());
+		if (test_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit))
+			input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
+					    hp_wmi_tablet_state());
 		input_sync(hp_wmi_input_dev);
 	}
 
Signature · 1 line
2.9.3
#6 lore raw

Re: [PATCH 2/2] hp-wmi: Fix detection for dock and tablet mode

Quoted 52 lines · Carlo Caione

From: Carlo Caione <[email protected]>

The current driver code is not checking for the error values returned by 'hp_wmi_dock_state()' and 'hp_wmi_tablet_state()' before passing the returned values down to 'input_report_switch()'. This error code is being translated to '1' in the input subsystem, reporting the wrong status.

The biggest problem caused by this issue is that several laptops are wrongly reported by the driver as docked, preventing them to be put to sleep using the LID (and in most cases they are not even dockable).

With this patch we create the report switches only if we are able to read the dock and tablet mode status correctly from ACPI.

---
 drivers/platform/x86/hp-wmi.c | 40 +++++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 13 deletions(-)
drivers/platform/x86/hp-wmi.c +7 -4
index 13ba65c..2b721fd 100644
@@ -572,10 +572,12 @@ static void hp_wmi_notify(u32 value, void *context)
 
 	switch (event_id) {
 	case HPWMI_DOCK_EVENT:
-		input_report_switch(hp_wmi_input_dev, SW_DOCK,
-				    hp_wmi_dock_state());
-		input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
-				    hp_wmi_tablet_state());
+		if (test_bit(SW_DOCK, hp_wmi_input_dev->swbit))
+			input_report_switch(hp_wmi_input_dev, SW_DOCK,
+					    hp_wmi_dock_state());
+		if (test_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit))
+			input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
+					    hp_wmi_tablet_state());
 		input_sync(hp_wmi_input_dev);
 		break;
 	case HPWMI_PARK_HDD:
@@ -644,6 +646,7 @@ static int __init hp_wmi_input_setup(void)
 {
 	acpi_status status;
 	int err;
+	int val;
 
 	hp_wmi_input_dev = input_allocate_device();
 	if (!hp_wmi_input_dev)
@@ -654,17 +657,26 @@ static int __init hp_wmi_input_setup(void)
 	hp_wmi_input_dev->id.bustype = BUS_HOST;
 

drivers/platform/x86/hp-wmi.c static int __init hp_wmi_input_setup(void) · line 666

Quoted 10 lines
drivers/platform/x86/hp-wmi.c +7 -2
 	__set_bit(EV_SW, hp_wmi_input_dev->evbit);
-	__set_bit(SW_DOCK, hp_wmi_input_dev->swbit);
-	__set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit);
+
+	/* Dock */
+	val = hp_wmi_dock_state();
+	if (!(val < 0)) {
+		__set_bit(SW_DOCK, hp_wmi_input_dev->swbit);
+		input_report_switch(hp_wmi_input_dev, SW_DOCK, val);
+	}

In general, these are fine and can go in. I did want to get your opinion on one thought though.

This adds some complexity to deal with what appears to be an unknown failure mode (the query fails, we don't know why, so we don't set the bit on the input dev for that feature). Since we don't know why it fails, can we be confident it will always fail? Could it succeed at init here, but then fail later and leave us in the same situation we are in now?

If so, have you considered just returning 0 on error and using a WARN_ONCE print statement to report the error? This would simplify a lot of this logic that you're adding in here to handle something we could just report and ignore.

That being said, your version avoids the input_report_switch() in the event of a failure at init. In practice, I don't know if this is worth the added complexity.

Your thoughts?

Quoted 40 lines
drivers/platform/x86/hp-wmi.c +13 -7
+
+	/* Tablet mode */
+	val = hp_wmi_tablet_state();
+	if (!(val < 0)) {
+		__set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit);
+		input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val);
+	}
 
 	err = sparse_keymap_setup(hp_wmi_input_dev, hp_wmi_keymap, NULL);
 	if (err)
 		goto err_free_dev;
 
 	/* Set initial hardware state */
-	input_report_switch(hp_wmi_input_dev, SW_DOCK, hp_wmi_dock_state());
-	input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
-			    hp_wmi_tablet_state());
 	input_sync(hp_wmi_input_dev);
 
 	if (!hp_wmi_bios_2009_later() && hp_wmi_bios_2008_later())
@@ -950,10 +962,12 @@ static int hp_wmi_resume_handler(struct device *device)
 	 * changed.
 	 */
 	if (hp_wmi_input_dev) {
-		input_report_switch(hp_wmi_input_dev, SW_DOCK,
-				    hp_wmi_dock_state());
-		input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
-				    hp_wmi_tablet_state());
+		if (test_bit(SW_DOCK, hp_wmi_input_dev->swbit))
+			input_report_switch(hp_wmi_input_dev, SW_DOCK,
+					    hp_wmi_dock_state());
+		if (test_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit))
+			input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
+					    hp_wmi_tablet_state());
 		input_sync(hp_wmi_input_dev);
 	}
 
Signature · 1 line
2.9.3
Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
#7 lore raw

Re: [PATCH 2/2] hp-wmi: Fix detection for dock and tablet mode

Quoted 2 lines · Darren Hart
Quoted 1 line · Carlo Caione

From: Carlo Caione <[email protected]>

/cut

Quoted 25 lines
Quoted 11 lines
drivers/platform/x86/hp-wmi.c +1 -0
@@ -644,6 +646,7 @@ static int __init hp_wmi_input_setup(void)
 {
      acpi_status status;
      int err;
+     int val;
 
      hp_wmi_input_dev = input_allocate_device();
      if (!hp_wmi_input_dev)
@@ -654,17 +657,26 @@ static int __init hp_wmi_input_setup(void)
      hp_wmi_input_dev->id.bustype = BUS_HOST;
 

drivers/platform/x86/hp-wmi.c static int __init hp_wmi_input_setup(void) · line 666

Quoted 10 lines
drivers/platform/x86/hp-wmi.c +7 -2
      __set_bit(EV_SW, hp_wmi_input_dev->evbit);
-     __set_bit(SW_DOCK, hp_wmi_input_dev->swbit);
-     __set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit);
+
+     /* Dock */
+     val = hp_wmi_dock_state();
+     if (!(val < 0)) {
+             __set_bit(SW_DOCK, hp_wmi_input_dev->swbit);
+             input_report_switch(hp_wmi_input_dev, SW_DOCK, val);
+     }

In general, these are fine and can go in. I did want to get your opinion on one thought though.

Quoted 4 lines

This adds some complexity to deal with what appears to be an unknown failure mode (the query fails, we don't know why, so we don't set the bit on the input dev for that feature). Since we don't know why it fails, can we be confident it will always fail?

That's not exactly true, at least for the firmware I have on the laptop I'm working on.

For this hardware (can we assume for all the HP models?) when the WMI calls returns the value of 0x04, that means that the query (HPWMI_HARDWARE_QUERY in this case) is not implemented at all in the SSDT.
In general reading the disassembled AML code when the WMI query fails and returns a positive value this can be:
- 0x04: Query ID is unknown / not implemented but valid
- 0x02: Wrong signature
- 0x05: Wrong / invalid query number (?)

The problem here is that: (1) this is my personal interpretation of the AML code obtained by disassembling the SSDT and (2) we cannot be sure that this is the same on all the HP firmwares around. For sure in general in all the cases I extracted from the SSDT table on this hardware if the call failed the first time all the chances are that it is going to fail also in the future.

In [1] is the SSDT table, the WMI method is WMAA if you want to check my interpretation.

Quoted 2 lines

Could it succeed at init here, but then fail later and leave us in the same situation we are in now?

I think that this is really unlikely

Quoted 3 lines

If so, have you considered just returning 0 on error and using a WARN_ONCE print statement to report the error? This would simplify a lot of this logic that you're adding in here to handle something we could just report and ignore.

Yes, I thought to report just 0 but in that case we are advertising to userspace fake capabilities for the hardware, like dockability or laptop mode that in most cases are not even implemented on the hardware (like on this laptop).

Quoted 5 lines

That being said, your version avoids the input_report_switch() in the event of a failure at init. In practice, I don't know if this is worth the added complexity.

Your thoughts?

AFAICT we can fail in hp_wmi_perform_query (as written in the comment to the function):
1) with -EINVAL if the query was not successful or the output buffer size exceeds buffersize. In this case I don't see how the next calls could be successful.
2) with a positive error code returned from the WMI method. Given my interpretation of this positive code reported before I don't see why we should fail only on init and not on all the subsequent calls

So I'm still convinced that my implementation is correct and that probably adding complexity on top is not really worth it. But of course this is your call as maintainer :)

Thanks,

[1] https://paste.fedoraproject.org/paste/bBnqUlazz1tAjKsJKq7NHl5M1UNdIGYhyRLivL9gydE=

Signature · 1 line
Carlo Caione  |  +39.340.80.30.096  |  Endless
#8 lore raw

Re: [PATCH 2/2] hp-wmi: Fix detection for dock and tablet mode

Quoted 63 lines · Carlo Caione
Quoted 2 lines · Darren Hart
Quoted 1 line · Carlo Caione

From: Carlo Caione <[email protected]>

/cut

Quoted 25 lines
Quoted 11 lines
drivers/platform/x86/hp-wmi.c +1 -0
@@ -644,6 +646,7 @@ static int __init hp_wmi_input_setup(void)
 {
      acpi_status status;
      int err;
+     int val;
 
      hp_wmi_input_dev = input_allocate_device();
      if (!hp_wmi_input_dev)
@@ -654,17 +657,26 @@ static int __init hp_wmi_input_setup(void)
      hp_wmi_input_dev->id.bustype = BUS_HOST;
 

drivers/platform/x86/hp-wmi.c static int __init hp_wmi_input_setup(void) · line 666

Quoted 10 lines
drivers/platform/x86/hp-wmi.c +7 -2
      __set_bit(EV_SW, hp_wmi_input_dev->evbit);
-     __set_bit(SW_DOCK, hp_wmi_input_dev->swbit);
-     __set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit);
+
+     /* Dock */
+     val = hp_wmi_dock_state();
+     if (!(val < 0)) {
+             __set_bit(SW_DOCK, hp_wmi_input_dev->swbit);
+             input_report_switch(hp_wmi_input_dev, SW_DOCK, val);
+     }

In general, these are fine and can go in. I did want to get your opinion on one thought though.

Quoted 4 lines

This adds some complexity to deal with what appears to be an unknown failure mode (the query fails, we don't know why, so we don't set the bit on the input dev for that feature). Since we don't know why it fails, can we be confident it will always fail?

That's not exactly true, at least for the firmware I have on the laptop I'm working on.

For this hardware (can we assume for all the HP models?) when the WMI calls returns the value of 0x04, that means that the query (HPWMI_HARDWARE_QUERY in this case) is not implemented at all in the SSDT.
In general reading the disassembled AML code when the WMI query fails and returns a positive value this can be:
- 0x04: Query ID is unknown / not implemented but valid
- 0x02: Wrong signature
- 0x05: Wrong / invalid query number (?)

The problem here is that: (1) this is my personal interpretation of the AML code obtained by disassembling the SSDT and (2) we cannot be sure that this is the same on all the HP firmwares around. For sure in general in all the cases I extracted from the SSDT table on this hardware if the call failed the first time all the chances are that it is going to fail also in the future.

In [1] is the SSDT table, the WMI method is WMAA if you want to check my interpretation.

Quoted 2 lines

Could it succeed at init here, but then fail later and leave us in the same situation we are in now?

I think that this is really unlikely

Quoted 8 lines
Quoted 3 lines

If so, have you considered just returning 0 on error and using a WARN_ONCE print statement to report the error? This would simplify a lot of this logic that you're adding in here to handle something we could just report and ignore.

Yes, I thought to report just 0 but in that case we are advertising to userspace fake capabilities for the hardware, like dockability or laptop mode that in most cases are not even implemented on the hardware (like on this laptop).

OK, I'm convinced that this approach is correct.

Quoted 5 lines
Quoted 5 lines

That being said, your version avoids the input_report_switch() in the event of a failure at init. In practice, I don't know if this is worth the added complexity.

Quoted 7 lines
Quoted 1 line

Your thoughts?

AFAICT we can fail in hp_wmi_perform_query (as written in the comment to the function):
1) with -EINVAL if the query was not successful or the output buffer size exceeds buffersize. In this case I don't see how the next calls could be successful.

EINVAL is being used to broadly here. If the input values are incorrect, then yes -EINVAL is the right response. However, if the query was unsuccessful, that is more appropriately -EIO.

If the handle/method doesn't exist, that would be -ENXIO.

However, your changes make the driver self-consistent and I'll apply them as is to testing.

You, me, or someone could prepare a follow up series to clean this driver up a bit.

Quoted 7 lines

2) with a positive error code returned from the WMI method. Given my interpretation of this positive code reported before I don't see why we should fail only on init and not on all the subsequent calls

So I'm still convinced that my implementation is correct and that probably adding complexity on top is not really worth it. But of course this is your call as maintainer :)

Thanks for the additional context.

Quoted 8 lines

Thanks,

[1] https://paste.fedoraproject.org/paste/bBnqUlazz1tAjKsJKq7NHl5M1UNdIGYhyRLivL9gydE=

Signature · 1 line
Carlo Caione  |  +39.340.80.30.096  |  Endless
Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
#9 lore raw

Re: [PATCH 2/2] hp-wmi: Fix detection for dock and tablet mode

Quoted 4 lines · Darren Hart
Quoted 2 lines · Carlo Caione
Quoted 1 line · Darren Hart

On Sun, Apr 09, 2017 at 03:56:08PM +0200, Carlo Caione wrote:

Quoted 8 lines

EINVAL is being used to broadly here. If the input values are incorrect, then yes -EINVAL is the right response. However, if the query was unsuccessful, that is more appropriately -EIO.

If the handle/method doesn't exist, that would be -ENXIO.

However, your changes make the driver self-consistent and I'll apply them as is to testing.

Darren, if it's not yet in for-next, I would like Carlo to update his patch 1. I think it's better if we not shadow negative error code from the callee.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#10 lore raw

Re: [PATCH 2/2] hp-wmi: Fix detection for dock and tablet mode

Quoted 9 lines · Andy Shevchenko
Quoted 8 lines · Darren Hart
Quoted 2 lines · Carlo Caione
Quoted 1 line · Darren Hart

On Sun, Apr 09, 2017 at 03:56:08PM +0200, Carlo Caione wrote:

EINVAL is being used to broadly here. If the input values are incorrect, then yes -EINVAL is the right response. However, if the query was unsuccessful, that is more appropriately -EIO.

Quoted 8 lines
Quoted 4 lines

If the handle/method doesn't exist, that would be -ENXIO.

However, your changes make the driver self-consistent and I'll apply them as is to testing.

Darren, if it's not yet in for-next, I would like Carlo to update his patch 1. I think it's better if we not shadow negative error code from the callee.

See my response in the V2 Carlo submitted.

Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
#11 lore raw
In reply to Carlo Caione
Quoted 6 lines · Carlo Caione

From: Carlo Caione <[email protected]>

Several HP laptops cannot be put to sleep using the LID since systemd complains that the system is docked even though the laptop is not even dockable (see [1]).

Quoted 8 lines

This is due to a bug in hp-wmi where the driver is failing to check for errors before creating the input switches.

[1]: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1574120

Carlo Caione (2):
hp-wmi: Fix error value for hp_wmi_tablet_state
hp-wmi: Fix detection for dock and tablet mode

Gentle ping.

Signature · 1 line
Carlo Caione  |  +39.340.80.30.096  |  Endless
#12 lore raw
Quoted 10 lines · Carlo Caione
Quoted 9 lines · Carlo Caione

From: Carlo Caione <[email protected]>

Several HP laptops cannot be put to sleep using the LID since systemd complains that the system is docked even though the laptop is not even dockable (see [1]).

This is due to a bug in hp-wmi where the driver is failing to check for errors before creating the input switches.

Quoted 7 lines
Quoted 5 lines

[1]: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1574120

Carlo Caione (2):
hp-wmi: Fix error value for hp_wmi_tablet_state
hp-wmi: Fix detection for dock and tablet mode

Gentle ping.

Hi Carlo,

To set expectations. I try to get to patches within 48 hours, but depending on a variety of things it can be as long as a week under normal circumstances. If you do not hear a response within a week, please do ping. At 4 days, this is just a little long, but not out of the norm. I'll get to these today.

Signature · 2 lines
Darren Hart
VMware Open Source Technology Center