Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'ib-fwnode-gpiod-get-index' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio into regulator-5.5

+101 -34
+9 -24
drivers/gpio/gpiolib-devres.c
··· 185 185 EXPORT_SYMBOL_GPL(devm_gpiod_get_from_of_node); 186 186 187 187 /** 188 - * devm_fwnode_get_index_gpiod_from_child - get a GPIO descriptor from a 189 - * device's child node 188 + * devm_fwnode_gpiod_get_index - get a GPIO descriptor from a given node 190 189 * @dev: GPIO consumer 190 + * @fwnode: firmware node containing GPIO reference 191 191 * @con_id: function within the GPIO consumer 192 192 * @index: index of the GPIO to obtain in the consumer 193 - * @child: firmware node (child of @dev) 194 193 * @flags: GPIO initialization flags 195 194 * @label: label to attach to the requested GPIO 196 195 * ··· 199 200 * On successful request the GPIO pin is configured in accordance with 200 201 * provided @flags. 201 202 */ 202 - struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, 203 - const char *con_id, int index, 204 - struct fwnode_handle *child, 205 - enum gpiod_flags flags, 206 - const char *label) 203 + struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev, 204 + struct fwnode_handle *fwnode, 205 + const char *con_id, int index, 206 + enum gpiod_flags flags, 207 + const char *label) 207 208 { 208 - char prop_name[32]; /* 32 is max size of property name */ 209 209 struct gpio_desc **dr; 210 210 struct gpio_desc *desc; 211 - unsigned int i; 212 211 213 212 dr = devres_alloc(devm_gpiod_release, sizeof(struct gpio_desc *), 214 213 GFP_KERNEL); 215 214 if (!dr) 216 215 return ERR_PTR(-ENOMEM); 217 216 218 - for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { 219 - if (con_id) 220 - snprintf(prop_name, sizeof(prop_name), "%s-%s", 221 - con_id, gpio_suffixes[i]); 222 - else 223 - snprintf(prop_name, sizeof(prop_name), "%s", 224 - gpio_suffixes[i]); 225 - 226 - desc = fwnode_get_named_gpiod(child, prop_name, index, flags, 227 - label); 228 - if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT)) 229 - break; 230 - } 217 + desc = fwnode_gpiod_get_index(fwnode, con_id, index, flags, label); 231 218 if (IS_ERR(desc)) { 232 219 devres_free(dr); 233 220 return desc; ··· 224 239 225 240 return desc; 226 241 } 227 - EXPORT_SYMBOL_GPL(devm_fwnode_get_index_gpiod_from_child); 242 + EXPORT_SYMBOL_GPL(devm_fwnode_gpiod_get_index); 228 243 229 244 /** 230 245 * devm_gpiod_get_index_optional - Resource-managed gpiod_get_index_optional()
+48
drivers/gpio/gpiolib.c
··· 4325 4325 } 4326 4326 4327 4327 /** 4328 + * fwnode_gpiod_get_index - obtain a GPIO from firmware node 4329 + * @fwnode: handle of the firmware node 4330 + * @con_id: function within the GPIO consumer 4331 + * @index: index of the GPIO to obtain for the consumer 4332 + * @flags: GPIO initialization flags 4333 + * @label: label to attach to the requested GPIO 4334 + * 4335 + * This function can be used for drivers that get their configuration 4336 + * from opaque firmware. 4337 + * 4338 + * The function properly finds the corresponding GPIO using whatever is the 4339 + * underlying firmware interface and then makes sure that the GPIO 4340 + * descriptor is requested before it is returned to the caller. 4341 + * 4342 + * Returns: 4343 + * On successful request the GPIO pin is configured in accordance with 4344 + * provided @flags. 4345 + * 4346 + * In case of error an ERR_PTR() is returned. 4347 + */ 4348 + struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode, 4349 + const char *con_id, int index, 4350 + enum gpiod_flags flags, 4351 + const char *label) 4352 + { 4353 + struct gpio_desc *desc; 4354 + char prop_name[32]; /* 32 is max size of property name */ 4355 + unsigned int i; 4356 + 4357 + for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { 4358 + if (con_id) 4359 + snprintf(prop_name, sizeof(prop_name), "%s-%s", 4360 + con_id, gpio_suffixes[i]); 4361 + else 4362 + snprintf(prop_name, sizeof(prop_name), "%s", 4363 + gpio_suffixes[i]); 4364 + 4365 + desc = fwnode_get_named_gpiod(fwnode, prop_name, index, flags, 4366 + label); 4367 + if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT)) 4368 + break; 4369 + } 4370 + 4371 + return desc; 4372 + } 4373 + EXPORT_SYMBOL_GPL(fwnode_gpiod_get_index); 4374 + 4375 + /** 4328 4376 * gpiod_count - return the number of GPIOs associated with a device / function 4329 4377 * or -ENOENT if no GPIO has been assigned to the requested function 4330 4378 * @dev: GPIO consumer, can be NULL for system-global GPIOs
+44 -10
include/linux/gpio/consumer.h
··· 176 176 const char *propname, int index, 177 177 enum gpiod_flags dflags, 178 178 const char *label); 179 - struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, 180 - const char *con_id, int index, 181 - struct fwnode_handle *child, 182 - enum gpiod_flags flags, 183 - const char *label); 179 + struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode, 180 + const char *con_id, int index, 181 + enum gpiod_flags flags, 182 + const char *label); 183 + struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev, 184 + struct fwnode_handle *child, 185 + const char *con_id, int index, 186 + enum gpiod_flags flags, 187 + const char *label); 184 188 185 189 #else /* CONFIG_GPIOLIB */ 186 190 ··· 536 532 } 537 533 538 534 static inline 535 + struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode, 536 + const char *con_id, int index, 537 + enum gpiod_flags flags, 538 + const char *label) 539 + { 540 + return ERR_PTR(-ENOSYS); 541 + } 542 + 543 + static inline 544 + struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev, 545 + struct fwnode_handle *fwnode, 546 + const char *con_id, int index, 547 + enum gpiod_flags flags, 548 + const char *label) 549 + { 550 + return ERR_PTR(-ENOSYS); 551 + } 552 + 553 + #endif /* CONFIG_GPIOLIB */ 554 + 555 + static inline 556 + struct gpio_desc *devm_fwnode_gpiod_get(struct device *dev, 557 + struct fwnode_handle *fwnode, 558 + const char *con_id, 559 + enum gpiod_flags flags, 560 + const char *label) 561 + { 562 + return devm_fwnode_gpiod_get_index(dev, fwnode, con_id, 0, 563 + flags, label); 564 + } 565 + 566 + static inline 539 567 struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, 540 568 const char *con_id, int index, 541 569 struct fwnode_handle *child, 542 570 enum gpiod_flags flags, 543 571 const char *label) 544 572 { 545 - return ERR_PTR(-ENOSYS); 573 + return devm_fwnode_gpiod_get_index(dev, child, con_id, index, 574 + flags, label); 546 575 } 547 - 548 - #endif /* CONFIG_GPIOLIB */ 549 576 550 577 static inline 551 578 struct gpio_desc *devm_fwnode_get_gpiod_from_child(struct device *dev, ··· 585 550 enum gpiod_flags flags, 586 551 const char *label) 587 552 { 588 - return devm_fwnode_get_index_gpiod_from_child(dev, con_id, 0, child, 589 - flags, label); 553 + return devm_fwnode_gpiod_get_index(dev, child, con_id, 0, flags, label); 590 554 } 591 555 592 556 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_OF_GPIO)