From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Mika Westerberg <mika.westerberg@linux.intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Linus Walleij <linus.walleij@linaro.org>,
Daniel Scally <djrscally@gmail.com>,
Hans de Goede <hdegoede@redhat.com>,
Mark Gross <markgross@kernel.org>
Cc: linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org,
platform-driver-x86@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [RFT PATCH 1/4] platform/x86: int3472: provide a helper for getting GPIOs from lookups
Date: Tue, 26 Sep 2023 16:59:40 +0200 [thread overview]
Message-ID: <20230926145943.42814-2-brgl@bgdev.pl> (raw)
In-Reply-To: <20230926145943.42814-1-brgl@bgdev.pl>
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
gpiod_toggle_active_low() should have never existed in the first place
and once it was added, it should have never been used outside the MMC
slot code.
Stop using it in the int3472 driver and use temporary lookup tables
instead. First: add a helper wrapping the common code in one function.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/platform/x86/intel/int3472/common.c | 29 +++++++++++++++++++++
drivers/platform/x86/intel/int3472/common.h | 9 +++++++
2 files changed, 38 insertions(+)
diff --git a/drivers/platform/x86/intel/int3472/common.c b/drivers/platform/x86/intel/int3472/common.c
index 9db2bb0bbba4..61a8240ed6db 100644
--- a/drivers/platform/x86/intel/int3472/common.c
+++ b/drivers/platform/x86/intel/int3472/common.c
@@ -2,6 +2,10 @@
/* Author: Dan Scally <djrscally@gmail.com> */
#include <linux/acpi.h>
+#include <linux/cleanup.h>
+#include <linux/device.h>
+#include <linux/gpio/machine.h>
+#include <linux/overflow.h>
#include <linux/slab.h>
#include "common.h"
@@ -80,3 +84,28 @@ int skl_int3472_get_sensor_adev_and_name(struct device *dev,
return ret;
}
+
+/* This should *really* only be used when there's no other way... */
+struct gpio_desc *
+skl_int3472_gpiod_get_from_temp_lookup(struct device *dev,
+ const char *chip_label, u16 hwnum,
+ const char *con_id,
+ enum gpio_lookup_flags lflags,
+ enum gpiod_flags rflags)
+{
+ struct gpio_desc *desc;
+
+ struct gpiod_lookup_table *lookup __free(kfree) =
+ kzalloc(struct_size(lookup, table, 1), GFP_KERNEL);
+ if (!lookup)
+ return ERR_PTR(-ENOMEM);
+
+ lookup->dev_id = dev_name(dev);
+ lookup->table[0] = GPIO_LOOKUP(chip_label, hwnum, con_id, lflags);
+
+ gpiod_add_lookup_table(lookup);
+
+ desc = gpiod_get(dev, con_id, rflags);
+ gpiod_remove_lookup_table(lookup);
+ return desc;
+}
diff --git a/drivers/platform/x86/intel/int3472/common.h b/drivers/platform/x86/intel/int3472/common.h
index 9f29baa13860..85ef9b630044 100644
--- a/drivers/platform/x86/intel/int3472/common.h
+++ b/drivers/platform/x86/intel/int3472/common.h
@@ -5,6 +5,8 @@
#define _INTEL_SKL_INT3472_H
#include <linux/clk-provider.h>
+#include <linux/device.h>
+#include <linux/gpio/consumer.h>
#include <linux/gpio/machine.h>
#include <linux/leds.h>
#include <linux/regulator/driver.h>
@@ -129,4 +131,11 @@ int skl_int3472_register_pled(struct int3472_discrete_device *int3472,
struct acpi_resource_gpio *agpio, u32 polarity);
void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472);
+struct gpio_desc *
+skl_int3472_gpiod_get_from_temp_lookup(struct device *dev,
+ const char *chip_label, u16 hwnum,
+ const char *con_id,
+ enum gpio_lookup_flags lflags,
+ enum gpiod_flags rflags);
+
#endif
--
2.39.2
next prev parent reply other threads:[~2023-09-26 14:59 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 14:59 [RFT PATCH 0/4] platform/x86: int3472: don't use gpiod_toggle_active_low() Bartosz Golaszewski
2023-09-26 14:59 ` Bartosz Golaszewski [this message]
2023-09-26 15:25 ` [RFT PATCH 1/4] platform/x86: int3472: provide a helper for getting GPIOs from lookups Andy Shevchenko
2023-09-26 14:59 ` [RFT PATCH 2/4] platform/x86: int3472: led: don't use gpiod_toggle_active_low() Bartosz Golaszewski
2023-09-26 15:26 ` Andy Shevchenko
2023-09-27 7:02 ` Bartosz Golaszewski
2023-09-27 9:14 ` Hans de Goede
2023-09-27 9:40 ` Hans de Goede
2023-09-27 10:44 ` Bartosz Golaszewski
2023-09-27 13:08 ` Hans de Goede
2023-09-27 13:17 ` Hans de Goede
2023-09-26 14:59 ` [RFT PATCH 3/4] platform/x86: int3472: clk_and_regulator: use GPIO lookup tables Bartosz Golaszewski
2023-09-26 15:27 ` Andy Shevchenko
2023-09-26 14:59 ` [RFT PATCH 4/4] gpio: acpi: remove acpi_get_and_request_gpiod() Bartosz Golaszewski
2023-09-26 15:27 ` Andy Shevchenko
2023-09-27 7:55 ` Mika Westerberg
2023-10-09 12:49 ` Bartosz Golaszewski
2023-09-26 15:28 ` [RFT PATCH 0/4] platform/x86: int3472: don't use gpiod_toggle_active_low() Andy Shevchenko
2023-09-27 8:38 ` Hans de Goede
2023-09-27 8:41 ` Hans de Goede
2023-09-27 8:48 ` Bartosz Golaszewski
2023-09-27 9:02 ` Hans de Goede
2023-09-27 9:18 ` Bartosz Golaszewski
2023-09-28 12:40 ` [PATCH v2 0/5] " Hans de Goede
2023-09-28 12:41 ` [PATCH v2 1/5] platform/x86: int3472: Add new skl_int3472_fill_gpiod_lookup() helper Hans de Goede
2023-09-28 12:42 ` [PATCH v2 2/5] platform/x86: int3472: Add new skl_int3472_gpiod_get_from_temp_lookup() helper Hans de Goede
2023-10-01 8:42 ` Andy Shevchenko
2023-10-01 8:55 ` Hans de Goede
2023-09-28 12:43 ` [PATCH v2 3/5] platform/x86: int3472: Stop using gpiod_toggle_active_low() Hans de Goede
2023-09-28 12:44 ` [PATCH v2 4/5] platform/x86: int3472: Switch to devm_get_gpiod() Hans de Goede
2023-09-28 12:45 ` [PATCH v2 5/5] gpio: acpi: remove acpi_get_and_request_gpiod() Hans de Goede
2023-10-01 9:16 ` Andy Shevchenko
2023-09-28 18:40 ` [PATCH v2 0/5] platform/x86: int3472: don't use gpiod_toggle_active_low() Bartosz Golaszewski
2023-09-28 21:15 ` Hans de Goede
2023-10-04 16:29 ` Hans de Goede
2023-10-04 18:22 ` Bartosz Golaszewski
2023-10-06 13:27 ` Ilpo Järvinen
2023-10-01 9:17 ` Andy Shevchenko
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=20230926145943.42814-2-brgl@bgdev.pl \
--to=brgl@bgdev.pl \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=djrscally@gmail.com \
--cc=hdegoede@redhat.com \
--cc=linus.walleij@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=mika.westerberg@linux.intel.com \
--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;
as well as URLs for NNTP newsgroup(s).