diff mbox series

[2/5] power: avs: qcom-cpr: fix unsigned expression compared with zero

Message ID 20191223141934.19837-3-nks@flawful.org (mailing list archive)
State Accepted
Commit cad12cdeea783e8b7fc4425848028d3606a4cba8
Headers show
Series qcom-cpr fixes for rjw bleeding-edge | expand

Commit Message

Niklas Cassel Dec. 23, 2019, 2:19 p.m. UTC
drivers/power/avs/qcom-cpr.c:1539:5-21:
warning: unsigned expression compared with zero: drv->num_corners < 0

Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Niklas Cassel <nks@flawful.org>
---
 drivers/power/avs/qcom-cpr.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Bjorn Andersson Dec. 27, 2019, 6:47 a.m. UTC | #1
On Mon 23 Dec 06:19 PST 2019, Niklas Cassel wrote:

> drivers/power/avs/qcom-cpr.c:1539:5-21:
> warning: unsigned expression compared with zero: drv->num_corners < 0
> 

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Julia Lawall <julia.lawall@lip6.fr>
> Signed-off-by: Niklas Cassel <nks@flawful.org>
> ---
>  drivers/power/avs/qcom-cpr.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/power/avs/qcom-cpr.c b/drivers/power/avs/qcom-cpr.c
> index a52d2cef1300..232836a1ef27 100644
> --- a/drivers/power/avs/qcom-cpr.c
> +++ b/drivers/power/avs/qcom-cpr.c
> @@ -1535,11 +1535,13 @@ static int cpr_pd_attach_dev(struct generic_pm_domain *domain,
>  	 * The reason for this is that we need to know the highest
>  	 * frequency associated with each fuse corner.
>  	 */
> -	drv->num_corners = dev_pm_opp_get_opp_count(&drv->pd.dev);
> -	if (drv->num_corners < 0) {
> -		ret = drv->num_corners;
> +	ret = dev_pm_opp_get_opp_count(&drv->pd.dev);
> +	if (ret < 0) {
> +		dev_err(drv->dev, "could not get OPP count\n");
>  		goto unlock;
>  	}
> +	drv->num_corners = ret;
> +
>  	if (drv->num_corners < 2) {
>  		dev_err(drv->dev, "need at least 2 OPPs to use CPR\n");
>  		ret = -EINVAL;
> -- 
> 2.24.1
>
diff mbox series

Patch

diff --git a/drivers/power/avs/qcom-cpr.c b/drivers/power/avs/qcom-cpr.c
index a52d2cef1300..232836a1ef27 100644
--- a/drivers/power/avs/qcom-cpr.c
+++ b/drivers/power/avs/qcom-cpr.c
@@ -1535,11 +1535,13 @@  static int cpr_pd_attach_dev(struct generic_pm_domain *domain,
 	 * The reason for this is that we need to know the highest
 	 * frequency associated with each fuse corner.
 	 */
-	drv->num_corners = dev_pm_opp_get_opp_count(&drv->pd.dev);
-	if (drv->num_corners < 0) {
-		ret = drv->num_corners;
+	ret = dev_pm_opp_get_opp_count(&drv->pd.dev);
+	if (ret < 0) {
+		dev_err(drv->dev, "could not get OPP count\n");
 		goto unlock;
 	}
+	drv->num_corners = ret;
+
 	if (drv->num_corners < 2) {
 		dev_err(drv->dev, "need at least 2 OPPs to use CPR\n");
 		ret = -EINVAL;