From: Hans de Goede <hdegoede@redhat.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Dan Scally" <dan.scally@ideasonboard.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org
Subject: [PATCH 1/2] platform/x86: int3472: discrete: Use FIELD_GET() on the GPIO _DSM return value
Date: Tue, 13 Jun 2023 13:08:09 +0200 [thread overview]
Message-ID: <20230613110810.240193-1-hdegoede@redhat.com> (raw)
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
next reply other threads:[~2023-06-13 11:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-13 11:08 Hans de Goede [this message]
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
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=20230613110810.240193-1-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=andy@kernel.org \
--cc=dan.scally@ideasonboard.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-media@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox