summaryrefslogtreecommitdiff
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2022-11-11 14:00:48 +0200
committerLinus Walleij <linus.walleij@linaro.org>2022-11-14 14:19:33 +0100
commit06de519345f4af5b7ee48aaa30228fe5ac5de233 (patch)
tree4eac0e369d678fb46a3f8e93c4ff8ce6020b4263 /drivers/pinctrl
parent5a0047360743695ecfe4ca33300222ddd39c4612 (diff)
downloadlwn-06de519345f4af5b7ee48aaa30228fe5ac5de233.tar.gz
lwn-06de519345f4af5b7ee48aaa30228fe5ac5de233.zip
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>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/core.c6
-rw-r--r--drivers/pinctrl/core.h10
2 files changed, 7 insertions, 9 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 655f9502e73f..41fd84738707 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1029,7 +1029,6 @@ static struct pinctrl *create_pinctrl(struct device *dev,
struct pinctrl *p;
const char *devname;
struct pinctrl_maps *maps_node;
- int i;
const struct pinctrl_map *map;
int ret;
@@ -1055,7 +1054,7 @@ static struct pinctrl *create_pinctrl(struct device *dev,
mutex_lock(&pinctrl_maps_mutex);
/* Iterate over the pin control maps to locate the right ones */
- for_each_maps(maps_node, i, map) {
+ for_each_pin_map(maps_node, map) {
/* Map must be for this device */
if (strcmp(map->dev_name, devname))
continue;
@@ -1806,13 +1805,12 @@ static inline const char *map_type(enum pinctrl_map_type type)
static int pinctrl_maps_show(struct seq_file *s, void *what)
{
struct pinctrl_maps *maps_node;
- int i;
const struct pinctrl_map *map;
seq_puts(s, "Pinctrl maps:\n");
mutex_lock(&pinctrl_maps_mutex);
- for_each_maps(maps_node, i, map) {
+ for_each_pin_map(maps_node, map) {
seq_printf(s, "device %s\nstate %s\ntype %s (%d)\n",
map->dev_name, map->name, map_type(map->type),
map->type);
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 4d0bdb9fb99b..530370443c19 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -252,8 +252,8 @@ extern int pinctrl_force_default(struct pinctrl_dev *pctldev);
extern struct mutex pinctrl_maps_mutex;
extern struct list_head pinctrl_maps;
-#define for_each_maps(_maps_node_, _i_, _map_) \
- list_for_each_entry(_maps_node_, &pinctrl_maps, node) \
- for (_i_ = 0, _map_ = &_maps_node_->maps[_i_]; \
- _i_ < _maps_node_->num_maps; \
- _i_++, _map_ = &_maps_node_->maps[_i_])
+#define for_each_pin_map(_maps_node_, _map_) \
+ list_for_each_entry(_maps_node_, &pinctrl_maps, node) \
+ for (unsigned int __i = 0; \
+ __i < _maps_node_->num_maps && (_map_ = &_maps_node_->maps[__i]); \
+ __i++)