pinctrl: simplify check for pin request conflicts
authorVladimir Zapolskiy <vz@mleia.com>
Sun, 25 Dec 2016 00:59:28 +0000 (02:59 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 30 Dec 2016 09:11:05 +0000 (10:11 +0100)
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: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinmux.c

index ece702881946dd849cae2e7adf2c992697b29fdd..9373146f3afc5bacf7fc66d7f300a32689b3cd28 100644 (file)
@@ -99,37 +99,24 @@ static int pin_request(struct pinctrl_dev *pctldev,
        dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n",
                pin, desc->name, owner);
 
-       if (gpio_range) {
-               /* There's no need to support multiple GPIO requests */
-               if (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;
-               }
-               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",
-                               desc->name, desc->mux_owner, owner);
-                       goto out;
-               }
+       if ((!gpio_range || 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",
+                       desc->name, desc->mux_owner, owner);
+               goto out;
+       }
+
+       if ((gpio_range || 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;
+       }
 
+       if (gpio_range) {
                desc->gpio_owner = owner;
        } 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++;
                if (desc->mux_usecount > 1)
                        return 0;