Skip to content

Commit 1e5d088

Browse files
jwrdegoedeij-intel
authored andcommitted
platform/x86: int3472: Stop using devm_gpiod_get()
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 <[email protected]> Reviewed-by: Sakari Ailus <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 53eddae commit 1e5d088

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472)
182182

183183
clkdev_drop(int3472->clock.cl);
184184
clk_unregister(int3472->clock.clk);
185+
gpiod_put(int3472->clock.ena_gpio);
185186
}
186187

187188
int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
@@ -244,12 +245,15 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
244245
if (IS_ERR(regulator->rdev))
245246
return PTR_ERR(regulator->rdev);
246247

248+
int3472->regulators[int3472->n_regulator_gpios].ena_gpio = gpio;
247249
int3472->n_regulator_gpios++;
248250
return 0;
249251
}
250252

251253
void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472)
252254
{
253-
for (int i = 0; i < int3472->n_regulator_gpios; i++)
255+
for (int i = 0; i < int3472->n_regulator_gpios; i++) {
254256
regulator_unregister(int3472->regulators[i].rdev);
257+
gpiod_put(int3472->regulators[i].ena_gpio);
258+
}
255259
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ skl_int3472_gpiod_get_from_temp_lookup(struct int3472_discrete_device *int3472,
117117
return ERR_PTR(ret);
118118

119119
gpiod_add_lookup_table(lookup);
120-
desc = devm_gpiod_get(int3472->dev, con_id, GPIOD_OUT_LOW);
120+
desc = gpiod_get(int3472->dev, con_id, GPIOD_OUT_LOW);
121121
gpiod_remove_lookup_table(lookup);
122122

123123
return desc;
@@ -340,6 +340,10 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
340340
ret = -EINVAL;
341341
break;
342342
}
343+
344+
if (ret)
345+
gpiod_put(gpio);
346+
343347
break;
344348
default:
345349
dev_warn(int3472->dev,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472)
5656

5757
led_remove_lookup(&int3472->pled.lookup);
5858
led_classdev_unregister(&int3472->pled.classdev);
59+
gpiod_put(int3472->pled.gpio);
5960
}

include/linux/platform_data/x86/int3472.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ struct int3472_gpio_regulator {
9999
struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2];
100100
char supply_name_upper[GPIO_SUPPLY_NAME_LENGTH];
101101
char regulator_name[GPIO_REGULATOR_NAME_LENGTH];
102+
struct gpio_desc *ena_gpio;
102103
struct regulator_dev *rdev;
103104
struct regulator_desc rdesc;
104105
};

0 commit comments

Comments
 (0)