]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/x86: int3472: Stop using devm_gpiod_get()
authorHans de Goede <hdegoede@redhat.com>
Wed, 7 May 2025 18:47:33 +0000 (20:47 +0200)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 8 May 2025 14:36:00 +0000 (17:36 +0300)
The intent is to re-use the INT3472 code for parsing Intel camera sensor
GPIOs and mapping them to the sensor for the atomisp driver, which
currently has duplicate code.

On atomisp devices there is no special INT3472 ACPI device, instead
the Intel _DSM to get the GPIO type is part of the ACPI device for
the sensor itself.

To deal with this the mapping is done from ipu_bridge_init() instead of
from a platform-device probe() function, there is no device to tie
the lifetime of the gpiod_get() calls done by the INT3472 code to.

Switch from devm_gpiod_get() to plain gpiod_get() + explicit gpiod_put()
calls, to prepare for the code being re-used in the atomisp driver.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20250507184737.154747-3-hdegoede@redhat.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/intel/int3472/clk_and_regulator.c
drivers/platform/x86/intel/int3472/discrete.c
drivers/platform/x86/intel/int3472/led.c
include/linux/platform_data/x86/int3472.h

index 4d00494a76701a2868c42e6ffd050d5390d89db0..476ec24d37020a226664236af058426bb43fd6ce 100644 (file)
@@ -182,6 +182,7 @@ void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472)
 
        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,
@@ -244,12 +245,15 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
        if (IS_ERR(regulator->rdev))
                return PTR_ERR(regulator->rdev);
 
+       int3472->regulators[int3472->n_regulator_gpios].ena_gpio = gpio;
        int3472->n_regulator_gpios++;
        return 0;
 }
 
 void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472)
 {
-       for (int i = 0; i < int3472->n_regulator_gpios; i++)
+       for (int i = 0; i < int3472->n_regulator_gpios; i++) {
                regulator_unregister(int3472->regulators[i].rdev);
+               gpiod_put(int3472->regulators[i].ena_gpio);
+       }
 }
index d0938da0a591dcefc32cfad8cf52040891e89c90..808d75e8deda676574fcee68b4fe9a20450c8b0e 100644 (file)
@@ -117,7 +117,7 @@ skl_int3472_gpiod_get_from_temp_lookup(struct int3472_discrete_device *int3472,
                return ERR_PTR(ret);
 
        gpiod_add_lookup_table(lookup);
-       desc = devm_gpiod_get(int3472->dev, con_id, GPIOD_OUT_LOW);
+       desc = gpiod_get(int3472->dev, con_id, GPIOD_OUT_LOW);
        gpiod_remove_lookup_table(lookup);
 
        return desc;
@@ -340,6 +340,10 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
                        ret = -EINVAL;
                        break;
                }
+
+               if (ret)
+                       gpiod_put(gpio);
+
                break;
        default:
                dev_warn(int3472->dev,
index c5588e143f7db12d1930860c123ca582205b77a8..f1d6d7b0cb75a38990cef1739ce055230de1f73f 100644 (file)
@@ -56,4 +56,5 @@ void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472)
 
        led_remove_lookup(&int3472->pled.lookup);
        led_classdev_unregister(&int3472->pled.classdev);
+       gpiod_put(int3472->pled.gpio);
 }
index 4cf02df6f753bbfc56cf20980b3bd221c3cd01de..0a835cc85c67035fb425fa7b380707e7ecce9e03 100644 (file)
@@ -99,6 +99,7 @@ struct int3472_gpio_regulator {
        struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2];
        char supply_name_upper[GPIO_SUPPLY_NAME_LENGTH];
        char regulator_name[GPIO_REGULATOR_NAME_LENGTH];
+       struct gpio_desc *ena_gpio;
        struct regulator_dev *rdev;
        struct regulator_desc rdesc;
 };