Message ID | 20180720080424.31505-2-marcel@ziswiler.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Jul 20, 2018 at 10:04:24AM +0200, Marcel Ziswiler wrote: > - 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. > 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.
On Fri, 2018-07-20 at 13:16 +0100, Mark Brown wrote: > On Fri, Jul 20, 2018 at 10:04:24AM +0200, Marcel Ziswiler wrote: > > > - 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. OK, will do. However, in this case I did not actually split anything searchable anyway. > > 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. 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.
On Fri, Jul 20, 2018 at 12:31:07PM +0000, Marcel Ziswiler wrote: > On Fri, 2018-07-20 at 13:16 +0100, Mark Brown wrote: > > > 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. > 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.
On Sat, 2018-07-21 at 10:56 +0100, Mark Brown wrote: > On Fri, Jul 20, 2018 at 12:31:07PM +0000, Marcel Ziswiler wrote: > > On Fri, 2018-07-20 at 13:16 +0100, Mark Brown wrote: > > > > 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? > > > > 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? > > > > - dev_err(&pdev->dev, "no codec-sync GPIO > > > > supplied\n"); > > > > + ret = ac97->sync_gpio; And here I assign ret with that return value from of_get_named_gpio(), right? > > > > + 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). > > > > 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.
On Saturday, 21 July 2018 12:56:15 MSK Mark Brown wrote: > On Fri, Jul 20, 2018 at 12:31:07PM +0000, Marcel Ziswiler wrote: > > On Fri, 2018-07-20 at 13:16 +0100, Mark Brown wrote: > > > > 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. > > > > 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.
On Sat, 2018-07-21 at 14:17 +0300, Dmitry Osipenko wrote: > On Saturday, 21 July 2018 12:56:15 MSK Mark Brown wrote: > > On Fri, Jul 20, 2018 at 12:31:07PM +0000, Marcel Ziswiler wrote: > > > On Fri, 2018-07-20 at 13:16 +0100, Mark Brown wrote: > > > > > 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. > > > > > > 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. Do you mean I should be assigning the return value of gpio_is_valid() to ret and use that instead?
On Saturday, 21 July 2018 14:55:21 MSK Marcel Ziswiler wrote: > On Sat, 2018-07-21 at 14:17 +0300, Dmitry Osipenko wrote: > > > On Saturday, 21 July 2018 12:56:15 MSK Mark Brown wrote: > > > > > On Fri, Jul 20, 2018 at 12:31:07PM +0000, Marcel Ziswiler wrote: > > > > > > > On Fri, 2018-07-20 at 13:16 +0100, Mark Brown wrote: > > > > > > > > > > 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. > > > > > > > > > > > > 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. > > > 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.
On Saturday, 21 July 2018 15:03:57 MSK Dmitry Osipenko wrote: > On Saturday, 21 July 2018 14:55:21 MSK Marcel Ziswiler wrote: > > On Sat, 2018-07-21 at 14:17 +0300, Dmitry Osipenko wrote: > > > On Saturday, 21 July 2018 12:56:15 MSK Mark Brown wrote: > > > > On Fri, Jul 20, 2018 at 12:31:07PM +0000, Marcel Ziswiler wrote: > > > > > On Fri, 2018-07-20 at 13:16 +0100, Mark Brown wrote: > > > > > > > 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. > > > > > > > > > > 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. > > > > 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. 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.
On Sat, Jul 21, 2018 at 10:06:23AM +0000, Marcel Ziswiler wrote: > On Sat, 2018-07-21 at 10:56 +0100, Mark Brown wrote: > > > > > - dev_err(&pdev->dev, "no codec-sync GPIO > > > > > supplied\n"); > > > > > + ret = ac97->sync_gpio; > And here I assign ret with that return value from of_get_named_gpio(), > right? > > 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.
On 20.07.2018 10:04, Marcel Ziswiler wrote: > From: Marcel Ziswiler <marcel.ziswiler@toradex.com> > > 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. > > Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> > > --- > > sound/soc/tegra/tegra20_ac97.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/sound/soc/tegra/tegra20_ac97.c b/sound/soc/tegra/tegra20_ac97.c > index 682ef33afb5f..4875512f0732 100644 > --- a/sound/soc/tegra/tegra20_ac97.c > +++ b/sound/soc/tegra/tegra20_ac97.c > @@ -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; 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 > }
diff --git a/sound/soc/tegra/tegra20_ac97.c b/sound/soc/tegra/tegra20_ac97.c index 682ef33afb5f..4875512f0732 100644 --- a/sound/soc/tegra/tegra20_ac97.c +++ b/sound/soc/tegra/tegra20_ac97.c @@ -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; }