All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>, linux-acpi@vger.kernel.org
Subject: [PATCH 1/3] platform/x86: int3472/discrete: Refactor GPIO to sensor mapping
Date: Thu, 24 Nov 2022 20:57:35 +0100	[thread overview]
Message-ID: <20221124195737.390729-2-hdegoede@redhat.com> (raw)
In-Reply-To: <20221124195737.390729-1-hdegoede@redhat.com>

Make the GPIO to sensor mapping more generic and fold the
INT3472_GPIO_TYPE_RESET and INT3472_GPIO_TYPE_POWERDOWN cases into
a single generic case.

This is a preparation patch for further GPIO mapping changes.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/intel/int3472/discrete.c | 31 ++++++++++++++-----
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
index 974a132db651..bc6c62f3f3bf 100644
--- a/drivers/platform/x86/intel/int3472/discrete.c
+++ b/drivers/platform/x86/intel/int3472/discrete.c
@@ -184,6 +184,24 @@ static int skl_int3472_map_gpio_to_clk(struct int3472_discrete_device *int3472,
 	return 0;
 }
 
+static const char *int3472_dsm_type_to_func(u8 type)
+{
+	switch (type) {
+	case INT3472_GPIO_TYPE_RESET:
+		return "reset";
+	case INT3472_GPIO_TYPE_POWERDOWN:
+		return "powerdown";
+	case INT3472_GPIO_TYPE_CLK_ENABLE:
+		return "clken";
+	case INT3472_GPIO_TYPE_PRIVACY_LED:
+		return "pled";
+	case INT3472_GPIO_TYPE_POWER_ENABLE:
+		return "power-enable";
+	}
+
+	return "unknown";
+}
+
 /**
  * skl_int3472_handle_gpio_resources: Map PMIC resources to consuming sensor
  * @ares: A pointer to a &struct acpi_resource
@@ -223,6 +241,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
 	struct acpi_resource_gpio *agpio;
 	union acpi_object *obj;
 	const char *err_msg;
+	const char *func;
 	int ret;
 	u8 type;
 
@@ -246,19 +265,15 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
 
 	type = obj->integer.value & 0xff;
 
+	func = int3472_dsm_type_to_func(type);
+
 	switch (type) {
 	case INT3472_GPIO_TYPE_RESET:
-		ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, "reset",
-						     GPIO_ACTIVE_LOW);
-		if (ret)
-			err_msg = "Failed to map reset pin to sensor\n";
-
-		break;
 	case INT3472_GPIO_TYPE_POWERDOWN:
-		ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, "powerdown",
+		ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, func,
 						     GPIO_ACTIVE_LOW);
 		if (ret)
-			err_msg = "Failed to map powerdown pin to sensor\n";
+			err_msg = "Failed to map GPIO pin to sensor\n";
 
 		break;
 	case INT3472_GPIO_TYPE_CLK_ENABLE:
-- 
2.38.1


  reply	other threads:[~2022-11-24 19:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 19:57 [PATCH 0/3] platform/x86: int3472/discrete: Make it work with IPU6 Hans de Goede
2022-11-24 19:57 ` Hans de Goede [this message]
2022-11-24 19:57 ` [PATCH 2/3] platform/x86: int3472/discrete: Get the polarity from the _DSM entry Hans de Goede
2022-11-24 19:57 ` [PATCH 3/3] platform/x86: int3472/discrete: Add support for sensor-drivers which expect clken + pled GPIOs Hans de Goede
2022-11-24 19:59 ` [PATCH 0/3] platform/x86: int3472/discrete: Make it work with IPU6 Hans de Goede
2022-11-24 20:00 Hans de Goede
2022-11-24 20:00 ` [PATCH 1/3] platform/x86: int3472/discrete: Refactor GPIO to sensor mapping Hans de Goede
2022-11-24 20:09   ` Andy Shevchenko
2022-11-24 20:20     ` Hans de Goede
2022-11-24 22:19       ` Andy Shevchenko
2022-11-25 16:00   ` Dan Scally
2022-11-28 10:56     ` 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=20221124195737.390729-2-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rafael@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 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.