diff mbox

power: qcom_smbb: test the correct variable

Message ID 20150924184137.GA28804@mwanda (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Dan Carpenter Sept. 24, 2015, 6:41 p.m. UTC
"state" is a bool so it's never less than zero.  The intent was to test
"ret" instead.

Fixes: 56d7df8716b2 ('power: Add Qualcomm SMBB driver')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Courtney Cavin Sept. 24, 2015, 7:50 p.m. UTC | #1
On Thu, Sep 24, 2015 at 08:41:37PM +0200, Dan Carpenter wrote:
> "state" is a bool so it's never less than zero.  The intent was to test
> "ret" instead.
> 
> Fixes: 56d7df8716b2 ('power: Add Qualcomm SMBB driver')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/power/qcom_smbb.c b/drivers/power/qcom_smbb.c
> index 0dabfe8..5eb1e9e 100644
> --- a/drivers/power/qcom_smbb.c
> +++ b/drivers/power/qcom_smbb.c
> @@ -351,7 +351,7 @@ static void smbb_set_line_flag(struct smbb_charger *chg, int irq, int flag)
>  	int ret;
>  
>  	ret = irq_get_irqchip_state(irq, IRQCHIP_STATE_LINE_LEVEL, &state);
> -	if (state < 0) {
> +	if (ret < 0) {
>  		dev_err(chg->dev, "failed to read irq line\n");
>  		return;
>  	}

Hrm.  This must be a leftover from when this was using Bjorn's
irq_read_line().  Thanks!

I guess you caught this with smatch?  Neither sparse nor gcc give me a
warning here, which is disappointing.

-Courtney
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sebastian Reichel Sept. 24, 2015, 8:36 p.m. UTC | #2
Hi,

On Thu, Sep 24, 2015 at 09:41:37PM +0300, Dan Carpenter wrote:
> "state" is a bool so it's never less than zero.  The intent was to test
> "ret" instead.
> 
> Fixes: 56d7df8716b2 ('power: Add Qualcomm SMBB driver')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, queued.

-- Sebastian
diff mbox

Patch

diff --git a/drivers/power/qcom_smbb.c b/drivers/power/qcom_smbb.c
index 0dabfe8..5eb1e9e 100644
--- a/drivers/power/qcom_smbb.c
+++ b/drivers/power/qcom_smbb.c
@@ -351,7 +351,7 @@  static void smbb_set_line_flag(struct smbb_charger *chg, int irq, int flag)
 	int ret;
 
 	ret = irq_get_irqchip_state(irq, IRQCHIP_STATE_LINE_LEVEL, &state);
-	if (state < 0) {
+	if (ret < 0) {
 		dev_err(chg->dev, "failed to read irq line\n");
 		return;
 	}