--- zzzz-none-000/linux-5.4.213/drivers/gpio/gpiolib.c 2022-09-15 10:04:56.000000000 +0000 +++ miami-7690-761/linux-5.4.213/drivers/gpio/gpiolib.c 2024-05-29 11:19:50.000000000 +0000 @@ -1586,6 +1586,27 @@ } EXPORT_SYMBOL_GPL(devm_gpiochip_add_data); +#ifdef CONFIG_GPIOLIB_AVM_EXTENSION +struct gpio_chip *gpiochip_avm_find_by_name(const char *name) +{ + struct gpio_device *gdev; + struct gpio_chip *chip = NULL; + unsigned long flags; + + spin_lock_irqsave(&gpio_lock, flags); + list_for_each_entry(gdev, &gpio_devices, list) + if (gdev->chip && !strcmp(gdev->chip->label, name)) { + chip = gdev->chip; + break; + } + + spin_unlock_irqrestore(&gpio_lock, flags); + + return chip; +} +EXPORT_SYMBOL(gpiochip_avm_find_by_name); +#endif + /** * gpiochip_find() - iterator for locating a specific gpio_chip * @data: data to pass to match function @@ -3143,6 +3164,43 @@ } EXPORT_SYMBOL_GPL(gpiod_direction_output); +#ifdef CONFIG_GPIOLIB_AVM_EXTENSION +int _gpiod_set_gpio_function_raw(struct gpio_desc *desc, unsigned int function) +{ + int ret; + struct gpio_chip *gc = desc->gdev->chip; + + ret = gc->set_function(gc, gpio_chip_hwgpio(desc), function); + + return 0; + +} + +int gpiod_set_gpio_function(struct gpio_desc *desc, unsigned int function) +{ + VALIDATE_DESC(desc); + return _gpiod_set_gpio_function_raw(desc, function); +} +EXPORT_SYMBOL_GPL(gpiod_set_gpio_function); + +int _gpiod_get_gpio_function_raw(struct gpio_desc *desc) +{ + int ret; + struct gpio_chip *gc = desc->gdev->chip; + + ret = gc->get_function(gc, gpio_chip_hwgpio(desc)); + + return ret; +} + +int gpiod_get_gpio_function(struct gpio_desc *desc) +{ + VALIDATE_DESC(desc); + return _gpiod_get_gpio_function_raw(desc); +} +EXPORT_SYMBOL_GPL(gpiod_get_gpio_function); +#endif + /** * gpiod_set_debounce - sets @debounce time for a GPIO * @desc: descriptor of the GPIO for which to set debounce time