Skip to content

Commit 53c5f7f

Browse files
jwrdegoedeij-intel
authored andcommitted
platform/x86: int3472: Stop using gpiod_toggle_active_low()
Use the new skl_int3472_gpiod_get_from_temp_lookup() helper to get a gpio to pass to register_gpio_clock(), skl_int3472_register_regulator() and skl_int3472_register_pled(). This removes all use of the deprecated gpiod_toggle_active_low() and acpi_get_and_request_gpiod() functions. Suggested-by: Bartosz Golaszewski <[email protected]> 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 5cad128 commit 53c5f7f

File tree

4 files changed

+41
-59
lines changed

4 files changed

+41
-59
lines changed

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

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,8 @@ int skl_int3472_register_dsm_clock(struct int3472_discrete_device *int3472)
162162
}
163163

164164
int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472,
165-
struct acpi_resource_gpio *agpio, u32 polarity)
165+
struct gpio_desc *gpio)
166166
{
167-
char *path = agpio->resource_source.string_ptr;
168167
struct clk_init_data init = {
169168
.ops = &skl_int3472_clock_ops,
170169
.flags = CLK_GET_RATE_NOCACHE,
@@ -174,19 +173,7 @@ int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472,
174173
if (int3472->clock.cl)
175174
return -EBUSY;
176175

177-
int3472->clock.ena_gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0],
178-
"int3472,clk-enable");
179-
if (IS_ERR(int3472->clock.ena_gpio)) {
180-
ret = PTR_ERR(int3472->clock.ena_gpio);
181-
int3472->clock.ena_gpio = NULL;
182-
return dev_err_probe(int3472->dev, ret, "getting clk-enable GPIO\n");
183-
}
184-
185-
if (polarity == GPIO_ACTIVE_LOW)
186-
gpiod_toggle_active_low(int3472->clock.ena_gpio);
187-
188-
/* Ensure the pin is in output mode and non-active state */
189-
gpiod_direction_output(int3472->clock.ena_gpio, 0);
176+
int3472->clock.ena_gpio = gpio;
190177

191178
init.name = kasprintf(GFP_KERNEL, "%s-clk",
192179
acpi_dev_name(int3472->adev));
@@ -273,9 +260,8 @@ static const struct dmi_system_id skl_int3472_regulator_second_sensor[] = {
273260
};
274261

275262
int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
276-
struct acpi_resource_gpio *agpio)
263+
struct gpio_desc *gpio)
277264
{
278-
char *path = agpio->resource_source.string_ptr;
279265
struct regulator_init_data init_data = { };
280266
struct regulator_config cfg = { };
281267
const char *second_sensor = NULL;
@@ -314,16 +300,7 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
314300
int3472->regulator.supply_name,
315301
&int3472_gpio_regulator_ops);
316302

317-
int3472->regulator.gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0],
318-
"int3472,regulator");
319-
if (IS_ERR(int3472->regulator.gpio)) {
320-
ret = PTR_ERR(int3472->regulator.gpio);
321-
int3472->regulator.gpio = NULL;
322-
return dev_err_probe(int3472->dev, ret, "getting regulator GPIO\n");
323-
}
324-
325-
/* Ensure the pin is in output mode and non-active state */
326-
gpiod_direction_output(int3472->regulator.gpio, 0);
303+
int3472->regulator.gpio = gpio;
327304

328305
cfg.dev = &int3472->adev->dev;
329306
cfg.init_data = &init_data;

drivers/platform/x86/intel/int3472/common.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,15 @@ int skl_int3472_get_sensor_adev_and_name(struct device *dev,
117117
const char **name_ret);
118118

119119
int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472,
120-
struct acpi_resource_gpio *agpio, u32 polarity);
120+
struct gpio_desc *gpio);
121121
int skl_int3472_register_dsm_clock(struct int3472_discrete_device *int3472);
122122
void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472);
123123

