static struct gpio_desc *of_xlate_and_get_gpiod_flags(struct gpio_chip *chip, struct of_phandle_args *gpiospec, enum of_gpio_flags *flags) { int ret; if (chip->of_gpio_n_cells != gpiospec->args_count) return ERR_PTR(-EINVAL); ret = chip->of_xlate(chip, gpiospec, flags); if (ret < 0) return ERR_PTR(ret); return gpiochip_get_desc(chip, ret); }
/* Private function for resolving node pointer to gpio_chip */ static int of_gpiochip_find_and_xlate(struct gpio_chip *gc, void *data) { struct gg_data *gg_data = data; int ret; if ((gc->of_node != gg_data->gpiospec.np) || (gc->of_gpio_n_cells != gg_data->gpiospec.args_count) || (!gc->of_xlate)) return false; ret = gc->of_xlate(gc, &gg_data->gpiospec, gg_data->flags); if (ret < 0) { /* We've found the gpio chip, but the translation failed. * Return true to stop looking and return the translation * error via out_gpio */ gg_data->out_gpio = ERR_PTR(ret); return true; } gg_data->out_gpio = gpiochip_get_desc(gc, ret); return true; }