linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
To: sre@kernel.org, linux-pm@vger.kernel.org
Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Subject: [PATCH 5/7] power: supply: sbs-battery: fix CAPACITY_MODE bit naming
Date: Fri,  1 Nov 2019 15:07:03 -0400	[thread overview]
Message-ID: <20191101190705.13393-5-jeff.dagenais@gmail.com> (raw)
In-Reply-To: <20191101190705.13393-1-jeff.dagenais@gmail.com>

"Battery mode" is the name of the register, the bit manipulated by this
code is "CAPACITY_MODE" (Smart Battery System Specifications).

Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
---
 drivers/power/supply/sbs-battery.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index f92b98d900d2..46c89dd05f46 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -46,10 +46,10 @@ enum {
 
 /* Battery Mode defines */
 #define BATTERY_MODE_OFFSET		0x03
-#define BATTERY_MODE_MASK		0x8000
-enum sbs_battery_mode {
-	BATTERY_MODE_AMPS = 0,
-	BATTERY_MODE_WATTS = 0x8000
+#define BATTERY_MODE_CAPACITY_MASK	(1<<15)
+enum sbs_capacity_mode {
+	CAPACITY_MODE_AMPS = 0,
+	CAPACITY_MODE_WATTS = BATTERY_MODE_CAPACITY_MASK
 };
 
 /* manufacturer access defines */
@@ -513,8 +513,8 @@ static void  sbs_unit_adjustment(struct i2c_client *client,
 	}
 }
 
-static enum sbs_battery_mode sbs_set_battery_mode(struct i2c_client *client,
-	enum sbs_battery_mode mode)
+static enum sbs_capacity_mode sbs_set_capacity_mode(struct i2c_client *client,
+	enum sbs_capacity_mode mode)
 {
 	int ret, original_val;
 
@@ -522,13 +522,13 @@ static enum sbs_battery_mode sbs_set_battery_mode(struct i2c_client *client,
 	if (original_val < 0)
 		return original_val;
 
-	if ((original_val & BATTERY_MODE_MASK) == mode)
+	if ((original_val & BATTERY_MODE_CAPACITY_MASK) == mode)
 		return mode;
 
-	if (mode == BATTERY_MODE_AMPS)
-		ret = original_val & ~BATTERY_MODE_MASK;
+	if (mode == CAPACITY_MODE_AMPS)
+		ret = original_val & ~BATTERY_MODE_CAPACITY_MASK;
 	else
-		ret = original_val | BATTERY_MODE_MASK;
+		ret = original_val | BATTERY_MODE_CAPACITY_MASK;
 
 	ret = sbs_write_word_data(client, BATTERY_MODE_OFFSET, ret);
 	if (ret < 0)
@@ -536,7 +536,7 @@ static enum sbs_battery_mode sbs_set_battery_mode(struct i2c_client *client,
 
 	usleep_range(1000, 2000);
 
-	return original_val & BATTERY_MODE_MASK;
+	return original_val & BATTERY_MODE_CAPACITY_MASK;
 }
 
 static int sbs_get_battery_capacity(struct i2c_client *client,
@@ -544,12 +544,12 @@ static int sbs_get_battery_capacity(struct i2c_client *client,
 	union power_supply_propval *val)
 {
 	s32 ret;
-	enum sbs_battery_mode mode = BATTERY_MODE_WATTS;
+	enum sbs_capacity_mode mode = CAPACITY_MODE_WATTS;
 
 	if (power_supply_is_amp_property(psp))
-		mode = BATTERY_MODE_AMPS;
+		mode = CAPACITY_MODE_AMPS;
 
-	mode = sbs_set_battery_mode(client, mode);
+	mode = sbs_set_capacity_mode(client, mode);
 	if (mode < 0)
 		return mode;
 
@@ -559,7 +559,7 @@ static int sbs_get_battery_capacity(struct i2c_client *client,
 
 	val->intval = ret;
 
-	ret = sbs_set_battery_mode(client, mode);
+	ret = sbs_set_capacity_mode(client, mode);
 	if (ret < 0)
 		return ret;
 
-- 
2.23.0


  parent reply	other threads:[~2019-11-01 19:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01 19:06 [PATCH 1/7] power: supply: sbs-battery: use octal permissions on module param Jean-Francois Dagenais
2019-11-01 19:07 ` [PATCH 2/7] power: supply: sbs-battery: prefix module param variable Jean-Francois Dagenais
2019-11-01 19:07 ` [PATCH 3/7] power: supply: sbs-battery: add force_load as a dts property Jean-Francois Dagenais
2019-12-19  1:19   ` Sebastian Reichel
2019-11-01 19:07 ` [PATCH 4/7] devicetree: bindings: sbs-battery: add sbs,force-load property Jean-Francois Dagenais
2019-12-19  1:23   ` Sebastian Reichel
2019-11-01 19:07 ` Jean-Francois Dagenais [this message]
2019-12-19  1:22   ` [PATCH 5/7] power: supply: sbs-battery: fix CAPACITY_MODE bit naming Sebastian Reichel
2019-11-01 19:07 ` [PATCH 6/7] power: supply: sbs-battery: add ability to disable charger broadcasts Jean-Francois Dagenais
2019-11-01 19:07 ` [PATCH 7/7] dt-bindings: power: sbs-battery: add disable-charger-broadcasts doc Jean-Francois Dagenais
2019-12-19  1:22   ` Sebastian Reichel
2019-12-19  1:13 ` [PATCH 1/7] power: supply: sbs-battery: use octal permissions on module param 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=20191101190705.13393-5-jeff.dagenais@gmail.com \
    --to=jeff.dagenais@gmail.com \
    --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).