public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Amit Sunil Dhamne <amitsd@google.com>
Cc: linux-pm@vger.kernel.org
Subject: [bug report] power: supply: max77759: add charger driver
Date: Fri, 10 Apr 2026 13:14:25 +0300	[thread overview]
Message-ID: <adjNgZAaULzTBtJO@stanley.mountain> (raw)

Hello Amit Sunil Dhamne,

Commit 70d7dd27f6dc ("power: supply: max77759: add charger driver")
from Mar 25, 2026 (linux-next), leads to the following Smatch static
checker warning:

	drivers/power/supply/max77759_charger.c:117 get_online()
	info: return a literal instead of 'ret'

drivers/power/supply/max77759_charger.c
    97  static int charger_input_valid(struct max77759_charger *chg)
    98  {
    99          u32 val;
   100          int ret;
   101  
   102          ret = regmap_read(chg->regmap, MAX77759_CHGR_REG_CHG_INT_OK, &val);
   103          if (ret)
   104                  return ret;
   105  
   106          return (val & MAX77759_CHGR_REG_CHG_INT_CHG) &&
   107                  (val & MAX77759_CHGR_REG_CHG_INT_CHGIN);
   108  }
   109  
   110  static int get_online(struct max77759_charger *chg)
   111  {
   112          u32 val;
   113          int ret;
   114  
   115          ret = charger_input_valid(chg);
   116          if (ret <= 0)
   117                  return ret;

This needs some comments.  From the naming, we would assume
charger_input_valid() returns true for valid and false for invalid.

Based on reading the code get_online() return true/false as well
but what does it mean?  false means offline and true means online?
In which sense is this a get_ function?  I'm so confused.

   118  
   119          ret = regmap_read(chg->regmap, MAX77759_CHGR_REG_CHG_DETAILS_02, &val);
   120          if (ret)
   121                  return ret;
   122  
   123          guard(mutex)(&chg->lock);
   124  
   125          return (val & MAX77759_CHGR_REG_CHG_DETAILS_02_CHGIN_STS) &&
   126                  (chg->mode == MAX77759_CHGR_MODE_CHG_BUCK_ON);
   127  }

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter

                 reply	other threads:[~2026-04-10 10:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=adjNgZAaULzTBtJO@stanley.mountain \
    --to=error27@gmail.com \
    --cc=amitsd@google.com \
    --cc=linux-pm@vger.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