mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 15:12:13 +02:00
platform/x86: int3472/discrete: Move GPIO request to skl_int3472_register_clock()
Move the requesting of the clk-enable GPIO to skl_int3472_register_clock() (and move the gpiod_put to unregister). This mirrors the GPIO handling in skl_int3472_register_regulator() and allows removing skl_int3472_map_gpio_to_clk() from discrete.c. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Link: https://lore.kernel.org/r/20230127203729.10205-5-hdegoede@redhat.com
This commit is contained in:
parent
5ae20a8050
commit
8cf0e541c1
|
|
@ -86,18 +86,34 @@ static const struct clk_ops skl_int3472_clock_ops = {
|
|||
.recalc_rate = skl_int3472_clk_recalc_rate,
|
||||
};
|
||||
|
||||
int skl_int3472_register_clock(struct int3472_discrete_device *int3472)
|
||||
int skl_int3472_register_clock(struct int3472_discrete_device *int3472,
|
||||
struct acpi_resource_gpio *agpio)
|
||||
{
|
||||
char *path = agpio->resource_source.string_ptr;
|
||||
struct clk_init_data init = {
|
||||
.ops = &skl_int3472_clock_ops,
|
||||
.flags = CLK_GET_RATE_NOCACHE,
|
||||
};
|
||||
int ret;
|
||||
|
||||
if (int3472->clock.cl)
|
||||
return -EBUSY;
|
||||
|
||||
int3472->clock.ena_gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0],
|
||||
"int3472,clk-enable");
|
||||
if (IS_ERR(int3472->clock.ena_gpio))
|
||||
return dev_err_probe(int3472->dev, PTR_ERR(int3472->clock.ena_gpio),
|
||||
"getting clk-enable GPIO\n");
|
||||
|
||||
/* Ensure the pin is in output mode and non-active state */
|
||||
gpiod_direction_output(int3472->clock.ena_gpio, 0);
|
||||
|
||||
init.name = kasprintf(GFP_KERNEL, "%s-clk",
|
||||
acpi_dev_name(int3472->adev));
|
||||
if (!init.name)
|
||||
return -ENOMEM;
|
||||
if (!init.name) {
|
||||
ret = -ENOMEM;
|
||||
goto out_put_gpio;
|
||||
}
|
||||
|
||||
int3472->clock.frequency = skl_int3472_get_clk_frequency(int3472);
|
||||
|
||||
|
|
@ -123,14 +139,20 @@ int skl_int3472_register_clock(struct int3472_discrete_device *int3472)
|
|||
clk_unregister(int3472->clock.clk);
|
||||
out_free_init_name:
|
||||
kfree(init.name);
|
||||
out_put_gpio:
|
||||
gpiod_put(int3472->clock.ena_gpio);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472)
|
||||
{
|
||||
if (!int3472->clock.cl)
|
||||
return;
|
||||
|
||||
clkdev_drop(int3472->clock.cl);
|
||||
clk_unregister(int3472->clock.clk);
|
||||
gpiod_put(int3472->clock.ena_gpio);
|
||||
}
|
||||
|
||||
int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
|
||||
|
|
|
|||
|
|
@ -121,7 +121,8 @@ int skl_int3472_get_sensor_adev_and_name(struct device *dev,
|
|||
struct acpi_device **sensor_adev_ret,
|
||||
const char **name_ret);
|
||||
|
||||
int skl_int3472_register_clock(struct int3472_discrete_device *int3472);
|
||||
int skl_int3472_register_clock(struct int3472_discrete_device *int3472,
|
||||
struct acpi_resource_gpio *agpio);
|
||||
void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472);
|
||||
|
||||
int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
/* Author: Dan Scally <djrscally@gmail.com> */
|
||||
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/clkdev.h>
|
||||
#include <linux/clk-provider.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/gpio/machine.h>
|
||||
|
|
@ -154,24 +152,6 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int skl_int3472_map_gpio_to_clk(struct int3472_discrete_device *int3472,
|
||||
struct acpi_resource_gpio *agpio)
|
||||
{
|
||||
char *path = agpio->resource_source.string_ptr;
|
||||
u16 pin = agpio->pin_table[0];
|
||||
struct gpio_desc *gpio;
|
||||
|
||||
gpio = acpi_get_and_request_gpiod(path, pin, "int3472,clk-enable");
|
||||
if (IS_ERR(gpio))
|
||||
return (PTR_ERR(gpio));
|
||||
|
||||
int3472->clock.ena_gpio = gpio;
|
||||
/* Ensure the pin is in output mode and non-active state */
|
||||
gpiod_direction_output(int3472->clock.ena_gpio, 0);
|
||||
|
||||
return skl_int3472_register_clock(int3472);
|
||||
}
|
||||
|
||||
static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polarity)
|
||||
{
|
||||
switch (type) {
|
||||
|
|
@ -277,9 +257,9 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
|
|||
|
||||
break;
|
||||
case INT3472_GPIO_TYPE_CLK_ENABLE:
|
||||
ret = skl_int3472_map_gpio_to_clk(int3472, agpio);
|
||||
ret = skl_int3472_register_clock(int3472, agpio);
|
||||
if (ret)
|
||||
err_msg = "Failed to map GPIO to clock\n";
|
||||
err_msg = "Failed to register clock\n";
|
||||
|
||||
break;
|
||||
case INT3472_GPIO_TYPE_PRIVACY_LED:
|
||||
|
|
@ -342,11 +322,7 @@ static int skl_int3472_discrete_remove(struct platform_device *pdev)
|
|||
|
||||
gpiod_remove_lookup_table(&int3472->gpios);
|
||||
|
||||
if (int3472->clock.cl)
|
||||
skl_int3472_unregister_clock(int3472);
|
||||
|
||||
gpiod_put(int3472->clock.ena_gpio);
|
||||
|
||||
skl_int3472_unregister_clock(int3472);
|
||||
skl_int3472_unregister_pled(int3472);
|
||||
skl_int3472_unregister_regulator(int3472);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user