All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] platform/x86: intel-vbtn: Use acpi_evaluate_integer()
@ 2020-04-29 10:45 Hans de Goede
  2020-04-29 10:46 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Hans de Goede @ 2020-04-29 10:45 UTC (permalink / raw)
  To: Mika Westerberg, Andy Shevchenko, Linus Walleij
  Cc: Hans de Goede, linux-gpio, linux-acpi

Use acpi_evaluate_integer() instead of open-coding it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/intel-vbtn.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
index b5880936d785..191894d648bb 100644
--- a/drivers/platform/x86/intel-vbtn.c
+++ b/drivers/platform/x86/intel-vbtn.c
@@ -119,28 +119,21 @@ static void detect_tablet_mode(struct platform_device *device)
 	const char *chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE);
 	struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
 	acpi_handle handle = ACPI_HANDLE(&device->dev);
-	struct acpi_buffer vgbs_output = { ACPI_ALLOCATE_BUFFER, NULL };
-	union acpi_object *obj;
+	unsigned long long vgbs;
 	acpi_status status;
 	int m;
 
 	if (!(chassis_type && strcmp(chassis_type, "31") == 0))
-		goto out;
+		return;
 
-	status = acpi_evaluate_object(handle, "VGBS", NULL, &vgbs_output);
+	status = acpi_evaluate_integer(handle, "VGBS", NULL, &vgbs);
 	if (ACPI_FAILURE(status))
-		goto out;
-
-	obj = vgbs_output.pointer;
-	if (!(obj && obj->type == ACPI_TYPE_INTEGER))
-		goto out;
+		return;
 
-	m = !(obj->integer.value & TABLET_MODE_FLAG);
+	m = !(vgbs & TABLET_MODE_FLAG);
 	input_report_switch(priv->input_dev, SW_TABLET_MODE, m);
-	m = (obj->integer.value & DOCK_MODE_FLAG) ? 1 : 0;
+	m = (vgbs & DOCK_MODE_FLAG) ? 1 : 0;
 	input_report_switch(priv->input_dev, SW_DOCK, m);
-out:
-	kfree(vgbs_output.pointer);
 }
 
 static int intel_vbtn_probe(struct platform_device *device)
-- 
2.26.0


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

* Re: [PATCH] platform/x86: intel-vbtn: Use acpi_evaluate_integer()
  2020-04-29 10:45 [PATCH] platform/x86: intel-vbtn: Use acpi_evaluate_integer() Hans de Goede
@ 2020-04-29 10:46 ` Hans de Goede
  0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2020-04-29 10:46 UTC (permalink / raw)
  To: Mika Westerberg, Andy Shevchenko, Linus Walleij; +Cc: linux-gpio, linux-acpi

Hi,

On 4/29/20 12:45 PM, Hans de Goede wrote:
> Use acpi_evaluate_integer() instead of open-coding it.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Sorry I send out the wrong patch, this is the start of a series
I'm working on. So please ignore.

Regards,

Hans


> ---
>   drivers/platform/x86/intel-vbtn.c | 19 ++++++-------------
>   1 file changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
> index b5880936d785..191894d648bb 100644
> --- a/drivers/platform/x86/intel-vbtn.c
> +++ b/drivers/platform/x86/intel-vbtn.c
> @@ -119,28 +119,21 @@ static void detect_tablet_mode(struct platform_device *device)
>   	const char *chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE);
>   	struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
>   	acpi_handle handle = ACPI_HANDLE(&device->dev);
> -	struct acpi_buffer vgbs_output = { ACPI_ALLOCATE_BUFFER, NULL };
> -	union acpi_object *obj;
> +	unsigned long long vgbs;
>   	acpi_status status;
>   	int m;
>   
>   	if (!(chassis_type && strcmp(chassis_type, "31") == 0))
> -		goto out;
> +		return;
>   
> -	status = acpi_evaluate_object(handle, "VGBS", NULL, &vgbs_output);
> +	status = acpi_evaluate_integer(handle, "VGBS", NULL, &vgbs);
>   	if (ACPI_FAILURE(status))
> -		goto out;
> -
> -	obj = vgbs_output.pointer;
> -	if (!(obj && obj->type == ACPI_TYPE_INTEGER))
> -		goto out;
> +		return;
>   
> -	m = !(obj->integer.value & TABLET_MODE_FLAG);
> +	m = !(vgbs & TABLET_MODE_FLAG);
>   	input_report_switch(priv->input_dev, SW_TABLET_MODE, m);
> -	m = (obj->integer.value & DOCK_MODE_FLAG) ? 1 : 0;
> +	m = (vgbs & DOCK_MODE_FLAG) ? 1 : 0;
>   	input_report_switch(priv->input_dev, SW_DOCK, m);
> -out:
> -	kfree(vgbs_output.pointer);
>   }
>   
>   static int intel_vbtn_probe(struct platform_device *device)
> 


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

end of thread, other threads:[~2020-04-29 10:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 10:45 [PATCH] platform/x86: intel-vbtn: Use acpi_evaluate_integer() Hans de Goede
2020-04-29 10:46 ` Hans de Goede

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.