Linux Tegra architecture development
 help / color / mirror / Atom feed
From: Mikko Perttunen <mperttunen@nvidia.com>
To: "Thierry Reding" <thierry.reding@kernel.org>,
	"Jonathan Hunter" <jonathanh@nvidia.com>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Uwe Kleine-König" <ukleinek@kernel.org>
Cc: linux-pwm@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH v1 2/6] pwm: tegra: Make use of dev_err_probe()
Date: Wed, 15 Jul 2026 13:17:41 +0900	[thread overview]
Message-ID: <pvR2hytaSrSgvheXwlJ_XQ@nvidia.com> (raw)
In-Reply-To: <0080b5bc2e7268740216bd911fd2c2358f219dc5.1784030076.git.ukleinek@kernel.org>

On Tuesday, July 14, 2026 9:02 PM Uwe Kleine-König wrote:
> Usage of dev_err_probe() is more compact than dev_err()'s, emits the
> error code and handles -ENOMEM and -EPROBE_DEFER properly. Benefit from
> these improvements.
> 
> Also add a few messages in error paths that lacked an output before.
> 
> Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
> ---
>  drivers/pwm/pwm-tegra.c | 44 ++++++++++++++++++++++++-----------------
>  1 file changed, 26 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
> index 53743f83869a..dba9a05675e3 100644
> --- a/drivers/pwm/pwm-tegra.c
> +++ b/drivers/pwm/pwm-tegra.c
> @@ -316,6 +316,7 @@ static const struct pwm_ops tegra_pwm_ops = {
>  
>  static int tegra_pwm_probe(struct platform_device *pdev)
>  {
> +	struct device *dev = &pdev->dev;
>  	struct pwm_chip *chip;
>  	struct tegra_pwm_chip *pc;
>  	const struct tegra_pwm_soc *soc;
> @@ -330,7 +331,7 @@ static int tegra_pwm_probe(struct platform_device *pdev)
>  		 */
>  		return dev_err_probe(dev, -ENODEV, "Unsupported device\n");
>  
> -	chip = devm_pwmchip_alloc(&pdev->dev, soc->num_channels, sizeof(*pc));
> +	chip = devm_pwmchip_alloc(dev, soc->num_channels, sizeof(*pc));
>  	if (IS_ERR(chip))
>  		return PTR_ERR(chip);
>  	pc = to_tegra_pwm_chip(chip);
> @@ -339,27 +340,36 @@ static int tegra_pwm_probe(struct platform_device *pdev)
>  
>  	pc->regs = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(pc->regs))
> +		/*
> +		 * devm_platform_ioremap_resource() already emits an error
> +		 * message with CONFIG_HAS_IOMEM, so don't emit another message
> +		 * here.
> +		 */
>  		return PTR_ERR(pc->regs);

Same as 1/6, my preference is for curlies with multiline blocks.

Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>

>  
>  	platform_set_drvdata(pdev, chip);
>  
> -	pc->clk = devm_clk_get(&pdev->dev, NULL);
> +	pc->clk = devm_clk_get(dev, NULL);
>  	if (IS_ERR(pc->clk))
> -		return PTR_ERR(pc->clk);
> +		return dev_err_probe(dev, PTR_ERR(pc->clk), "Failed to get clock\n");
>  
> -	ret = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
> +	ret = devm_tegra_core_dev_init_opp_table_common(dev);
>  	if (ret)
> +		/*
> +		 * devm_tegra_core_dev_init_opp_table_common() emits an error
> +		 * message most of the time, so don't add another.
> +		 */
>  		return ret;
>  
> -	pm_runtime_enable(&pdev->dev);
> -	ret = pm_runtime_resume_and_get(&pdev->dev);
> +	pm_runtime_enable(dev);
> +	ret = pm_runtime_resume_and_get(dev);
>  	if (ret)
> -		return ret;
> +		return dev_err_probe(dev, ret, "Failed to runtime resume device\n");
>  
>  	/* Set maximum frequency of the IP */
> -	ret = dev_pm_opp_set_rate(&pdev->dev, ULONG_MAX);
> +	ret = dev_pm_opp_set_rate(dev, ULONG_MAX);
>  	if (ret < 0) {
> -		dev_err(&pdev->dev, "Failed to set max frequency: %d\n", ret);
> +		dev_err_probe(dev, ret, "Failed to set max frequency\n");
>  		goto put_pm;
>  	}
>  
> @@ -370,8 +380,7 @@ static int tegra_pwm_probe(struct platform_device *pdev)
>  	 */
>  	pc->clk_rate = clk_get_rate(pc->clk);
>  	if (pc->clk_rate < TEGRA_PWM_DEPTH) {
> -		dev_err(&pdev->dev, "clock maximum frequency out of range\n");
> -		ret = -ERANGE;
> +		ret = dev_err_probe(dev, -ERANGE, "Clock maximum frequency out of range\n");
>  		goto put_pm;
>  	}
>  
> @@ -379,10 +388,9 @@ static int tegra_pwm_probe(struct platform_device *pdev)
>  	pc->min_period_ns =
>  	    (NSEC_PER_SEC / (pc->clk_rate / TEGRA_PWM_DEPTH)) + 1;
>  
> -	pc->rst = devm_reset_control_get_exclusive(&pdev->dev, "pwm");
> +	pc->rst = devm_reset_control_get_exclusive(dev, "pwm");
>  	if (IS_ERR(pc->rst)) {
> -		ret = PTR_ERR(pc->rst);
> -		dev_err(&pdev->dev, "Reset control is not found: %d\n", ret);
> +		ret = dev_err_probe(dev, PTR_ERR(pc->rst), "Failed to get reset control\n");
>  		goto put_pm;
>  	}
>  
> @@ -392,17 +400,17 @@ static int tegra_pwm_probe(struct platform_device *pdev)
>  
>  	ret = pwmchip_add(chip);
>  	if (ret < 0) {
> -		dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
> +		dev_err_probe(dev, ret, "Adding pwmchip failed\n");
>  		reset_control_assert(pc->rst);
>  		goto put_pm;
>  	}
>  
> -	pm_runtime_put(&pdev->dev);
> +	pm_runtime_put(dev);
>  
>  	return 0;
>  put_pm:
> -	pm_runtime_put_sync_suspend(&pdev->dev);
> -	pm_runtime_force_suspend(&pdev->dev);
> +	pm_runtime_put_sync_suspend(dev);
> +	pm_runtime_force_suspend(dev);
>  	return ret;
>  }
>  
> -- 
> 2.55.0.11.g153666a7d9bb
> 
> 





  reply	other threads:[~2026-07-15  4:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 12:02 [PATCH v1 0/6] pwm: tegra: Cleanups and .get_state() Uwe Kleine-König
2026-07-14 12:02 ` [PATCH v1 1/6] pwm: tegra: Check for match_data being NULL Uwe Kleine-König
2026-07-15  4:11   ` Mikko Perttunen
2026-07-15 14:20     ` Uwe Kleine-König
2026-07-14 12:02 ` [PATCH v1 2/6] pwm: tegra: Make use of dev_err_probe() Uwe Kleine-König
2026-07-15  4:17   ` Mikko Perttunen [this message]
2026-07-14 12:02 ` [PATCH v1 3/6] pwm: tegra: Use devm function for pm_runtime_enable() Uwe Kleine-König
2026-07-15  4:31   ` Mikko Perttunen
2026-07-14 12:02 ` [PATCH v1 4/6] pwm: tegra: Simplify using devm_reset_control_get_exclusive_deasserted() Uwe Kleine-König
2026-07-14 12:12   ` Philipp Zabel
2026-07-14 14:07     ` Uwe Kleine-König
2026-07-15  4:50       ` Mikko Perttunen
2026-07-14 12:02 ` [PATCH v1 5/6] pwm: tegra: Simplify using devm_pwmchip_add() Uwe Kleine-König
2026-07-14 12:02 ` [PATCH v1 6/6] pwm: tegra: Implement .get_state() Uwe Kleine-König
2026-07-15  5:09   ` Mikko Perttunen
2026-07-15 12:28   ` Ola Chr. Vaage

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pvR2hytaSrSgvheXwlJ_XQ@nvidia.com \
    --to=mperttunen@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=thierry.reding@kernel.org \
    --cc=ukleinek@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox