mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 08:19:28 +00:00
power: supply: sbs-battery: fix CAPACITY_MODE bit naming
"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> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
parent
75d8a8423c
commit
e2ec6aef37
1 changed files with 16 additions and 15 deletions
|
@ -5,6 +5,7 @@
|
|||
* Copyright (c) 2010, NVIDIA Corporation.
|
||||
*/
|
||||
|
||||
#include <linux/bits.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
|
@ -46,10 +47,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 BIT(15)
|
||||
enum sbs_capacity_mode {
|
||||
CAPACITY_MODE_AMPS = 0,
|
||||
CAPACITY_MODE_WATTS = BATTERY_MODE_CAPACITY_MASK
|
||||
};
|
||||
|
||||
/* manufacturer access defines */
|
||||
|
@ -518,8 +519,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;
|
||||
|
||||
|
@ -527,13 +528,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)
|
||||
|
@ -541,7 +542,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,
|
||||
|
@ -549,12 +550,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;
|
||||
|
||||
|
@ -564,7 +565,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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue