Skip to content

Commit 85174ad

Browse files
andy-shevlinusw
authored andcommitted
pinctrl: core: Embed struct pingroup into struct group_desc
struct group_desc is a particular version of the struct pingroup with associated opaque data. Start switching pin control core and drivers to use it explicitly. Reviewed-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent b0f24e0 commit 85174ad

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

drivers/pinctrl/core.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,10 @@ const char *pinctrl_generic_get_group_name(struct pinctrl_dev *pctldev,
557557
if (!group)
558558
return NULL;
559559

560-
return group->name;
560+
if (group->name)
561+
return group->name;
562+
563+
return group->grp.name;
561564
}
562565
EXPORT_SYMBOL_GPL(pinctrl_generic_get_group_name);
563566

@@ -583,8 +586,14 @@ int pinctrl_generic_get_group_pins(struct pinctrl_dev *pctldev,
583586
return -EINVAL;
584587
}
585588

586-
*pins = group->pins;
587-
*num_pins = group->num_pins;
589+
if (group->pins) {
590+
*pins = group->pins;
591+
*num_pins = group->num_pins;
592+
return 0;
593+
}
594+
595+
*pins = group->grp.pins;
596+
*num_pins = group->grp.npins;
588597

589598
return 0;
590599
}

drivers/pinctrl/core.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,18 @@ struct pinctrl_maps {
194194

195195
#ifdef CONFIG_GENERIC_PINCTRL_GROUPS
196196

197+
#include <linux/pinctrl/pinctrl.h>
198+
197199
/**
198200
* struct group_desc - generic pin group descriptor
201+
* @grp: generic data of the pin group (name and pins)
199202
* @name: name of the pin group
200203
* @pins: array of pins that belong to the group
201204
* @num_pins: number of pins in the group
202205
* @data: pin controller driver specific data
203206
*/
204207
struct group_desc {
208+
struct pingroup grp;
205209
const char *name;
206210
const unsigned int *pins;
207211
int num_pins;
@@ -211,6 +215,7 @@ struct group_desc {
211215
/* Convenience macro to define a generic pin group descriptor */
212216
#define PINCTRL_GROUP_DESC(_name, _pins, _num_pins, _data) \
213217
(struct group_desc) { \
218+
.grp = PINCTRL_PINGROUP(_name, _pins, _num_pins), \
214219
.name = _name, \
215220
.pins = _pins, \
216221
.num_pins = _num_pins, \

0 commit comments

Comments
 (0)