X86 platform drivers
 help / color / mirror / Atom feed
* [PATCH 1/2] platform/x86: int3472: discrete: Use FIELD_GET() on the GPIO _DSM return value
@ 2023-06-13 11:08 Hans de Goede
  2023-06-13 11:08 ` [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match Hans de Goede
  0 siblings, 1 reply; 12+ messages in thread
From: Hans de Goede @ 2023-06-13 11:08 UTC (permalink / raw)
  To: Ilpo Järvinen, Andy Shevchenko, Dan Scally
  Cc: Hans de Goede, platform-driver-x86, linux-media

Add defines for the various fields encoded in the GPIO _DSM integer
return value and then use FIELD_GET() to get field values.

Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
index fc839a73e411..a31964076883 100644
--- a/drivers/platform/x86/intel/int3472/discrete.c
+++ b/drivers/platform/x86/intel/int3472/discrete.c
@@ -2,6 +2,7 @@
 /* Author: Dan Scally <djrscally@gmail.com> */
 
 #include <linux/acpi.h>
+#include <linux/bitfield.h>
 #include <linux/device.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/machine.h>
@@ -25,6 +26,10 @@ static const guid_t int3472_gpio_guid =
 	GUID_INIT(0x79234640, 0x9e10, 0x4fea,
 		  0xa5, 0xc1, 0xb5, 0xaa, 0x8b, 0x19, 0x75, 0x6f);
 
+#define INT3472_GPIO_DSM_TYPE				GENMASK(7, 0)
+#define INT3472_GPIO_DSM_PIN				GENMASK(15, 8)
+#define INT3472_GPIO_DSM_SENSOR_ON_VAL			GENMASK(31, 24)
+
 /*
  * 822ace8f-2814-4174-a56b-5f029fe079ee
  * This _DSM GUID returns a string from the sensor device, which acts as a
@@ -174,12 +179,11 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
 		return 1;
 	}
 
-	type = obj->integer.value & 0xff;
+	type = FIELD_GET(INT3472_GPIO_DSM_TYPE, obj->integer.value);
 
 	int3472_get_func_and_polarity(type, &func, &polarity);
 
-	/* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */
-	active_value = obj->integer.value >> 24;
+	active_value = FIELD_GET(INT3472_GPIO_DSM_SENSOR_ON_VAL, obj->integer.value);
 	if (!active_value)
 		polarity ^= GPIO_ACTIVE_LOW;
 
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [PATCH 1/2] platform/x86: int3472: discrete: Fix getting active_value
@ 2023-06-12 14:16 Hans de Goede
  2023-06-12 14:16 ` [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match Hans de Goede
  0 siblings, 1 reply; 12+ messages in thread
From: Hans de Goede @ 2023-06-12 14:16 UTC (permalink / raw)
  To: Andy Shevchenko, Ilpo Järvinen, Dan Scally
  Cc: Hans de Goede, platform-driver-x86, linux-media

acpi_object.integer.value is 64 bit, so to get bits 31-24
the value not only needs to be shifted but also masked.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/intel/int3472/discrete.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
index fc839a73e411..4ef60883154d 100644
--- a/drivers/platform/x86/intel/int3472/discrete.c
+++ b/drivers/platform/x86/intel/int3472/discrete.c
@@ -179,7 +179,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
 	int3472_get_func_and_polarity(type, &func, &polarity);
 
 	/* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */
-	active_value = obj->integer.value >> 24;
+	active_value = (obj->integer.value >> 24) & 0xff;
 	if (!active_value)
 		polarity ^= GPIO_ACTIVE_LOW;
 
-- 
2.40.1


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

end of thread, other threads:[~2023-06-15 12:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-13 11:08 [PATCH 1/2] platform/x86: int3472: discrete: Use FIELD_GET() on the GPIO _DSM return value Hans de Goede
2023-06-13 11:08 ` [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match Hans de Goede
2023-06-13 11:17   ` Ilpo Järvinen
2023-06-15 12:38     ` Hans de Goede
  -- strict thread matches above, loose matches on Subject: below --
2023-06-12 14:16 [PATCH 1/2] platform/x86: int3472: discrete: Fix getting active_value Hans de Goede
2023-06-12 14:16 ` [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match Hans de Goede
2023-06-12 14:20   ` Andy Shevchenko
2023-06-12 14:20   ` Dan Scally
2023-06-12 15:26     ` Hans de Goede
2023-06-12 15:30       ` Dan Scally
2023-06-12 15:36         ` Hans de Goede
2023-06-13  8:10   ` Ilpo Järvinen
2023-06-13 11:02     ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox