diff mbox

[1/2] ASoC: cs35l33: Fix testing return value of devm_gpiod_get_optional

Message ID 1467245614.7105.2.camel@ingics.com (mailing list archive)
State Accepted
Commit 410fe39c6d2116aa5584083cbcbb7b3796e09f5d
Headers show

Commit Message

Axel Lin June 30, 2016, 12:13 a.m. UTC
devm_gpiod_get_optional() returns NULL when the gpio is not assigned.
So the if (PTR_ERR(cs35l33->reset_gpio) == -ENOENT) test is always false.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 sound/soc/codecs/cs35l33.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Paul Handrigan June 30, 2016, 3:36 p.m. UTC | #1
On 6/29/16, 7:13 PM, "Axel Lin" <axel.lin@ingics.com> wrote:

>devm_gpiod_get_optional() returns NULL when the gpio is not assigned.
>So the if (PTR_ERR(cs35l33->reset_gpio) == -ENOENT) test is always false.
>
>Signed-off-by: Axel Lin <axel.lin@ingics.com>
>---
> sound/soc/codecs/cs35l33.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
>diff --git a/sound/soc/codecs/cs35l33.c b/sound/soc/codecs/cs35l33.c
>index 622a111..aa5c0c5 100644
>--- a/sound/soc/codecs/cs35l33.c
>+++ b/sound/soc/codecs/cs35l33.c
>@@ -1176,11 +1176,7 @@ static int cs35l33_i2c_probe(struct i2c_client
>*i2c_client,
> 	/* We could issue !RST or skip it based on AMP topology */
> 	cs35l33->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev,
> 			"reset-gpios", GPIOD_OUT_HIGH);
>-
>-	if (PTR_ERR(cs35l33->reset_gpio) == -ENOENT) {
>-		dev_warn(&i2c_client->dev,
>-			"%s WARNING: No reset gpio assigned\n", __func__);
>-	} else if (IS_ERR(cs35l33->reset_gpio)) {
>+	if (IS_ERR(cs35l33->reset_gpio)) {
> 		dev_err(&i2c_client->dev, "%s ERROR: Can't get reset GPIO\n",
> 			__func__);
> 		return PTR_ERR(cs35l33->reset_gpio)
Acked-by: Paul Handrigan <Paul.Handrigan@cirrus.com>
diff mbox

Patch

diff --git a/sound/soc/codecs/cs35l33.c b/sound/soc/codecs/cs35l33.c
index 622a111..aa5c0c5 100644
--- a/sound/soc/codecs/cs35l33.c
+++ b/sound/soc/codecs/cs35l33.c
@@ -1176,11 +1176,7 @@  static int cs35l33_i2c_probe(struct i2c_client *i2c_client,
 	/* We could issue !RST or skip it based on AMP topology */
 	cs35l33->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev,
 			"reset-gpios", GPIOD_OUT_HIGH);
-
-	if (PTR_ERR(cs35l33->reset_gpio) == -ENOENT) {
-		dev_warn(&i2c_client->dev,
-			"%s WARNING: No reset gpio assigned\n", __func__);
-	} else if (IS_ERR(cs35l33->reset_gpio)) {
+	if (IS_ERR(cs35l33->reset_gpio)) {
 		dev_err(&i2c_client->dev, "%s ERROR: Can't get reset GPIO\n",
 			__func__);
 		return PTR_ERR(cs35l33->reset_gpio);