Skip to content

Commit

Permalink
pinctrl: move strict option to pinmux_ops
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
linusw committed May 6, 2015
1 parent fa76a3d commit 8c4c201
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Documentation/pinctrl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ static struct pinctrl_desc foo_desc = {
.pins = foo_pins,
.npins = ARRAY_SIZE(foo_pins),
.owner = THIS_MODULE,
.strict = true,
};

int __init foo_probe(void)
Expand Down Expand Up @@ -715,6 +714,7 @@ static struct pinmux_ops foo_pmxops = {
.get_function_name = foo_get_fname,
.get_function_groups = foo_get_groups,
.set_mux = foo_set_mux,
.strict = true,
};

/* Pinmux operations are handled by some pin controller */
Expand Down
2 changes: 1 addition & 1 deletion drivers/pinctrl/pinctrl-adi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,14 +703,14 @@ static struct pinmux_ops adi_pinmux_ops = {
.get_function_name = adi_pinmux_get_func_name,
.get_function_groups = adi_pinmux_get_groups,
.gpio_request_enable = adi_pinmux_request_gpio,
.strict = true,
};


static struct pinctrl_desc adi_pinmux_desc = {
.name = DRIVER_NAME,
.pctlops = &adi_pctrl_ops,
.pmxops = &adi_pinmux_ops,
.strict = true,
.owner = THIS_MODULE,
};

Expand Down
4 changes: 2 additions & 2 deletions drivers/pinctrl/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
desc->name, desc->gpio_owner, owner);
goto out;
}
if (pctldev->desc->strict && desc->mux_usecount &&
if (ops->strict && desc->mux_usecount &&
strcmp(desc->mux_owner, owner)) {
dev_err(pctldev->dev,
"pin %s already requested by %s; cannot claim for %s\n",
Expand All @@ -123,7 +123,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
desc->name, desc->mux_owner, owner);
goto out;
}
if (pctldev->desc->strict && desc->gpio_owner) {
if (ops->strict && desc->gpio_owner) {
dev_err(pctldev->dev,
"pin %s already requested by %s; cannot claim for %s\n",
desc->name, desc->gpio_owner, owner);
Expand Down
3 changes: 0 additions & 3 deletions include/linux/pinctrl/pinctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ struct pinctrl_ops {
* of the pins field above
* @pctlops: pin control operation vtable, to support global concepts like
* grouping of pins, this is optional.
* @strict: check both gpio_owner and mux_owner strictly before approving
the pin request
* @pmxops: pinmux operations vtable, if you support pinmuxing in your driver
* @confops: pin config operations vtable, if you support pin configuration in
* your driver
Expand All @@ -134,7 +132,6 @@ struct pinctrl_desc {
const struct pinctrl_ops *pctlops;
const struct pinmux_ops *pmxops;
const struct pinconf_ops *confops;
bool strict;
struct module *owner;
#ifdef CONFIG_GENERIC_PINCONF
unsigned int num_custom_params;
Expand Down
4 changes: 4 additions & 0 deletions include/linux/pinctrl/pinmux.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ struct pinctrl_dev;
* depending on whether the GPIO is configured as input or output,
* a direction selector function may be implemented as a backing
* to the GPIO controllers that need pin muxing.
* @strict: do not allow simultaneous use of the same pin for GPIO and another
* function. Check both gpio_owner and mux_owner strictly before approving
* the pin request.
*/
struct pinmux_ops {
int (*request) (struct pinctrl_dev *pctldev, unsigned offset);
Expand All @@ -79,6 +82,7 @@ struct pinmux_ops {
struct pinctrl_gpio_range *range,
unsigned offset,
bool input);
bool strict;
};

#endif /* CONFIG_PINMUX */
Expand Down

0 comments on commit 8c4c201

Please sign in to comment.