Skip to content

Commit 5ccf987

Browse files
jwrdegoedeij-intel
authored andcommitted
platform/x86: int3472: Switch to devm_get_gpiod()
Switch to devm_get_gpiod() for discrete GPIOs for clks / regulators / LEDs and let devm do the cleanup for us. 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 53c5f7f commit 5ccf987

File tree

3 files changed

+6
-26
lines changed

3 files changed

+6
-26
lines changed

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

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,8 @@ int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472,
177177

178178
init.name = kasprintf(GFP_KERNEL, "%s-clk",
179179
acpi_dev_name(int3472->adev));
180-
if (!init.name) {
181-
ret = -ENOMEM;
182-
goto out_put_gpio;
183-
}
180+
if (!init.name)
181+
return -ENOMEM;
184182

185183
int3472->clock.frequency = skl_int3472_get_clk_frequency(int3472);
186184

@@ -206,8 +204,6 @@ int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472,
206204
clk_unregister(int3472->clock.clk);
207205
out_free_init_name:
208206
kfree(init.name);
209-
out_put_gpio:
210-
gpiod_put(int3472->clock.ena_gpio);
211207

212208
return ret;
213209
}
@@ -219,7 +215,6 @@ void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472)
219215

220216
clkdev_drop(int3472->clock.cl);
221217
clk_unregister(int3472->clock.clk);
222-
gpiod_put(int3472->clock.ena_gpio);
223218
}
224219

225220
/*
@@ -266,7 +261,7 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
266261
struct regulator_config cfg = { };
267262
const char *second_sensor = NULL;
268263
const struct dmi_system_id *id;
269-
int i, j, ret;
264+
int i, j;
270265

271266
id = dmi_first_match(skl_int3472_regulator_second_sensor);
272267
if (id)
@@ -309,21 +304,11 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
309304
int3472->regulator.rdev = regulator_register(int3472->dev,
310305
&int3472->regulator.rdesc,
311306
&cfg);
312-
if (IS_ERR(int3472->regulator.rdev)) {
313-
ret = PTR_ERR(int3472->regulator.rdev);
314-
goto err_free_gpio;
315-
}
316307

317-
return 0;
318-
319-
err_free_gpio:
320-
gpiod_put(int3472->regulator.gpio);
321-
322-
return ret;
308+
return PTR_ERR_OR_ZERO(int3472->regulator.rdev);
323309
}
324310

325311
void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472)
326312
{
327313
regulator_unregister(int3472->regulator.rdev);
328-
gpiod_put(int3472->regulator.gpio);
329314
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ skl_int3472_gpiod_get_from_temp_lookup(struct int3472_discrete_device *int3472,
119119
return ERR_PTR(ret);
120120

121121
gpiod_add_lookup_table(lookup);
122-
desc = gpiod_get(int3472->dev, func, GPIOD_OUT_LOW);
122+
desc = devm_gpiod_get(int3472->dev, func, GPIOD_OUT_LOW);
123123
gpiod_remove_lookup_table(lookup);
124124

125125
return desc;

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,14 @@ int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gp
3939

4040
ret = led_classdev_register(int3472->dev, &int3472->pled.classdev);
4141
if (ret)
42-
goto err_free_gpio;
42+
return ret;
4343

4444
int3472->pled.lookup.provider = int3472->pled.name;
4545
int3472->pled.lookup.dev_id = int3472->sensor_name;
4646
int3472->pled.lookup.con_id = "privacy-led";
4747
led_add_lookup(&int3472->pled.lookup);
4848

4949
return 0;
50-
51-
err_free_gpio:
52-
gpiod_put(int3472->pled.gpio);
53-
return ret;
5450
}
5551

5652
void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472)
@@ -60,5 +56,4 @@ void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472)
6056

6157
led_remove_lookup(&int3472->pled.lookup);
6258
led_classdev_unregister(&int3472->pled.classdev);
63-
gpiod_put(int3472->pled.gpio);
6459
}

0 commit comments

Comments
 (0)