From fa76a3db7093a527333c380df82a0f158d9b8299 Mon Sep 17 00:00:00 2001 From: Sonic Zhang Date: Thu, 9 Apr 2015 11:13:07 +0800 Subject: pinctrl: allow exlusive GPIO/mux pin allocation Disallow simultaneous use of the the GPIO and peripheral mux functions by setting a flag "strict" in struct pinctrl_desc. The blackfin pinmux and gpio controller doesn't allow user to set up a pin for both GPIO and peripheral function. So, add flag strict in struct pinctrl_desc to check both gpio_owner and mux_owner before approving the pin request. v2-changes: - if strict flag is set, check gpio_owner and mux_onwer in if and else clause v3-changes: - add kerneldoc for this struct - augment Documentation/pinctrl.txt Signed-off-by: Sonic Zhang Signed-off-by: Linus Walleij --- drivers/pinctrl/pinmux.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'drivers/pinctrl/pinmux.c') diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index b874458dcb88..2546fa783464 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -107,6 +107,13 @@ static int pin_request(struct pinctrl_dev *pctldev, desc->name, desc->gpio_owner, owner); goto out; } + if (pctldev->desc->strict && desc->mux_usecount && + strcmp(desc->mux_owner, owner)) { + dev_err(pctldev->dev, + "pin %s already requested by %s; cannot claim for %s\n", + desc->name, desc->mux_owner, owner); + goto out; + } desc->gpio_owner = owner; } else { @@ -116,6 +123,12 @@ static int pin_request(struct pinctrl_dev *pctldev, desc->name, desc->mux_owner, owner); goto out; } + if (pctldev->desc->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); + goto out; + } desc->mux_usecount++; if (desc->mux_usecount > 1) -- cgit