kernel: config: add missing symbol for kenrel 6.6
[openwrt/staging/stintel.git] / target / linux / ramips / patches-5.15 / 808-pinctrl-mtmips-support-requesting-different-function.patch
1 From: Shiji Yang <yangshiji66@outlook.com>
2 Date: Wed, 26 Jul 2023 01:32:55 +0800
3 Subject: [PATCH] pinctrl: mtmips: support requesting different functions for
4 same group
5
6 Sometimes pinctrl consumers may request different functions for the
7 same pin group in different situations. This patch can help to reset
8 the group function flag when requesting a different function.
9
10 Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
11 ---
12 drivers/pinctrl/ralink/pinctrl-ralink.c | 21 +++++++++++++++++----
13 1 file changed, 17 insertions(+), 4 deletions(-)
14
15 --- a/drivers/pinctrl/ralink/pinctrl-ralink.c
16 +++ b/drivers/pinctrl/ralink/pinctrl-ralink.c
17 @@ -123,11 +123,24 @@ static int ralink_pmx_group_enable(struc
18 int i;
19 int shift;
20
21 - /* dont allow double use */
22 + /*
23 + * for the same pin group, if request a different function,
24 + * then clear the group function flag and continue, else exit.
25 + */
26 if (p->groups[group].enabled) {
27 - dev_err(p->dev, "%s is already enabled\n",
28 - p->groups[group].name);
29 - return 0;
30 + for (i = 0; i < p->groups[group].func_count; i++) {
31 + if (p->groups[group].func[i].enabled == 1) {
32 + if (!strcmp(p->func[func]->name,
33 + p->groups[group].func[i].name))
34 + return 0;
35 + p->groups[group].func[i].enabled = 0;
36 + break;
37 + }
38 + }
39 +
40 + /* exit if request the "gpio" function again */
41 + if (i == p->groups[group].func_count && func == 0)
42 + return 0;
43 }
44
45 p->groups[group].enabled = 1;