124124
int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
125-
struct acpi_resource_gpio *agpio);
125+
struct gpio_desc *gpio);
126126
void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472);
127127

128-
int skl_int3472_register_pled(struct int3472_discrete_device *int3472,
129-
struct acpi_resource_gpio *agpio, u32 polarity);
128+
int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio);
130129
void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472);
131130

132131
#endif

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

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
194194
struct acpi_resource_gpio *agpio;
195195
u8 active_value, pin, type;
196196
union acpi_object *obj;
197+
struct gpio_desc *gpio;
197198
const char *err_msg;
198199
const char *func;
199200
u32 polarity;
@@ -244,22 +245,38 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
244245

245246
break;
246247
case INT3472_GPIO_TYPE_CLK_ENABLE:
247-
ret = skl_int3472_register_gpio_clock(int3472, agpio, polarity);
248-
if (ret)
249-
err_msg = "Failed to register clock\n";
250-
251-
break;
252248
case INT3472_GPIO_TYPE_PRIVACY_LED:
253-
ret = skl_int3472_register_pled(int3472, agpio, polarity);
254-
if (ret)
255-
err_msg = "Failed to register LED\n";
256-
257-
break;
258249
case INT3472_GPIO_TYPE_POWER_ENABLE:
259-
ret = skl_int3472_register_regulator(int3472, agpio);
260-
if (ret)
261-
err_msg = "Failed to map regulator to sensor\n";
262-
250+
gpio = skl_int3472_gpiod_get_from_temp_lookup(int3472, agpio, func, polarity);
251+
if (IS_ERR(gpio)) {
252+
ret = PTR_ERR(gpio);
253+
err_msg = "Failed to get GPIO\n";
254+
break;
255+
}
256+
257+
switch (type) {
258+
case INT3472_GPIO_TYPE_CLK_ENABLE:
259+
ret = skl_int3472_register_gpio_clock(int3472, gpio);
260+
if (ret)
261+
err_msg = "Failed to register clock\n";
262+
263+
break;
264+
case INT3472_GPIO_TYPE_PRIVACY_LED:
265+
ret = skl_int3472_register_pled(int3472, gpio);
266+
if (ret)
267+
err_msg = "Failed to register LED\n";
268+
269+
break;
270+
case INT3472_GPIO_TYPE_POWER_ENABLE:
271+
ret = skl_int3472_register_regulator(int3472, gpio);
272+
if (ret)
273+
err_msg = "Failed to map regulator to sensor\n";
274+
275+
break;
276+
default: /* Never reached */
277+
ret = -EINVAL;
278+
break;
279+
}
263280
break;
264281
default:
265282
dev_warn(int3472->dev,

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,15 @@ static int int3472_pled_set(struct led_classdev *led_cdev,
1616
return 0;
1717
}
1818

19-
int skl_int3472_register_pled(struct int3472_discrete_device *int3472,
20-
struct acpi_resource_gpio *agpio, u32 polarity)
19+
int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio)
2120
{
22-
char *p, *path = agpio->resource_source.string_ptr;
21+
char *p;
2322
int ret;
2423

2524
if (int3472->pled.classdev.dev)
2625
return -EBUSY;
2726

28-
int3472->pled.gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0],
29-
"int3472,privacy-led");
30-
if (IS_ERR(int3472->pled.gpio))
31-
return dev_err_probe(int3472->dev, PTR_ERR(int3472->pled.gpio),
32-
"getting privacy LED GPIO\n");
33-
34-
if (polarity == GPIO_ACTIVE_LOW)
35-
gpiod_toggle_active_low(int3472->pled.gpio);
36-
37-
/* Ensure the pin is in output mode and non-active state */
38-
gpiod_direction_output(int3472->pled.gpio, 0);
27+
int3472->pled.gpio = gpio;
3928

4029
/* Generate the name, replacing the ':' in the ACPI devname with '_' */
4130
snprintf(int3472->pled.name, sizeof(int3472->pled.name),

0 commit comments

Comments
 (0)