Skip to contentSkip to conversation

ASoC: tegra: improve goto error label

PATCH In review Marcel Ziswiler 5 participants 13 messages Jul 20, 2018 – Jul 26, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ASoC: tegra: improve goto error label

From: Marcel Ziswiler <[email protected]>

While the two error labels "err" and "err_clk_put" goto the same place it is rather confusing that the earlier one is certainly used later again.

---

 sound/soc/tegra/tegra20_ac97.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/tegra/tegra20_ac97.c +1 -1
index affad46bf188..682ef33afb5f 100644
@@ -377,7 +377,7 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
 	ret = clk_prepare_enable(ac97->clk_ac97);
 	if (ret) {
 		dev_err(&pdev->dev, "clk_enable failed: %d\n", ret);
-		goto err;
+		goto err_clk_put;
 	}
 
 	ret = snd_soc_set_ac97_ops(&tegra20_ac97_ops);
Signature · 1 line
2.14.4
#1 lore raw

PATCH 2/2 ASoC: tegra: probe deferral error reporting

From: Marcel Ziswiler <[email protected]>

Actually report the error codes from of_get_named_gpio() resp. devm_gpio_request_one() upon trying to get the codec reset resp. sync GPIOs which may as well just be a probe deferrals.

---

 sound/soc/tegra/tegra20_ac97.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
sound/soc/tegra/tegra20_ac97.c +6 -3
index 682ef33afb5f..4875512f0732 100644
@@ -351,18 +351,21 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
 		ret = devm_gpio_request_one(&pdev->dev, ac97->reset_gpio,
 					    GPIOF_OUT_INIT_HIGH, "codec-reset");
 		if (ret) {
-			dev_err(&pdev->dev, "could not get codec-reset GPIO\n");
+			dev_err(&pdev->dev, "could not get codec-reset GPIO: "
+					    "%d\n", ret);
 			goto err_clk_put;
 		}
 	} else {
-		dev_err(&pdev->dev, "no codec-reset GPIO supplied\n");
+		ret = ac97->reset_gpio;
+		dev_err(&pdev->dev, "no codec-reset GPIO supplied: %d\n", ret);
 		goto err_clk_put;
 	}
 
 	ac97->sync_gpio = of_get_named_gpio(pdev->dev.of_node,
 					    "nvidia,codec-sync-gpio", 0);
 	if (!gpio_is_valid(ac97->sync_gpio)) {
-		dev_err(&pdev->dev, "no codec-sync GPIO supplied\n");
+		ret = ac97->sync_gpio;
+		dev_err(&pdev->dev, "no codec-sync GPIO supplied: %d\n", ret);
 		goto err_clk_put;
 	}
 
Signature · 1 line
2.14.4
maintainer
#2 lore raw

Re: [PATCH 2/2] ASoC: tegra: probe deferral error reporting

sound/soc/tegra/tegra20_ac97.c static int tegra20_ac97_platform_probe(struct platform_device *pdev) · line 355

Quoted 3 lines · Marcel Ziswiler
sound/soc/tegra/tegra20_ac97.c +2 -1
-			dev_err(&pdev->dev, "could not get codec-reset GPIO\n");
+			dev_err(&pdev->dev, "could not get codec-reset GPIO: "
+					    "%d\n", ret);

Don't split strings over lines like this, it causes problems when people grep for errors. It's better to go over 80 columns.

sound/soc/tegra/tegra20_ac97.c static int tegra20_ac97_platform_probe(struct platform_device *pdev) · line 370

Quoted 8 lines
sound/soc/tegra/tegra20_ac97.c +2 -1
 	ac97->sync_gpio = of_get_named_gpio(pdev->dev.of_node,
 					    "nvidia,codec-sync-gpio", 0);
 	if (!gpio_is_valid(ac97->sync_gpio)) {
-		dev_err(&pdev->dev, "no codec-sync GPIO supplied\n");
+		ret = ac97->sync_gpio;
+		dev_err(&pdev->dev, "no codec-sync GPIO supplied: %d\n", ret);
 		goto err_clk_put;
 	}

This isn't reporting an error code associated with the attempt to find a codec-sync GPIO, it's the result of some other operation.

maintainer
#12 lore raw

Applied "ASoC: tegra: improve goto error label" to the asoc tree

In reply to Marcel Ziswiler

The patch

ASoC: tegra: improve goto error label

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 2ec42486358f63c4a426514c395d13f4b9de5da8 Mon Sep 17 00:00:00 2001

From: Marcel Ziswiler <[email protected]>
Date: Fri, 20 Jul 2018 10:04:23 +0200
Subject: [PATCH] ASoC: tegra: improve goto error label

While the two error labels "err" and "err_clk_put" goto the same place it is rather confusing that the earlier one is certainly used later again.

---
 sound/soc/tegra/tegra20_ac97.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/tegra/tegra20_ac97.c +1 -1
index affad46bf188..682ef33afb5f 100644
@@ -377,7 +377,7 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
 	ret = clk_prepare_enable(ac97->clk_ac97);
 	if (ret) {
 		dev_err(&pdev->dev, "clk_enable failed: %d\n", ret);
-		goto err;
+		goto err_clk_put;
 	}
 
 	ret = snd_soc_set_ac97_ops(&tegra20_ac97_ops);
Signature · 1 line
2.18.0
#3 lore raw

Re: [PATCH 2/2] ASoC: tegra: probe deferral error reporting

In reply to Mark Brown
Quoted 11 lines · Mark Brown

sound/soc/tegra/tegra20_ac97.c static int tegra20_ac97_platform_probe(struct platform_device *pdev) · line 355

