Skip to content

Commit 7199418

Browse files
andy-shevjwrdegoede
authored andcommitted
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: Andy Shevchenko <[email protected]> Reviewed-by: Daniel Scally <[email protected]> Tested-by: Daniel Scally <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Hans de Goede <[email protected]>
1 parent a438dd1 commit 7199418

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ int skl_int3472_register_clock(struct int3472_discrete_device *int3472)
131131
}
132132

133133
int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
134-
struct acpi_resource *ares)
134+
struct acpi_resource_gpio *agpio)
135135
{
136-
char *path = ares->data.gpio.resource_source.string_ptr;
137136
const struct int3472_sensor_config *sensor_config;
137+
char *path = agpio->resource_source.string_ptr;
138138
struct regulator_consumer_supply supply_map;
139139
struct regulator_init_data init_data = { };
140140
struct regulator_config cfg = { };
@@ -168,8 +168,7 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
168168
int3472->regulator.supply_name,
169169
&int3472_gpio_regulator_ops);
170170

171-
int3472->regulator.gpio = acpi_get_and_request_gpiod(path,
172-
ares->data.gpio.pin_table[0],
171+
int3472->regulator.gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0],
173172
"int3472,regulator");
174173
if (IS_ERR(int3472->regulator.gpio)) {
175174
dev_err(int3472->dev, "Failed to get regulator GPIO line\n");

drivers/platform/x86/intel-int3472/intel_skl_int3472_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev,
113113
int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb);
114114
int skl_int3472_register_clock(struct int3472_discrete_device *int3472);
115115
int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
116-
struct acpi_resource *ares);
116+
struct acpi_resource_gpio *agpio);
117117

118118
#endif

drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ skl_int3472_get_sensor_module_config(struct int3472_discrete_device *int3472)
103103
}
104104

105105
static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int3472,
106-
struct acpi_resource *ares,
106+
struct acpi_resource_gpio *agpio,
107107
const char *func, u32 polarity)
108108
{
109-
char *path = ares->data.gpio.resource_source.string_ptr;
110109
const struct int3472_sensor_config *sensor_config;
110+
char *path = agpio->resource_source.string_ptr;
111111
struct gpiod_lookup *table_entry;
112112
struct acpi_device *adev;
113113
acpi_handle handle;
@@ -145,7 +145,7 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
145145

146146
table_entry = &int3472->gpios.table[int3472->n_sensor_gpios];
147147
table_entry->key = acpi_dev_name(adev);
148-
table_entry->chip_hwnum = ares->data.gpio.pin_table[0];
148+
table_entry->chip_hwnum = agpio->pin_table[0];
149149
table_entry->con_id = func;
150150
table_entry->idx = 0;
151151
table_entry->flags = polarity;
@@ -156,23 +156,22 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
156156
}
157157

158158
static int skl_int3472_map_gpio_to_clk(struct int3472_discrete_device *int3472,
159-
struct acpi_resource *ares, u8 type)
159+
struct acpi_resource_gpio *agpio, u8 type)
160160
{
161-
char *path = ares->data.gpio.resource_source.string_ptr;
161+
char *path = agpio->resource_source.string_ptr;
162+
u16 pin = agpio->pin_table[0];
162163
struct gpio_desc *gpio;
163164

164165
switch (type) {
165166
case INT3472_GPIO_TYPE_CLK_ENABLE:
166-
gpio = acpi_get_and_request_gpiod(path, ares->data.gpio.pin_table[0],
167-
"int3472,clk-enable");
167+
gpio = acpi_get_and_request_gpiod(path, pin, "int3472,clk-enable");
168168
if (IS_ERR(gpio))
169169
return (PTR_ERR(gpio));
170170

171171
int3472->clock.ena_gpio = gpio;
172172
break;
173173
case INT3472_GPIO_TYPE_PRIVACY_LED:
174-
gpio = acpi_get_and_request_gpiod(path, ares->data.gpio.pin_table[0],
175-
"int3472,privacy-led");
174+
gpio = acpi_get_and_request_gpiod(path, pin, "int3472,privacy-led");
176175
if (IS_ERR(gpio))
177176
return (PTR_ERR(gpio));
178177

@@ -242,37 +241,36 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
242241

243242
if (!obj) {
244243
dev_warn(int3472->dev, "No _DSM entry for GPIO pin %u\n",
245-
ares->data.gpio.pin_table[0]);
244+
agpio->pin_table[0]);
246245
return 1;
247246
}
248247

249248
type = obj->integer.value & 0xff;
250249

251250
switch (type) {
252251
case INT3472_GPIO_TYPE_RESET:
253-
ret = skl_int3472_map_gpio_to_sensor(int3472, ares, "reset",
252+
ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, "reset",
254253
GPIO_ACTIVE_LOW);
255254
if (ret)
256255
err_msg = "Failed to map reset pin to sensor\n";
257256

258257
break;
259258
case INT3472_GPIO_TYPE_POWERDOWN:
260-
ret = skl_int3472_map_gpio_to_sensor(int3472, ares,
261-
"powerdown",
259+
ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, "powerdown",
262260
GPIO_ACTIVE_LOW);
263261
if (ret)
264262
err_msg = "Failed to map powerdown pin to sensor\n";
265263

266264
break;
267265
case INT3472_GPIO_TYPE_CLK_ENABLE:
268266
case INT3472_GPIO_TYPE_PRIVACY_LED:
269-
ret = skl_int3472_map_gpio_to_clk(int3472, ares, type);
267+
ret = skl_int3472_map_gpio_to_clk(int3472, agpio, type);
270268
if (ret)
271269
err_msg = "Failed to map GPIO to clock\n";
272270

273271
break;
274272
case INT3472_GPIO_TYPE_POWER_ENABLE:
275-
ret = skl_int3472_register_regulator(int3472, ares);
273+
ret = skl_int3472_register_regulator(int3472, agpio);
276274
if (ret)
277275
err_msg = "Failed to map regulator to sensor\n";
278276

0 commit comments

Comments
 (0)