linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurentiu Palcu <laurentiu.palcu@intel.com>
To: Sebastian Reichel <sre@kernel.org>,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	Laurentiu Palcu <laurentiu.palcu@intel.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] power_supply: bq25890: make chip_id int
Date: Tue,  2 Jun 2015 13:36:51 +0300	[thread overview]
Message-ID: <1433241411-27423-1-git-send-email-laurentiu.palcu@intel.com> (raw)

Smatch static checker correctly detected an impossible condition because
chip_id was declared as u8, instead of int:

drivers/power/bq25890_charger.c:843 bq25890_probe()
warn: impossible condition '(bq->chip_id < 0) => (0-255 < 0)'

Also, while at it, fix the return value too.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/power/bq25890_charger.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/bq25890_charger.c b/drivers/power/bq25890_charger.c
index c7b4903..16b7c7bc 100644
--- a/drivers/power/bq25890_charger.c
+++ b/drivers/power/bq25890_charger.c
@@ -99,7 +99,7 @@ struct bq25890_device {
 	struct regmap *rmap;
 	struct regmap_field *rmap_fields[F_MAX_FIELDS];
 
-	u8 chip_id;
+	int chip_id;
 	struct bq25890_init_data init_data;
 	struct bq25890_state state;
 
@@ -842,7 +842,7 @@ static int bq25890_probe(struct i2c_client *client,
 	bq->chip_id = bq25890_field_read(bq, F_PN);
 	if (bq->chip_id < 0) {
 		dev_err(dev, "Cannot read chip ID.\n");
-		return ret;
+		return bq->chip_id;
 	}
 
 	if (bq->chip_id != BQ25890_ID) {
-- 
1.9.1


             reply	other threads:[~2015-06-02 10:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 10:36 Laurentiu Palcu [this message]
2015-06-02 13:12 ` [PATCH] power_supply: bq25890: make chip_id int Krzysztof Kozlowski
2015-06-02 19:28 ` Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433241411-27423-1-git-send-email-laurentiu.palcu@intel.com \
    --to=laurentiu.palcu@intel.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dbaryshkov@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=k.kozlowski@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).