Quoted 5 lines · Marcel Ziswiler
(quoted diff) +0 -1
-			dev_err(&pdev->dev, "could not get codec-

reset GPIO\n");

(quoted diff) +1 -0
+			dev_err(&pdev->dev, "could not get codec-

reset GPIO: "

sound/soc/tegra/tegra20_ac97.c +1 -0
+					    "%d\n", ret);

Don't split strings over lines like this, it causes problems when people
grep for errors. It's better to go over 80 columns.

OK, will do. However, in this case I did not actually split anything searchable anyway.

Quoted 7 lines
Quoted 7 lines
(quoted diff) +0 -0
 	ac97->sync_gpio = of_get_named_gpio(pdev->dev.of_node,
 					    "nvidia,codec-sync-

gpio", 0);

(quoted diff) +0 -1
 	if (!gpio_is_valid(ac97->sync_gpio)) {
-		dev_err(&pdev->dev, "no codec-sync GPIO

supplied\n");

sound/soc/tegra/tegra20_ac97.c +1 -0
+		ret = ac97->sync_gpio;
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +1 -0
+		dev_err(&pdev->dev, "no codec-sync GPIO supplied:

%d\n", ret);

(quoted diff) +0 -0
 		goto err_clk_put;
 	}

This isn't reporting an error code associated with the attempt to find a
codec-sync GPIO, it's the result of some other operation.

What exactly is then the of_get_named_gpio() above please doing if not getting the codec sync GPIO? I am not following you, sorry.

maintainer
#4 lore raw

Re: [PATCH 2/2] ASoC: tegra: probe deferral error reporting

Quoted 18 lines · Marcel Ziswiler
Quoted 7 lines · Mark Brown
Quoted 7 lines
(quoted diff) +0 -0
 	ac97->sync_gpio = of_get_named_gpio(pdev->dev.of_node,
 					    "nvidia,codec-sync-

gpio", 0);

(quoted diff) +0 -1
 	if (!gpio_is_valid(ac97->sync_gpio)) {
-		dev_err(&pdev->dev, "no codec-sync GPIO

supplied\n");

sound/soc/tegra/tegra20_ac97.c +1 -0
+		ret = ac97->sync_gpio;
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +1 -0
+		dev_err(&pdev->dev, "no codec-sync GPIO supplied:

%d\n", ret);

(quoted diff) +0 -0
 		goto err_clk_put;
 	}

This isn't reporting an error code associated with the attempt to find a
codec-sync GPIO, it's the result of some other operation.

Quoted 2 lines

What exactly is then the of_get_named_gpio() above please doing if not getting the codec sync GPIO? I am not following you, sorry.

It's not in any way involved in setting the value of ret, whatever value that has it's nothing to do with that operation.

#5 lore raw

Re: [PATCH 2/2] ASoC: tegra: probe deferral error reporting

Quoted 6 lines · Mark Brown
Quoted 5 lines · Marcel Ziswiler
Quoted 4 lines · Mark Brown
Quoted 4 lines
(quoted diff) +0 -0
 	ac97->sync_gpio = of_get_named_gpio(pdev->dev.of_node,
 					    "nvidia,codec-

sync-
gpio", 0);

Above ac97->sync_gpio gets return value from of_get_named_gpio(), right?

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

if (!gpio_is_valid(ac97->sync_gpio)) {

Here it goes if ac97->sync_gpio is not a valid GPIO e.g. in an error case as reported by above of_get_named_gpio(), right?

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

sound/soc/tegra/tegra20_ac97.c static int tegra20_ac97_platform_probe(struct platform_device *pdev) · line 367

Quoted 3 lines
(quoted diff) +0 -1
-		dev_err(&pdev->dev, "no codec-sync GPIO

supplied\n");

sound/soc/tegra/tegra20_ac97.c +1 -0
+		ret = ac97->sync_gpio;

And here I assign ret with that return value from of_get_named_gpio(), right?

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
(quoted diff) +1 -0
+		dev_err(&pdev->dev, "no codec-sync GPIO

supplied:
%d\n", ret);

And then I actually report what error it was (e.g. probe deferral).

Quoted 11 lines
Quoted 7 lines
Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +0 -0
 		goto err_clk_put;
 	}

This isn't reporting an error code associated with the attempt to find a
codec-sync GPIO, it's the result of some other operation.

What exactly is then the of_get_named_gpio() above please doing if not getting the codec sync GPIO? I am not following you, sorry.

It's not in any way involved in setting the value of ret, whatever value
that has it's nothing to do with that operation.

I really do not understand what you are trying to get at, sorry.

#7 lore raw

Re: [PATCH 2/2] ASoC: tegra: probe deferral error reporting

In reply to Mark Brown
Quoted 24 lines · On Saturday, 21 July 2018 12:56:15 MSK Mark Brown wrote:
Quoted 23 lines · Marcel Ziswiler
Quoted 21 lines · Mark Brown
Quoted 14 lines
sound/soc/tegra/tegra20_ac97.c +0 -0
 	ac97->sync_gpio = of_get_named_gpio(pdev->dev.of_node,
 
 					    "nvidia,codec-sync-

gpio", 0);

sound/soc/tegra/tegra20_ac97.c +0 -1
 	if (!gpio_is_valid(ac97->sync_gpio)) {
 
-		dev_err(&pdev->dev, "no codec-sync GPIO

supplied\n");

(quoted diff) +2 -0
+		ret = ac97->sync_gpio;
+		dev_err(&pdev->dev, "no codec-sync GPIO supplied:

%d\n", ret);

sound/soc/tegra/tegra20_ac97.c static int tegra20_ac97_platform_probe(struct platform_device *pdev) · line 370

Quoted 3 lines
sound/soc/tegra/tegra20_ac97.c +0 -0
 		goto err_clk_put;
 
 	}

This isn't reporting an error code associated with the attempt to find a
codec-sync GPIO, it's the result of some other operation.

Quoted 5 lines
Quoted 2 lines

What exactly is then the of_get_named_gpio() above please doing if not getting the codec sync GPIO? I am not following you, sorry.

It's not in any way involved in setting the value of ret, whatever value that has it's nothing to do with that operation.

The comment to gpio_is_valid() says that it "Returns GPIO number to use with Linux generic GPIO API, or one of the errno value on the error condition". Comment doesn't explicitly states that the returned GPIO number is always valid, but it is kinda implied.

#8 lore raw

Re: [PATCH 2/2] ASoC: tegra: probe deferral error reporting

Quoted 37 lines · Dmitry Osipenko
Quoted 28 lines · On Saturday, 21 July 2018 12:56:15 MSK Mark Brown wrote:
Quoted 27 lines · Marcel Ziswiler
Quoted 25 lines · Mark Brown
Quoted 17 lines

ac97->sync_gpio = of_get_named_gpio(pdev-

Quoted 1 line

dev.of_node,

"nvidia,codec-
sync-

gpio", 0);

sound/soc/tegra/tegra20_ac97.c +0 -1
 	if (!gpio_is_valid(ac97->sync_gpio)) {
 
-		dev_err(&pdev->dev, "no codec-sync GPIO

supplied\n");

(quoted diff) +2 -0
+		ret = ac97->sync_gpio;
+		dev_err(&pdev->dev, "no codec-sync GPIO

supplied:
%d\n", ret);

sound/soc/tegra/tegra20_ac97.c static int tegra20_ac97_platform_probe(struct platform_device *pdev) · line 370

Quoted 3 lines
sound/soc/tegra/tegra20_ac97.c +0 -0
 		goto err_clk_put;
 
 	}

This isn't reporting an error code associated with the attempt to
find a
codec-sync GPIO, it's the result of some other operation.

Quoted 7 lines
Quoted 3 lines

What exactly is then the of_get_named_gpio() above please doing if
not getting the codec sync GPIO? I am not following you, sorry.

It's not in any way involved in setting the value of ret, whatever value
that has it's nothing to do with that operation.

Quoted 7 lines

The comment to gpio_is_valid() says that it "Returns GPIO number to use with
Linux generic GPIO API, or one of the errno value on the error condition".
Comment doesn't explicitly states that the returned GPIO number is always
valid, but it is kinda implied.

Do you mean I should be assigning the return value of gpio_is_valid() to ret and use that instead?

#9 lore raw

Re: [PATCH 2/2] ASoC: tegra: probe deferral error reporting

Quoted 63 lines · On Saturday, 21 July 2018 14:55:21 MSK Marcel Ziswiler wrote:
Quoted 52 lines · Dmitry Osipenko
Quoted 40 lines · On Saturday, 21 July 2018 12:56:15 MSK Mark Brown wrote:
Quoted 38 lines · Marcel Ziswiler
Quoted 34 lines · Mark Brown
Quoted 24 lines

ac97->sync_gpio = of_get_named_gpio(pdev-

Quoted 3 lines

dev.of_node,

"nvidia,codec-

sync-

gpio", 0);

sound/soc/tegra/tegra20_ac97.c +0 -1
 	if (!gpio_is_valid(ac97->sync_gpio)) {
 
 
-		dev_err(&pdev->dev, "no codec-sync GPIO

supplied\n");

(quoted diff) +2 -0
+		ret = ac97->sync_gpio;
+		dev_err(&pdev->dev, "no codec-sync GPIO

supplied:
%d\n", ret);

sound/soc/tegra/tegra20_ac97.c static int tegra20_ac97_platform_probe(struct platform_device *pdev)

Quoted 4 lines
sound/soc/tegra/tegra20_ac97.c +0 -0
 		goto err_clk_put;
 
 
 	}

This isn't reporting an error code associated with the attempt to
find a
codec-sync GPIO, it's the result of some other operation.

Quoted 8 lines
Quoted 3 lines

What exactly is then the of_get_named_gpio() above please doing if
not getting the codec sync GPIO? I am not following you, sorry.

It's not in any way involved in setting the value of ret, whatever value
that has it's nothing to do with that operation.

Quoted 7 lines

The comment to gpio_is_valid() says that it "Returns GPIO number to use with
Linux generic GPIO API, or one of the errno value on the error condition".
Comment doesn't explicitly states that the returned GPIO number is always
valid, but it is kinda implied.

Quoted 2 lines

Do you mean I should be assigning the return value of gpio_is_valid() to ret and use that instead?

No, gpio_is_valid() returns a boolean. I think your patch is fine as it is is.

Probably Mark meant something like this:

        ac97->sync_gpio = of_get_named_gpio(pdev->dev.of_node,
                                            "nvidia,codec-sync-gpio", 0);
        if (ac97->sync_gpio < 0) {
                ret = ac97->sync_gpio;
                dev_err(&pdev->dev, "no codec-sync GPIO supplied: %d\n", ret);
                goto err_clk_put;
        }

        if (!gpio_is_valid(ac97->sync_gpio)) {
                ret = -EINVAL;
                goto err_clk_put;
       }

But that is not needed because of_get_named_gpio() returns either a valid GPIO number or a error code.

#10 lore raw

Re: [PATCH 2/2] ASoC: tegra: probe deferral error reporting

Quoted 70 lines · On Saturday, 21 July 2018 15:03:57 MSK Dmitry Osipenko wrote:
Quoted 48 lines · On Saturday, 21 July 2018 14:55:21 MSK Marcel Ziswiler wrote:
Quoted 39 lines · Dmitry Osipenko
Quoted 30 lines · On Saturday, 21 July 2018 12:56:15 MSK Mark Brown wrote:
Quoted 29 lines · Marcel Ziswiler
Quoted 27 lines · Mark Brown
Quoted 19 lines

ac97->sync_gpio = of_get_named_gpio(pdev-

Quoted 3 lines

dev.of_node,

"nvidia,codec-

sync-

gpio", 0);

(quoted diff) +0 -1
 	if (!gpio_is_valid(ac97->sync_gpio)) {
 
-		dev_err(&pdev->dev, "no codec-sync GPIO

supplied\n");

(quoted diff) +2 -0
+		ret = ac97->sync_gpio;
+		dev_err(&pdev->dev, "no codec-sync GPIO

supplied:
%d\n", ret);

Review

Quoted 3 lines
(quoted diff) +0 -0
 		goto err_clk_put;
 
 	}

This isn't reporting an error code associated with the attempt to
find a
codec-sync GPIO, it's the result of some other operation.

Quoted 7 lines
Quoted 3 lines

What exactly is then the of_get_named_gpio() above please doing if
not getting the codec sync GPIO? I am not following you, sorry.

It's not in any way involved in setting the value of ret, whatever value
that has it's nothing to do with that operation.

Quoted 7 lines

The comment to gpio_is_valid() says that it "Returns GPIO number to use with
Linux generic GPIO API, or one of the errno value on the error condition".
Comment doesn't explicitly states that the returned GPIO number is always
valid, but it is kinda implied.

Quoted 2 lines

Do you mean I should be assigning the return value of gpio_is_valid() to ret and use that instead?

No, gpio_is_valid() returns a boolean. I think your patch is fine as it is is.

Probably Mark meant something like this:

        ac97->sync_gpio = of_get_named_gpio(pdev->dev.of_node,
                                            "nvidia,codec-sync-gpio", 0);
        if (ac97->sync_gpio < 0) {
                ret = ac97->sync_gpio;
                dev_err(&pdev->dev, "no codec-sync GPIO supplied: %d\n",
ret); goto err_clk_put;
        }

        if (!gpio_is_valid(ac97->sync_gpio)) {
                ret = -EINVAL;
                goto err_clk_put;
       }
Quoted 2 lines

But that is not needed because of_get_named_gpio() returns either a valid GPIO number or a error code.

Also note that tegra20_ac97 code doesn't check the returned value of:

	gpio_request(workdata->sync_gpio, "codec-sync");

That is a bit fragile. Probably would be better to move the GPIO requesting to the drivers probe function using the devm_gpio_request_one() and fail the driver probing if requesting fails. That should be a distinct patch if you'll want to implement that.

maintainer
#6 lore raw

Re: [PATCH 2/2] ASoC: tegra: probe deferral error reporting

In reply to Marcel Ziswiler
Quoted 9 lines · Marcel Ziswiler
Quoted 3 lines · Mark Brown
Quoted 3 lines
Quoted 3 lines

sound/soc/tegra/tegra20_ac97.c static int tegra20_ac97_platform_probe(struct platform_device *pdev) · line 367

Quoted 3 lines
(quoted diff) +0 -1
-		dev_err(&pdev->dev, "no codec-sync GPIO

supplied\n");

sound/soc/tegra/tegra20_ac97.c +1 -0
+		ret = ac97->sync_gpio;

And here I assign ret with that return value from of_get_named_gpio(), right?

Quoted 5 lines
Quoted 3 lines

It's not in any way involved in setting the value of ret, whatever value
that has it's nothing to do with that operation.

I really do not understand what you are trying to get at, sorry.

Didn't see the above assignment you'd added, sorry.

#11 lore raw

Re: [PATCH 2/2] ASoC: tegra: probe deferral error reporting

In reply to Marcel Ziswiler
Quoted 31 lines · Marcel Ziswiler

From: Marcel Ziswiler <[email protected]>

Actually report the error codes from of_get_named_gpio() resp. devm_gpio_request_one() upon trying to get the codec reset resp. sync GPIOs which may as well just be a probe deferrals.

---

 sound/soc/tegra/tegra20_ac97.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
sound/soc/tegra/tegra20_ac97.c +4 -2
index 682ef33afb5f..4875512f0732 100644
@@ -351,18 +351,21 @@ static int tegra20_ac97_platform_probe(struct
 platform_device *pdev)
 		ret = devm_gpio_request_one(&pdev->dev, ac97->reset_gpio,
 					    GPIOF_OUT_INIT_HIGH, "codec-reset");
 		if (ret) {
-			dev_err(&pdev->dev, "could not get codec-reset GPIO\n");
+			dev_err(&pdev->dev, "could not get codec-reset GPIO: "
+					    "%d\n", ret);
 			goto err_clk_put;
 		}
 	} else {
-		dev_err(&pdev->dev, "no codec-reset GPIO supplied\n");
+		ret = ac97->reset_gpio;
+		dev_err(&pdev->dev, "no codec-reset GPIO supplied: %d\n", ret);

sound/soc/tegra/tegra20_ac97.c static int tegra20_ac97_platform_probe(struct · line 370

Quoted 10 lines
sound/soc/tegra/tegra20_ac97.c +2 -1
 		goto err_clk_put;
 	}
 
 	ac97->sync_gpio = of_get_named_gpio(pdev->dev.of_node,
 					    "nvidia,codec-sync-gpio", 0);
 	if (!gpio_is_valid(ac97->sync_gpio)) {
-		dev_err(&pdev->dev, "no codec-sync GPIO supplied\n");
+		ret = ac97->sync_gpio;
+		dev_err(&pdev->dev, "no codec-sync GPIO supplied: %d\n", ret);
 		goto err_clk_put;

This will still print an error on defer, which is not really nice. I suggest to suppress defer errors completely, e.g. by:

		if (ret != -EPROBE_DEFER)
			dev_err(&pdev->dev, "no codec-sync GPIO supplied: %d\n", ret);

The driver framework provides debug level prints if debugging of deferred probing is required.

--
Stefan

Quoted 1 line
sound/soc/tegra/tegra20_ac97.c +0 -0
 	}