Skip to contentSkip to conversation

trivial: pinctrl core: remove extraneous code lines

PATCH Applied Richard Genoud 3 participants 3 messages Aug 10, 2012 – Aug 13, 2012 Pin control

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trivial: pinctrl core: remove extraneous code lines

In function pinctrl_get_locked, pointer p is returned on error, and also return on no_error.
So, we just return it with no error test.

It's pretty the same in function pinctrl_lookup_state_locked: state is returned in every case, so we drop the error test and just return state.

---
 drivers/pinctrl/core.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
drivers/pinctrl/core.c +2 -8
index fb7f3be..7365d46 100644
@@ -657,11 +657,7 @@ static struct pinctrl *pinctrl_get_locked(struct device *dev)
 	if (p != NULL)
 		return ERR_PTR(-EBUSY);
 
-	p = create_pinctrl(dev);
-	if (IS_ERR(p))
-		return p;
-
-	return p;
+	return create_pinctrl(dev);
 }
 
 /**
@@ -738,10 +734,8 @@ static struct pinctrl_state *pinctrl_lookup_state_locked(struct pinctrl *p,
 			dev_dbg(p->dev, "using pinctrl dummy state (%s)\n",
 				name);
 			state = create_state(p, name);
-			if (IS_ERR(state))
-				return state;
 		} else {
-			return ERR_PTR(-ENODEV);
+			state = ERR_PTR(-ENODEV);
 		}
 	}
 
Signature · 1 line
1.7.2.5
#1 lore raw
Quoted 17 lines · Richard Genoud

In function pinctrl_get_locked, pointer p is returned on error, and also return on no_error.
So, we just return it with no error test.

It's pretty the same in function pinctrl_lookup_state_locked: state is returned in every case, so we drop the error test and just return state.

---
 drivers/pinctrl/core.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
drivers/pinctrl/core.c +0 -0
index fb7f3be..7365d46 100644

drivers/pinctrl/core.c static struct pinctrl *pinctrl_get_locked(struct device *dev) · line 661

Quoted 10 lines
drivers/pinctrl/core.c +1 -5
@@ -657,11 +657,7 @@ static struct pinctrl *pinctrl_get_locked(struct device *dev)
 	if (p != NULL)
 		return ERR_PTR(-EBUSY);
 
-	p = create_pinctrl(dev);
-	if (IS_ERR(p))
-		return p;
-
-	return p;
+	return create_pinctrl(dev);
 }

This makes sense.

drivers/pinctrl/core.c static struct pinctrl_state *pinctrl_lookup_state_locked(struct pinctrl *p, · line 740

Quoted 12 lines
drivers/pinctrl/core.c +1 -3
 /**
@@ -738,10 +734,8 @@ static struct pinctrl_state *pinctrl_lookup_state_locked(struct pinctrl *p,
 			dev_dbg(p->dev, "using pinctrl dummy state (%s)\n",
 				name);
 			state = create_state(p, name);
-			if (IS_ERR(state))
-				return state;
 		} else {
-			return ERR_PTR(-ENODEV);
+			state = ERR_PTR(-ENODEV);
 		}
 	}

Personally I find the code much clearer as it is, but the result of this patch still looks correct.

#2 lore raw
In reply to Richard Genoud
Quoted 8 lines · Richard Genoud

In function pinctrl_get_locked, pointer p is returned on error, and also return on no_error.
So, we just return it with no error test.

It's pretty the same in function pinctrl_lookup_state_locked: state is returned in every case, so we drop the error test and just return state.

Applied. While I sort of agree with Stephen on the point of the second hunk being cleaner as it was, it's no big deal so whatever.

I took this opportunity to cut some parens tho:

@@ -657,11 +657,7 @@ static struct pinctrl *pinctrl_get_locked(struct device *dev)

        if (p != NULL)
                return ERR_PTR(-EBUSY);

- p = create_pinctrl(dev);
- if (IS_ERR(p))
- return p;
-
- return p;
+ return create_pinctrl(dev);
}

/**
@@ -738,11 +734,8 @@ static struct pinctrl_state
*pinctrl_lookup_state_locked(struct pinctrl *p,

                        dev_dbg(p->dev, "using pinctrl dummy state (%s)\n",
                                name);
                        state = create_state(p, name);

- if (IS_ERR(state))
- return state;
- } else {
- return ERR_PTR(-ENODEV);
- }
+ } else

+                       state = ERR_PTR(-ENODEV);
        }

Yours,
Linus Walleij