Skip to content

Commit 5cad128

Browse files
Bartosz Golaszewskiij-intel
authored andcommitted
platform/x86: int3472: Add new skl_int3472_gpiod_get_from_temp_lookup() helper
Add a new skl_int3472_gpiod_get_from_temp_lookup() helper. This is a preparation patch for removing usage of the deprecated gpiod_toggle_active_low() and acpi_get_and_request_gpiod() functions. [[email protected]] use the new skl_int3472_fill_gpiod_lookup() helper Signed-off-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Co-developed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 23516fb commit 5cad128

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/platform/x86/intel/int3472/discrete.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,32 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
9999
return 0;
100100
}
101101

102+
/* This should *really* only be used when there's no other way... */
103+
static struct gpio_desc *
104+
skl_int3472_gpiod_get_from_temp_lookup(struct int3472_discrete_device *int3472,
105+
struct acpi_resource_gpio *agpio,
106+
const char *func, u32 polarity)
107+
{
108+
struct gpio_desc *desc;
109+
int ret;
110+
111+
struct gpiod_lookup_table *lookup __free(kfree) =
112+
kzalloc(struct_size(lookup, table, 2), GFP_KERNEL);
113+
if (!lookup)
114+
return ERR_PTR(-ENOMEM);
115+
116+
lookup->dev_id = dev_name(int3472->dev);
117+
ret = skl_int3472_fill_gpiod_lookup(&lookup->table[0], agpio, func, polarity);
118+
if (ret)
119+
return ERR_PTR(ret);
120+
121+
gpiod_add_lookup_table(lookup);
122+
desc = gpiod_get(int3472->dev, func, GPIOD_OUT_LOW);
123+
gpiod_remove_lookup_table(lookup);
124+
125+
return desc;
126+
}
127+
102128
static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polarity)
103129
{
104130
switch (type) {

0 commit comments

Comments
 (0)