Commit 71994187 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Hans de Goede

platform/x86: intel_skl_int3472: Use ACPI GPIO resource directly

When we call acpi_gpio_get_io_resource(), the output will be
the pointer to the ACPI GPIO resource. Use it directly instead of
dereferencing the generic resource.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarDaniel Scally <djrscally@gmail.com>
Tested-by: default avatarDaniel Scally <djrscally@gmail.com>
Link: https://lore.kernel.org/r/20210618125516.53510-4-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent a438dd11
...@@ -131,10 +131,10 @@ int skl_int3472_register_clock(struct int3472_discrete_device *int3472) ...@@ -131,10 +131,10 @@ int skl_int3472_register_clock(struct int3472_discrete_device *int3472)
} }
int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
struct acpi_resource *ares) struct acpi_resource_gpio *agpio)
{ {
char *path = ares->data.gpio.resource_source.string_ptr;
const struct int3472_sensor_config *sensor_config; const struct int3472_sensor_config *sensor_config;
char *path = agpio->resource_source.string_ptr;
struct regulator_consumer_supply supply_map; struct regulator_consumer_supply supply_map;
struct regulator_init_data init_data = { }; struct regulator_init_data init_data = { };
struct regulator_config cfg = { }; struct regulator_config cfg = { };
...@@ -168,8 +168,7 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, ...@@ -168,8 +168,7 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
int3472->regulator.supply_name, int3472->regulator.supply_name,
&int3472_gpio_regulator_ops); &int3472_gpio_regulator_ops);
int3472->regulator.gpio = acpi_get_and_request_gpiod(path, int3472->regulator.gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0],
ares->data.gpio.pin_table[0],
"int3472,regulator"); "int3472,regulator");
if (IS_ERR(int3472->regulator.gpio)) { if (IS_ERR(int3472->regulator.gpio)) {
dev_err(int3472->dev, "Failed to get regulator GPIO line\n"); dev_err(int3472->dev, "Failed to get regulator GPIO line\n");
......
...@@ -113,6 +113,6 @@ union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev, ...@@ -113,6 +113,6 @@ union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev,
int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb); int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb);
int skl_int3472_register_clock(struct int3472_discrete_device *int3472); int skl_int3472_register_clock(struct int3472_discrete_device *int3472);
int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
struct acpi_resource *ares); struct acpi_resource_gpio *agpio);
#endif #endif
...@@ -103,11 +103,11 @@ skl_int3472_get_sensor_module_config(struct int3472_discrete_device *int3472) ...@@ -103,11 +103,11 @@ skl_int3472_get_sensor_module_config(struct int3472_discrete_device *int3472)
} }
static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int3472, static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int3472,
struct acpi_resource *ares, struct acpi_resource_gpio *agpio,
const char *func, u32 polarity) const char *func, u32 polarity)
{ {
char *path = ares->data.gpio.resource_source.string_ptr;
const struct int3472_sensor_config *sensor_config; const struct int3472_sensor_config *sensor_config;
char *path = agpio->resource_source.string_ptr;
struct gpiod_lookup *table_entry; struct gpiod_lookup *table_entry;
struct acpi_device *adev; struct acpi_device *adev;
acpi_handle handle; acpi_handle handle;
...@@ -145,7 +145,7 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347 ...@@ -145,7 +145,7 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
table_entry = &int3472->gpios.table[int3472->n_sensor_gpios]; table_entry = &int3472->gpios.table[int3472->n_sensor_gpios];
table_entry->key = acpi_dev_name(adev); table_entry->key = acpi_dev_name(adev);
table_entry->chip_hwnum = ares->data.gpio.pin_table[0]; table_entry->chip_hwnum = agpio->pin_table[0];
table_entry->con_id = func; table_entry->con_id = func;
table_entry->idx = 0; table_entry->idx = 0;
table_entry->flags = polarity; table_entry->flags = polarity;
...@@ -156,23 +156,22 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347 ...@@ -156,23 +156,22 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
} }
static int skl_int3472_map_gpio_to_clk(struct int3472_discrete_device *int3472, static int skl_int3472_map_gpio_to_clk(struct int3472_discrete_device *int3472,
struct acpi_resource *ares, u8 type) struct acpi_resource_gpio *agpio, u8 type)
{ {
char *path = ares->data.gpio.resource_source.string_ptr; char *path = agpio->resource_source.string_ptr;
u16 pin = agpio->pin_table[0];
struct gpio_desc *gpio; struct gpio_desc *gpio;
switch (type) { switch (type) {
case INT3472_GPIO_TYPE_CLK_ENABLE: case INT3472_GPIO_TYPE_CLK_ENABLE:
gpio = acpi_get_and_request_gpiod(path, ares->data.gpio.pin_table[0], gpio = acpi_get_and_request_gpiod(path, pin, "int3472,clk-enable");
"int3472,clk-enable");
if (IS_ERR(gpio)) if (IS_ERR(gpio))
return (PTR_ERR(gpio)); return (PTR_ERR(gpio));
int3472->clock.ena_gpio = gpio; int3472->clock.ena_gpio = gpio;
break; break;
case INT3472_GPIO_TYPE_PRIVACY_LED: case INT3472_GPIO_TYPE_PRIVACY_LED:
gpio = acpi_get_and_request_gpiod(path, ares->data.gpio.pin_table[0], gpio = acpi_get_and_request_gpiod(path, pin, "int3472,privacy-led");
"int3472,privacy-led");
if (IS_ERR(gpio)) if (IS_ERR(gpio))
return (PTR_ERR(gpio)); return (PTR_ERR(gpio));
...@@ -242,7 +241,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, ...@@ -242,7 +241,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
if (!obj) { if (!obj) {
dev_warn(int3472->dev, "No _DSM entry for GPIO pin %u\n", dev_warn(int3472->dev, "No _DSM entry for GPIO pin %u\n",
ares->data.gpio.pin_table[0]); agpio->pin_table[0]);
return 1; return 1;
} }
...@@ -250,15 +249,14 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, ...@@ -250,15 +249,14 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
switch (type) { switch (type) {
case INT3472_GPIO_TYPE_RESET: case INT3472_GPIO_TYPE_RESET:
ret = skl_int3472_map_gpio_to_sensor(int3472, ares, "reset", ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, "reset",
GPIO_ACTIVE_LOW); GPIO_ACTIVE_LOW);
if (ret) if (ret)
err_msg = "Failed to map reset pin to sensor\n"; err_msg = "Failed to map reset pin to sensor\n";
break; break;
case INT3472_GPIO_TYPE_POWERDOWN: case INT3472_GPIO_TYPE_POWERDOWN:
ret = skl_int3472_map_gpio_to_sensor(int3472, ares, ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, "powerdown",
"powerdown",
GPIO_ACTIVE_LOW); GPIO_ACTIVE_LOW);
if (ret) if (ret)
err_msg = "Failed to map powerdown pin to sensor\n"; err_msg = "Failed to map powerdown pin to sensor\n";
...@@ -266,13 +264,13 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, ...@@ -266,13 +264,13 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
break; break;
case INT3472_GPIO_TYPE_CLK_ENABLE: case INT3472_GPIO_TYPE_CLK_ENABLE:
case INT3472_GPIO_TYPE_PRIVACY_LED: case INT3472_GPIO_TYPE_PRIVACY_LED:
ret = skl_int3472_map_gpio_to_clk(int3472, ares, type); ret = skl_int3472_map_gpio_to_clk(int3472, agpio, type);
if (ret) if (ret)
err_msg = "Failed to map GPIO to clock\n"; err_msg = "Failed to map GPIO to clock\n";
break; break;
case INT3472_GPIO_TYPE_POWER_ENABLE: case INT3472_GPIO_TYPE_POWER_ENABLE:
ret = skl_int3472_register_regulator(int3472, ares); ret = skl_int3472_register_regulator(int3472, agpio);
if (ret) if (ret)
err_msg = "Failed to map regulator to sensor\n"; err_msg = "Failed to map regulator to sensor\n";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment