Commit b1eb8fab authored by Vladimir Zapolskiy's avatar Vladimir Zapolskiy Committed by Linus Walleij

pinctrl: simplify check for pin request conflicts

This is a non-functional change, which deletes code duplication in two
of four if-if branches by reordering the checks. Functional identity
of the code change can be shown by running through the whole truth table
of boolean arguments.
Signed-off-by: default avatarVladimir Zapolskiy <vz@mleia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 55e40950
...@@ -99,37 +99,24 @@ static int pin_request(struct pinctrl_dev *pctldev, ...@@ -99,37 +99,24 @@ static int pin_request(struct pinctrl_dev *pctldev,
dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n", dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n",
pin, desc->name, owner); pin, desc->name, owner);
if (gpio_range) { if ((!gpio_range || ops->strict) &&
/* There's no need to support multiple GPIO requests */ desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
if (desc->gpio_owner) { dev_err(pctldev->dev,
dev_err(pctldev->dev, "pin %s already requested by %s; cannot claim for %s\n",
"pin %s already requested by %s; cannot claim for %s\n", desc->name, desc->mux_owner, owner);
desc->name, desc->gpio_owner, owner); goto out;
goto out; }
}
if (ops->strict && desc->mux_usecount && if ((gpio_range || ops->strict) && desc->gpio_owner) {
strcmp(desc->mux_owner, owner)) { dev_err(pctldev->dev,
dev_err(pctldev->dev, "pin %s already requested by %s; cannot claim for %s\n",
"pin %s already requested by %s; cannot claim for %s\n", desc->name, desc->gpio_owner, owner);
desc->name, desc->mux_owner, owner); goto out;
goto out; }
}
if (gpio_range) {
desc->gpio_owner = owner; desc->gpio_owner = owner;
} else { } else {
if (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;
}
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);
goto out;
}
desc->mux_usecount++; desc->mux_usecount++;
if (desc->mux_usecount > 1) if (desc->mux_usecount > 1)
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment