diff mbox series

pwm: stm32: Add error messages in .probe()'s error paths

Message ID 20240315145443.982807-2-u.kleine-koenig@pengutronix.de
State Accepted
Headers show
Series pwm: stm32: Add error messages in .probe()'s error paths | expand

Commit Message

Uwe Kleine-König March 15, 2024, 2:54 p.m. UTC
Giving an indication about the problem if probing a device fails is a
nice move. Do that for the stm32 pwm driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-stm32.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)


base-commit: dd6c6d57ab61d496f6ff7d6ca38611062af142a1

Comments

Fabrice Gasnier March 15, 2024, 4:39 p.m. UTC | #1
On 3/15/24 15:54, Uwe Kleine-König wrote:
> Giving an indication about the problem if probing a device fails is a
> nice move. Do that for the stm32 pwm driver.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Hi Uwe,

Thanks for your patch, you can add my:
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>

Best Regards,
Fabrice

> ---
>  drivers/pwm/pwm-stm32.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
> index 0c028d17c075..ffe572b76174 100644
> --- a/drivers/pwm/pwm-stm32.c
> +++ b/drivers/pwm/pwm-stm32.c
> @@ -648,11 +648,13 @@ static int stm32_pwm_probe(struct platform_device *pdev)
>  	priv->max_arr = ddata->max_arr;
>  
>  	if (!priv->regmap || !priv->clk)
> -		return -EINVAL;
> +		return dev_err_probe(dev, -EINVAL, "Failed to get %s\n",
> +				     priv->regmap ? "clk" : "regmap");
>  
>  	ret = stm32_pwm_probe_breakinputs(priv, np);
>  	if (ret)
> -		return ret;
> +		return dev_err_probe(dev, ret,
> +				     "Failed to configure breakinputs\n");
>  
>  	stm32_pwm_detect_complementary(priv);
>  
> @@ -664,7 +666,8 @@ static int stm32_pwm_probe(struct platform_device *pdev)
>  
>  	ret = devm_pwmchip_add(dev, chip);
>  	if (ret < 0)
> -		return ret;
> +		return dev_err_probe(dev, ret,
> +				     "Failed to register pwmchip\n");
>  
>  	platform_set_drvdata(pdev, chip);
>  
> 
> base-commit: dd6c6d57ab61d496f6ff7d6ca38611062af142a1
Uwe Kleine-König April 13, 2024, 8:26 a.m. UTC | #2
On Fri, Mar 15, 2024 at 05:39:34PM +0100, Fabrice Gasnier wrote:
> On 3/15/24 15:54, Uwe Kleine-König wrote:
> > Giving an indication about the problem if probing a device fails is a
> > nice move. Do that for the stm32 pwm driver.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> Hi Uwe,
> 
> Thanks for your patch, you can add my:
> Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>

Thanks, I applied it to
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next
with your review tag.

Best regards
Uwe
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
index 0c028d17c075..ffe572b76174 100644
--- a/drivers/pwm/pwm-stm32.c
+++ b/drivers/pwm/pwm-stm32.c
@@ -648,11 +648,13 @@  static int stm32_pwm_probe(struct platform_device *pdev)
 	priv->max_arr = ddata->max_arr;
 
 	if (!priv->regmap || !priv->clk)
-		return -EINVAL;
+		return dev_err_probe(dev, -EINVAL, "Failed to get %s\n",
+				     priv->regmap ? "clk" : "regmap");
 
 	ret = stm32_pwm_probe_breakinputs(priv, np);
 	if (ret)
-		return ret;
+		return dev_err_probe(dev, ret,
+				     "Failed to configure breakinputs\n");
 
 	stm32_pwm_detect_complementary(priv);
 
@@ -664,7 +666,8 @@  static int stm32_pwm_probe(struct platform_device *pdev)
 
 	ret = devm_pwmchip_add(dev, chip);
 	if (ret < 0)
-		return ret;
+		return dev_err_probe(dev, ret,
+				     "Failed to register pwmchip\n");
 
 	platform_set_drvdata(pdev, chip);