Skip to content

Commit 8c4c201

Browse files
author
Linus Walleij
committed
pinctrl: move strict option to pinmux_ops
While the pinmux_ops are ideally just a vtable for pin mux calls, the "strict" setting belongs so intuitively with the pin multiplexing that we should move it here anyway. Putting it in the top pinctrl_desc makes no sense. Cc: Sonic Zhang <sonic.zhang@analog.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent fa76a3d commit 8c4c201

5 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎Documentation/pinctrl.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ static struct pinctrl_desc foo_desc = {
7373
.pins = foo_pins,
7474
.npins = ARRAY_SIZE(foo_pins),
7575
.owner = THIS_MODULE,
76-
.strict = true,
7776
};
7877

7978
int __init foo_probe(void)
@@ -715,6 +714,7 @@ static struct pinmux_ops foo_pmxops = {
715714
.get_function_name = foo_get_fname,
716715
.get_function_groups = foo_get_groups,
717716
.set_mux = foo_set_mux,
717+
.strict = true,
718718
};
719719

720720
/* Pinmux operations are handled by some pin controller */

‎drivers/pinctrl/pinctrl-adi2.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,14 +703,14 @@ static struct pinmux_ops adi_pinmux_ops = {
703703
.get_function_name = adi_pinmux_get_func_name,
704704
.get_function_groups = adi_pinmux_get_groups,
705705
.gpio_request_enable = adi_pinmux_request_gpio,
706+
.strict = true,
706707
};
707708

708709

709710
static struct pinctrl_desc adi_pinmux_desc = {
710711
.name = DRIVER_NAME,
711712
.pctlops = &adi_pctrl_ops,
712713
.pmxops = &adi_pinmux_ops,
713-
.strict = true,
714714
.owner = THIS_MODULE,
715715
};
716716

‎drivers/pinctrl/pinmux.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
107107
desc->name, desc->gpio_owner, owner);
108108
goto out;
109109
}
110-
if (pctldev->desc->strict && desc->mux_usecount &&
110+
if (ops->strict && desc->mux_usecount &&
111111
strcmp(desc->mux_owner, owner)) {
112112
dev_err(pctldev->dev,
113113
"pin %s already requested by %s; cannot claim for %s\n",
@@ -123,7 +123,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
123123
desc->name, desc->mux_owner, owner);
124124
goto out;
125125
}
126-
if (pctldev->desc->strict && desc->gpio_owner) {
126+
if (ops->strict && desc->gpio_owner) {
127127
dev_err(pctldev->dev,
128128
"pin %s already requested by %s; cannot claim for %s\n",
129129
desc->name, desc->gpio_owner, owner);

‎include/linux/pinctrl/pinctrl.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ struct pinctrl_ops {
114114
* of the pins field above
115115
* @pctlops: pin control operation vtable, to support global concepts like
116116
* grouping of pins, this is optional.
117-
* @strict: check both gpio_owner and mux_owner strictly before approving
118-
the pin request
119117
* @pmxops: pinmux operations vtable, if you support pinmuxing in your driver
120118
* @confops: pin config operations vtable, if you support pin configuration in
121119
* your driver
@@ -134,7 +132,6 @@ struct pinctrl_desc {
134132
const struct pinctrl_ops *pctlops;
135133
const struct pinmux_ops *pmxops;
136134
const struct pinconf_ops *confops;
137-
bool strict;
138135
struct module *owner;
139136
#ifdef CONFIG_GENERIC_PINCONF
140137
unsigned int num_custom_params;

‎include/linux/pinctrl/pinmux.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ struct pinctrl_dev;
5656
* depending on whether the GPIO is configured as input or output,
5757
* a direction selector function may be implemented as a backing
5858
* to the GPIO controllers that need pin muxing.
59+
* @strict: do not allow simultaneous use of the same pin for GPIO and another
60+
* function. Check both gpio_owner and mux_owner strictly before approving
61+
* the pin request.
5962
*/
6063
struct pinmux_ops {
6164
int (*request) (struct pinctrl_dev *pctldev, unsigned offset);
@@ -79,6 +82,7 @@ struct pinmux_ops {
7982
struct pinctrl_gpio_range *range,
8083
unsigned offset,
8184
bool input);
85+
bool strict;
8286
};
8387

8488
#endif /* CONFIG_PINMUX */

0 commit comments

Comments
 (0)