Skip to content

Commit 036f394

Browse files
benjamingaignardlinusw
authored andcommitted
pinctrl: Enable device link creation for pin control
A pin controller may want to create a link between itself and its clients to be sure of suspend/resume call ordering. Introduce link_consumers field in pinctrl_desc structure to let pinctrl core knows that controller expect to create a link. Signed-off-by: Benjamin Gaignard <[email protected]> [Renamed create_link to link_consumers] Signed-off-by: Linus Walleij <[email protected]>
1 parent ee11f86 commit 036f394

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/pinctrl/core.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,15 @@ struct pinctrl_state *pinctrl_lookup_state(struct pinctrl *p,
12161216
}
12171217
EXPORT_SYMBOL_GPL(pinctrl_lookup_state);
12181218

1219+
static void pinctrl_link_add(struct pinctrl_dev *pctldev,
1220+
struct device *consumer)
1221+
{
1222+
if (pctldev->desc->link_consumers)
1223+
device_link_add(consumer, pctldev->dev,
1224+
DL_FLAG_PM_RUNTIME |
1225+
DL_FLAG_AUTOREMOVE_CONSUMER);
1226+
}
1227+
12191228
/**
12201229
* pinctrl_commit_state() - select/activate/program a pinctrl state to HW
12211230
* @p: the pinctrl handle for the device that requests configuration
@@ -1261,6 +1270,8 @@ static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)
12611270
if (ret < 0) {
12621271
goto unapply_new_state;
12631272
}
1273+
1274+
pinctrl_link_add(setting->pctldev, p->dev);
12641275
}
12651276

12661277
p->state = state;

include/linux/pinctrl/pinctrl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ struct pinctrl_ops {
125125
* the hardware description
126126
* @custom_conf_items: Information how to print @params in debugfs, must be
127127
* the same size as the @custom_params, i.e. @num_custom_params
128+
* @link_consumers: If true create a device link between pinctrl and its
129+
* consumers (i.e. the devices requesting pin control states). This is
130+
* sometimes necessary to ascertain the right suspend/resume order for
131+
* example.
128132
*/
129133
struct pinctrl_desc {
130134
const char *name;
@@ -139,6 +143,7 @@ struct pinctrl_desc {
139143
const struct pinconf_generic_params *custom_params;
140144
const struct pin_config_item *custom_conf_items;
141145
#endif
146+
bool link_consumers;
142147
};
143148

144149
/* External interface to pin controller */

0 commit comments

Comments
 (0)