mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:44:45 +01:00
gpiolib: legacy: Make sure we kill gpio_request_one() first
Make sure we kill gpio_request_one() first by converting it to use legacy APIs that will be alive a bit longer. In particular, this also shows the code we will use in another function to make it die independently. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20251112093608.1481030-2-andriy.shevchenko@linux.intel.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
82e71fe436
commit
61e1fd2abc
1 changed files with 4 additions and 14 deletions
|
|
@ -34,30 +34,20 @@ EXPORT_SYMBOL_GPL(gpio_free);
|
|||
*/
|
||||
int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
|
||||
{
|
||||
struct gpio_desc *desc;
|
||||
int err;
|
||||
|
||||
/* Compatibility: assume unavailable "valid" GPIOs will appear later */
|
||||
desc = gpio_to_desc(gpio);
|
||||
if (!desc)
|
||||
return -EPROBE_DEFER;
|
||||
|
||||
err = gpiod_request(desc, label);
|
||||
err = gpio_request(gpio, label);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (flags & GPIOF_IN)
|
||||
err = gpiod_direction_input(desc);
|
||||
err = gpio_direction_input(gpio);
|
||||
else
|
||||
err = gpiod_direction_output_raw(desc, !!(flags & GPIOF_OUT_INIT_HIGH));
|
||||
err = gpio_direction_output(gpio, !!(flags & GPIOF_OUT_INIT_HIGH));
|
||||
|
||||
if (err)
|
||||
goto free_gpio;
|
||||
gpio_free(gpio);
|
||||
|
||||
return 0;
|
||||
|
||||
free_gpio:
|
||||
gpiod_free(desc);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gpio_request_one);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue