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

pinctrl: Move for_each_maps() to namespace and hide iterator inside

First of all, while for_each_maps() is private to pin control subsystem
it's still better to have it put into a namespace.

Besides that, users are not relying on iterator variable, so hide it
inside for-loop.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221111120048.42968-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Andy Shevchenko and committed by
Linus Walleij
06de5193 5a004736

+7 -9
+2 -4
drivers/pinctrl/core.c
··· 1029 1029 struct pinctrl *p; 1030 1030 const char *devname; 1031 1031 struct pinctrl_maps *maps_node; 1032 - int i; 1033 1032 const struct pinctrl_map *map; 1034 1033 int ret; 1035 1034 ··· 1054 1055 1055 1056 mutex_lock(&pinctrl_maps_mutex); 1056 1057 /* Iterate over the pin control maps to locate the right ones */ 1057 - for_each_maps(maps_node, i, map) { 1058 + for_each_pin_map(maps_node, map) { 1058 1059 /* Map must be for this device */ 1059 1060 if (strcmp(map->dev_name, devname)) 1060 1061 continue; ··· 1805 1806 static int pinctrl_maps_show(struct seq_file *s, void *what) 1806 1807 { 1807 1808 struct pinctrl_maps *maps_node; 1808 - int i; 1809 1809 const struct pinctrl_map *map; 1810 1810 1811 1811 seq_puts(s, "Pinctrl maps:\n"); 1812 1812 1813 1813 mutex_lock(&pinctrl_maps_mutex); 1814 - for_each_maps(maps_node, i, map) { 1814 + for_each_pin_map(maps_node, map) { 1815 1815 seq_printf(s, "device %s\nstate %s\ntype %s (%d)\n", 1816 1816 map->dev_name, map->name, map_type(map->type), 1817 1817 map->type);
+5 -5
drivers/pinctrl/core.h
··· 252 252 extern struct mutex pinctrl_maps_mutex; 253 253 extern struct list_head pinctrl_maps; 254 254 255 - #define for_each_maps(_maps_node_, _i_, _map_) \ 256 - list_for_each_entry(_maps_node_, &pinctrl_maps, node) \ 257 - for (_i_ = 0, _map_ = &_maps_node_->maps[_i_]; \ 258 - _i_ < _maps_node_->num_maps; \ 259 - _i_++, _map_ = &_maps_node_->maps[_i_]) 255 + #define for_each_pin_map(_maps_node_, _map_) \ 256 + list_for_each_entry(_maps_node_, &pinctrl_maps, node) \ 257 + for (unsigned int __i = 0; \ 258 + __i < _maps_node_->num_maps && (_map_ = &_maps_node_->maps[__i]); \ 259 + __i++)