···185185EXPORT_SYMBOL_GPL(devm_gpiod_get_from_of_node);186186187187/**188188- * devm_fwnode_get_index_gpiod_from_child - get a GPIO descriptor from a189189- * device's child node188188+ * devm_fwnode_gpiod_get_index - get a GPIO descriptor from a given node190189 * @dev: GPIO consumer190190+ * @fwnode: firmware node containing GPIO reference191191 * @con_id: function within the GPIO consumer192192 * @index: index of the GPIO to obtain in the consumer193193- * @child: firmware node (child of @dev)194193 * @flags: GPIO initialization flags195194 * @label: label to attach to the requested GPIO196195 *···199200 * On successful request the GPIO pin is configured in accordance with200201 * provided @flags.201202 */202202-struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,203203- const char *con_id, int index,204204- struct fwnode_handle *child,205205- enum gpiod_flags flags,206206- const char *label)203203+struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,204204+ struct fwnode_handle *fwnode,205205+ const char *con_id, int index,206206+ enum gpiod_flags flags,207207+ const char *label)207208{208208- char prop_name[32]; /* 32 is max size of property name */209209 struct gpio_desc **dr;210210 struct gpio_desc *desc;211211- unsigned int i;212211213212 dr = devres_alloc(devm_gpiod_release, sizeof(struct gpio_desc *),214213 GFP_KERNEL);215214 if (!dr)216215 return ERR_PTR(-ENOMEM);217216218218- for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {219219- if (con_id)220220- snprintf(prop_name, sizeof(prop_name), "%s-%s",221221- con_id, gpio_suffixes[i]);222222- else223223- snprintf(prop_name, sizeof(prop_name), "%s",224224- gpio_suffixes[i]);225225-226226- desc = fwnode_get_named_gpiod(child, prop_name, index, flags,227227- label);228228- if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))229229- break;230230- }217217+ desc = fwnode_gpiod_get_index(fwnode, con_id, index, flags, label);231218 if (IS_ERR(desc)) {232219 devres_free(dr);233220 return desc;···224239225240 return desc;226241}227227-EXPORT_SYMBOL_GPL(devm_fwnode_get_index_gpiod_from_child);242242+EXPORT_SYMBOL_GPL(devm_fwnode_gpiod_get_index);228243229244/**230245 * devm_gpiod_get_index_optional - Resource-managed gpiod_get_index_optional()
+48
drivers/gpio/gpiolib.c
···43254325}4326432643274327/**43284328+ * fwnode_gpiod_get_index - obtain a GPIO from firmware node43294329+ * @fwnode: handle of the firmware node43304330+ * @con_id: function within the GPIO consumer43314331+ * @index: index of the GPIO to obtain for the consumer43324332+ * @flags: GPIO initialization flags43334333+ * @label: label to attach to the requested GPIO43344334+ *43354335+ * This function can be used for drivers that get their configuration43364336+ * from opaque firmware.43374337+ *43384338+ * The function properly finds the corresponding GPIO using whatever is the43394339+ * underlying firmware interface and then makes sure that the GPIO43404340+ * descriptor is requested before it is returned to the caller.43414341+ *43424342+ * Returns:43434343+ * On successful request the GPIO pin is configured in accordance with43444344+ * provided @flags.43454345+ *43464346+ * In case of error an ERR_PTR() is returned.43474347+ */43484348+struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,43494349+ const char *con_id, int index,43504350+ enum gpiod_flags flags,43514351+ const char *label)43524352+{43534353+ struct gpio_desc *desc;43544354+ char prop_name[32]; /* 32 is max size of property name */43554355+ unsigned int i;43564356+43574357+ for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {43584358+ if (con_id)43594359+ snprintf(prop_name, sizeof(prop_name), "%s-%s",43604360+ con_id, gpio_suffixes[i]);43614361+ else43624362+ snprintf(prop_name, sizeof(prop_name), "%s",43634363+ gpio_suffixes[i]);43644364+43654365+ desc = fwnode_get_named_gpiod(fwnode, prop_name, index, flags,43664366+ label);43674367+ if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))43684368+ break;43694369+ }43704370+43714371+ return desc;43724372+}43734373+EXPORT_SYMBOL_GPL(fwnode_gpiod_get_index);43744374+43754375+/**43284376 * gpiod_count - return the number of GPIOs associated with a device / function43294377 * or -ENOENT if no GPIO has been assigned to the requested function43304378 * @dev: GPIO consumer, can be NULL for system-global GPIOs