Skip to content

Commit 23516fb

Browse files
jwrdegoedeij-intel
authored andcommitted
platform/x86: int3472: Add new skl_int3472_fill_gpiod_lookup() helper
Add a new skl_int3472_fill_gpiod_lookup() helper. This is a preparation patch for removing usage of the deprecated gpiod_toggle_active_low() and acpi_get_and_request_gpiod() functions. Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Reviewed-by: Bartosz Golaszewski <[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 0bb80ec commit 23516fb

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,15 @@ static void skl_int3472_log_sensor_module_name(struct int3472_discrete_device *i
5252
}
5353
}
5454

55-
static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int3472,
56-
struct acpi_resource_gpio *agpio,
57-
const char *func, u32 polarity)
55+
static int skl_int3472_fill_gpiod_lookup(struct gpiod_lookup *table_entry,
56+
struct acpi_resource_gpio *agpio,
57+
const char *func, u32 polarity)
5858
{
5959
char *path = agpio->resource_source.string_ptr;
60-
struct gpiod_lookup *table_entry;
6160
struct acpi_device *adev;
6261
acpi_handle handle;
6362
acpi_status status;
6463

65-
if (int3472->n_sensor_gpios >= INT3472_MAX_SENSOR_GPIOS) {
66-
dev_warn(int3472->dev, "Too many GPIOs mapped\n");
67-
return -EINVAL;
68-
}
69-
7064
status = acpi_get_handle(NULL, path, &handle);
7165
if (ACPI_FAILURE(status))
7266
return -EINVAL;
@@ -75,13 +69,31 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
7569
if (!adev)
7670
return -ENODEV;
7771

78-
table_entry = &int3472->gpios.table[int3472->n_sensor_gpios];
7972
table_entry->key = acpi_dev_name(adev);
8073
table_entry->chip_hwnum = agpio->pin_table[0];
8174
table_entry->con_id = func;
8275
table_entry->idx = 0;
8376
table_entry->flags = polarity;
8477

78+
return 0;
79+
}
80+
81+
static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int3472,
82+
struct acpi_resource_gpio *agpio,
83+
const char *func, u32 polarity)
84+
{
85+
int ret;
86+
87+
if (int3472->n_sensor_gpios >= INT3472_MAX_SENSOR_GPIOS) {
88+
dev_warn(int3472->dev, "Too many GPIOs mapped\n");
89+
return -EINVAL;
90+
}
91+
92+
ret = skl_int3472_fill_gpiod_lookup(&int3472->gpios.table[int3472->n_sensor_gpios],
93+
agpio, func, polarity);
94+
if (ret)
95+
return ret;
96+
8597
int3472->n_sensor_gpios++;
8698

8799
return 0;

0 commit comments

Comments
 (0)