linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soc: qcom: aoss: avoid registering cooling for NULL cdev
@ 2025-12-12  2:36 Haris Wu
  2025-12-12 19:19 ` Dmitry Baryshkov
  0 siblings, 1 reply; 2+ messages in thread
From: Haris Wu @ 2025-12-12  2:36 UTC (permalink / raw)
  To: andersson, konradybcio; +Cc: linux-arm-msm, Haris Wu

When PTR_ERR_OR_ZERO points to NULL, it returns 0. In this case, if
(ret) does not meet expectations. Now, qmp_cooling_device_add returns
NODEV for both failure and NULL, and returns 0 for success.

Signed-off-by: Haris Wu <bymark256@gmail.com>
---
 drivers/soc/qcom/qcom_aoss.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c
index a543ab9be..ac411343d 100644
--- a/drivers/soc/qcom/qcom_aoss.c
+++ b/drivers/soc/qcom/qcom_aoss.c
@@ -386,11 +386,13 @@ static int qmp_cooling_device_add(struct qmp *qmp,
 				cdev_name,
 				qmp_cdev, &qmp_cooling_device_ops);
 
-	if (IS_ERR(qmp_cdev->cdev))
+	if (IS_ERR_OR_NULL(qmp_cdev->cdev)) {
 		dev_err(qmp->dev, "unable to register %s cooling device\n",
 			cdev_name);
+		return -ENODEV;
+	}
 
-	return PTR_ERR_OR_ZERO(qmp_cdev->cdev);
+	return 0;
 }
 
 static int qmp_cooling_devices_register(struct qmp *qmp)
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] soc: qcom: aoss: avoid registering cooling for NULL cdev
  2025-12-12  2:36 [PATCH] soc: qcom: aoss: avoid registering cooling for NULL cdev Haris Wu
@ 2025-12-12 19:19 ` Dmitry Baryshkov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Baryshkov @ 2025-12-12 19:19 UTC (permalink / raw)
  To: Haris Wu; +Cc: andersson, konradybcio, linux-arm-msm

On Fri, Dec 12, 2025 at 10:36:10AM +0800, Haris Wu wrote:
> When PTR_ERR_OR_ZERO points to NULL, it returns 0. In this case, if
> (ret) does not meet expectations. Now, qmp_cooling_device_add returns
> NODEV for both failure and NULL, and returns 0 for success.
> 
> Signed-off-by: Haris Wu <bymark256@gmail.com>
> ---
>  drivers/soc/qcom/qcom_aoss.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

NAK, devm_thermal_of_cooling_device_register() can't return NULL. It
returns either a valid device pointer or an error pointer.

> 
> diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c
> index a543ab9be..ac411343d 100644
> --- a/drivers/soc/qcom/qcom_aoss.c
> +++ b/drivers/soc/qcom/qcom_aoss.c
> @@ -386,11 +386,13 @@ static int qmp_cooling_device_add(struct qmp *qmp,
>  				cdev_name,
>  				qmp_cdev, &qmp_cooling_device_ops);
>  
> -	if (IS_ERR(qmp_cdev->cdev))
> +	if (IS_ERR_OR_NULL(qmp_cdev->cdev)) {
>  		dev_err(qmp->dev, "unable to register %s cooling device\n",
>  			cdev_name);
> +		return -ENODEV;
> +	}
>  
> -	return PTR_ERR_OR_ZERO(qmp_cdev->cdev);
> +	return 0;
>  }
>  
>  static int qmp_cooling_devices_register(struct qmp *qmp)
> -- 
> 2.47.3
> 

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-12 19:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-12  2:36 [PATCH] soc: qcom: aoss: avoid registering cooling for NULL cdev Haris Wu
2025-12-12 19:19 ` Dmitry Baryshkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).