Commit 5ccf9873 authored by Hans de Goede's avatar Hans de Goede Committed by Ilpo Järvinen

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://lore.kernel.org/r/20231004162317.163488-5-hdegoede@redhat.comReviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent 53c5f7f6
...@@ -177,10 +177,8 @@ int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472, ...@@ -177,10 +177,8 @@ int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472,
init.name = kasprintf(GFP_KERNEL, "%s-clk", init.name = kasprintf(GFP_KERNEL, "%s-clk",
acpi_dev_name(int3472->adev)); acpi_dev_name(int3472->adev));
if (!init.name) { if (!init.name)
ret = -ENOMEM; return -ENOMEM;
goto out_put_gpio;
}
int3472->clock.frequency = skl_int3472_get_clk_frequency(int3472); int3472->clock.frequency = skl_int3472_get_clk_frequency(int3472);
...@@ -206,8 +204,6 @@ int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472, ...@@ -206,8 +204,6 @@ int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472,
clk_unregister(int3472->clock.clk); clk_unregister(int3472->clock.clk);
out_free_init_name: out_free_init_name:
kfree(init.name); kfree(init.name);
out_put_gpio:
gpiod_put(int3472->clock.ena_gpio);
return ret; return ret;
} }
...@@ -219,7 +215,6 @@ void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472) ...@@ -219,7 +215,6 @@ void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472)
clkdev_drop(int3472->clock.cl); clkdev_drop(int3472->clock.cl);
clk_unregister(int3472->clock.clk); clk_unregister(int3472->clock.clk);
gpiod_put(int3472->clock.ena_gpio);
} }
/* /*
...@@ -266,7 +261,7 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, ...@@ -266,7 +261,7 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
struct regulator_config cfg = { }; struct regulator_config cfg = { };
const char *second_sensor = NULL; const char *second_sensor = NULL;
const struct dmi_system_id *id; const struct dmi_system_id *id;
int i, j, ret; int i, j;
id = dmi_first_match(skl_int3472_regulator_second_sensor); id = dmi_first_match(skl_int3472_regulator_second_sensor);
if (id) if (id)
...@@ -309,21 +304,11 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, ...@@ -309,21 +304,11 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
int3472->regulator.rdev = regulator_register(int3472->dev, int3472->regulator.rdev = regulator_register(int3472->dev,
&int3472->regulator.rdesc, &int3472->regulator.rdesc,
&cfg); &cfg);
if (IS_ERR(int3472->regulator.rdev)) {
ret = PTR_ERR(int3472->regulator.rdev);
goto err_free_gpio;
}
return 0; return PTR_ERR_OR_ZERO(int3472->regulator.rdev);
err_free_gpio:
gpiod_put(int3472->regulator.gpio);
return ret;
} }
void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472) void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472)
{ {
regulator_unregister(int3472->regulator.rdev); regulator_unregister(int3472->regulator.rdev);
gpiod_put(int3472->regulator.gpio);
} }
...@@ -119,7 +119,7 @@ skl_int3472_gpiod_get_from_temp_lookup(struct int3472_discrete_device *int3472, ...@@ -119,7 +119,7 @@ skl_int3472_gpiod_get_from_temp_lookup(struct int3472_discrete_device *int3472,
return ERR_PTR(ret); return ERR_PTR(ret);
gpiod_add_lookup_table(lookup); gpiod_add_lookup_table(lookup);
desc = gpiod_get(int3472->dev, func, GPIOD_OUT_LOW); desc = devm_gpiod_get(int3472->dev, func, GPIOD_OUT_LOW);
gpiod_remove_lookup_table(lookup); gpiod_remove_lookup_table(lookup);
return desc; return desc;
......
...@@ -39,7 +39,7 @@ int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gp ...@@ -39,7 +39,7 @@ int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gp
ret = led_classdev_register(int3472->dev, &int3472->pled.classdev); ret = led_classdev_register(int3472->dev, &int3472->pled.classdev);
if (ret) if (ret)
goto err_free_gpio; return ret;
int3472->pled.lookup.provider = int3472->pled.name; int3472->pled.lookup.provider = int3472->pled.name;
int3472->pled.lookup.dev_id = int3472->sensor_name; int3472->pled.lookup.dev_id = int3472->sensor_name;
...@@ -47,10 +47,6 @@ int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gp ...@@ -47,10 +47,6 @@ int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gp
led_add_lookup(&int3472->pled.lookup); led_add_lookup(&int3472->pled.lookup);
return 0; return 0;
err_free_gpio:
gpiod_put(int3472->pled.gpio);
return ret;
} }
void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472) void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472)
...@@ -60,5 +56,4 @@ void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472) ...@@ -60,5 +56,4 @@ void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472)
led_remove_lookup(&int3472->pled.lookup); led_remove_lookup(&int3472->pled.lookup);
led_classdev_unregister(&int3472->pled.classdev); led_classdev_unregister(&int3472->pled.classdev);
gpiod_put(int3472->pled.gpio);
} }
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