在配置CONFIG_OF_GPIO下作用:
int of_gpiochip_add(struct gpio_chip *chip) { int status;
if ((!chip->of_node) && (chip->parent)) chip->of_node = chip->parent->of_node;
if (!chip->of_node) return 0;
if (!chip->of_xlate) { chip->of_gpio_n_cells = 2; chip->of_xlate = of_gpio_simple_xlate; }
if (chip->of_gpio_n_cells > MAX_PHANDLE_ARGS) return -EINVAL;
status = of_gpiochip_add_pin_range(chip); if (status) return status;
/* If the chip defines names itself, these take precedence */ if (!chip->names) of_gpiochip_set_names(chip);
of_node_get(chip->of_node);
return of_gpiochip_scan_gpios(chip); }
void of_gpiochip_remove(struct gpio_chip *chip) { gpiochip_remove_pin_ranges(chip); of_node_put(chip->of_node); }