Re: [PATCH v6 067/164] pwm: lpss-*: Make use of devm_pwmchip_alloc() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

On Wed, Feb 14, 2024 at 10:31:54AM +0100, Uwe Kleine-König wrote:
> @@ -256,9 +257,10 @@ struct pwm_lpss_chip *devm_pwm_lpss_probe(struct device *dev, void __iomem *base
>  	if (WARN_ON(info->npwm > LPSS_MAX_PWMS))
>  		return ERR_PTR(-ENODEV);
>  
> -	lpwm = devm_kzalloc(dev, sizeof(*lpwm), GFP_KERNEL);
> -	if (!lpwm)
> +	chip = devm_pwmchip_alloc(dev, info->npwm, sizeof(*lpwm));
> +	if (!chip)
>  		return ERR_PTR(-ENOMEM);

while adapting the patch for Andy's feedback I noticed this being wrong,
devm_pwmchip_alloc() returns an error pointer and not NULL on failure.
I'll squash the following change into the commit:

diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c
index 3247b420b67a..867e2bc8c601 100644
--- a/drivers/pwm/pwm-lpss.c
+++ b/drivers/pwm/pwm-lpss.c
@@ -258,8 +258,8 @@ struct pwm_chip *devm_pwm_lpss_probe(struct device *dev, void __iomem *base,
 		return ERR_PTR(-ENODEV);
 
 	chip = devm_pwmchip_alloc(dev, info->npwm, sizeof(*lpwm));
-	if (!chip)
-		return ERR_PTR(-ENOMEM);
+	if (IS_ERR(chip))
+		return chip;
 	lpwm = to_lpwm(chip);
 
 	lpwm->regs = base;

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux