Commit 17c6d397 authored by Guenter Roeck's avatar Guenter Roeck Committed by Sebastian Reichel

sbs-battery: make writes to ManufacturerAccess optional

According to the Smart Battery Data Specification, the use
of ManufacturerAcess (register 0x0) is implementation-defined.
It appears that some batteries use writes to this register
in order to implement certain functionality, but others may
simply NAK all writes to it. As a result, write failures to
ManufacturerAccess should not be used as an indicator of
battery presence, nor as a failure to enter sleep mode.

The failed write access was seen with SANYO AP13J3K.

Cc: Brian Norris <briannorris@chromium.org>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 06107359
...@@ -317,21 +317,22 @@ static int sbs_get_battery_presence_and_health( ...@@ -317,21 +317,22 @@ static int sbs_get_battery_presence_and_health(
return ret; return ret;
} }
/* Write to ManufacturerAccess with /*
* ManufacturerAccess command and then * Write to ManufacturerAccess with ManufacturerAccess command
* read the status */ * and then read the status. Do not check for error on the write
ret = sbs_write_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr, * since not all batteries implement write access to this command,
MANUFACTURER_ACCESS_STATUS); * while others mandate it.
*/
sbs_write_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr,
MANUFACTURER_ACCESS_STATUS);
ret = sbs_read_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr);
if (ret < 0) { if (ret < 0) {
if (psp == POWER_SUPPLY_PROP_PRESENT) if (psp == POWER_SUPPLY_PROP_PRESENT)
val->intval = 0; /* battery removed */ val->intval = 0; /* battery removed */
return ret; return ret;
} }
ret = sbs_read_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr);
if (ret < 0)
return ret;
if (ret < sbs_data[REG_MANUFACTURER_DATA].min_value || if (ret < sbs_data[REG_MANUFACTURER_DATA].min_value ||
ret > sbs_data[REG_MANUFACTURER_DATA].max_value) { ret > sbs_data[REG_MANUFACTURER_DATA].max_value) {
val->intval = 0; val->intval = 0;
...@@ -882,16 +883,16 @@ static int sbs_suspend(struct device *dev) ...@@ -882,16 +883,16 @@ static int sbs_suspend(struct device *dev)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct sbs_info *chip = i2c_get_clientdata(client); struct sbs_info *chip = i2c_get_clientdata(client);
s32 ret;
if (chip->poll_time > 0) if (chip->poll_time > 0)
cancel_delayed_work_sync(&chip->work); cancel_delayed_work_sync(&chip->work);
/* write to manufacturer access with sleep command */ /*
ret = sbs_write_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr, * Write to manufacturer access with sleep command.
* Support is manufacturer dependend, so ignore errors.
*/
sbs_write_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr,
MANUFACTURER_ACCESS_SLEEP); MANUFACTURER_ACCESS_SLEEP);
if (chip->is_present && ret < 0)
return ret;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment