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.

pinctrl: core: add devm_pinctrl_register_mappings()

Using devm_pinctrl_register_mappings(), the core can automatically
unregister pinctrl mappings.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
Link: https://lore.kernel.org/20250520-aaeon-up-board-pinctrl-support-v6-3-dcb3756be3c6@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Thomas Richard and committed by
Linus Walleij
2e9ba1d9 223657cf

+40
+29
drivers/pinctrl/core.c
··· 1530 1530 } 1531 1531 EXPORT_SYMBOL_GPL(pinctrl_unregister_mappings); 1532 1532 1533 + static void devm_pinctrl_unregister_mappings(void *maps) 1534 + { 1535 + pinctrl_unregister_mappings(maps); 1536 + } 1537 + 1538 + /** 1539 + * devm_pinctrl_register_mappings() - Resource managed pinctrl_register_mappings() 1540 + * @dev: device for which mappings are registered 1541 + * @maps: the pincontrol mappings table to register. Note the pinctrl-core 1542 + * keeps a reference to the passed in maps, so they should _not_ be 1543 + * marked with __initdata. 1544 + * @num_maps: the number of maps in the mapping table 1545 + * 1546 + * Returns: 0 on success, or negative errno on failure. 1547 + */ 1548 + int devm_pinctrl_register_mappings(struct device *dev, 1549 + const struct pinctrl_map *maps, 1550 + unsigned int num_maps) 1551 + { 1552 + int ret; 1553 + 1554 + ret = pinctrl_register_mappings(maps, num_maps); 1555 + if (ret) 1556 + return ret; 1557 + 1558 + return devm_add_action_or_reset(dev, devm_pinctrl_unregister_mappings, (void *)maps); 1559 + } 1560 + EXPORT_SYMBOL_GPL(devm_pinctrl_register_mappings); 1561 + 1533 1562 /** 1534 1563 * pinctrl_force_sleep() - turn a given controller device into sleep state 1535 1564 * @pctldev: pin controller device
+11
include/linux/pinctrl/machine.h
··· 149 149 #define PIN_MAP_CONFIGS_GROUP_HOG_DEFAULT(dev, grp, cfgs) \ 150 150 PIN_MAP_CONFIGS_GROUP(dev, PINCTRL_STATE_DEFAULT, dev, grp, cfgs) 151 151 152 + struct device; 152 153 struct pinctrl_map; 153 154 154 155 #ifdef CONFIG_PINCTRL 155 156 156 157 int pinctrl_register_mappings(const struct pinctrl_map *map, 157 158 unsigned int num_maps); 159 + int devm_pinctrl_register_mappings(struct device *dev, 160 + const struct pinctrl_map *map, 161 + unsigned int num_maps); 158 162 void pinctrl_unregister_mappings(const struct pinctrl_map *map); 159 163 void pinctrl_provide_dummies(void); 160 164 #else 161 165 162 166 static inline int pinctrl_register_mappings(const struct pinctrl_map *map, 163 167 unsigned int num_maps) 168 + { 169 + return 0; 170 + } 171 + 172 + static inline int devm_pinctrl_register_mappings(struct device *dev, 173 + const struct pinctrl_map *map, 174 + unsigned int num_maps) 164 175 { 165 176 return 0; 166 177 }