aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Reid <preid@electromag.com.au>2017-08-24 05:31:10 -0400
committerWolfram Sang <wsa@the-dreams.de>2017-10-28 17:43:32 -0400
commit1cf855535b034579ac4d39f49da853594ce968dc (patch)
tree348d1193421a7ef3f2f6fee9c602bdb913a2dd8f
parenta0b8839e2afc6613566ab723f8e3f0e698e9e007 (diff)
power: supply: sbs-battery: move gpio present detect to sbs_get_property
Currently when a gpio is defined for battery presence it is only used in the sbs_get_battery_presence_and_health function for 2 properties. All other properties currently try to read data form the battery before returning an error if not present. We should know in advance that no data is going to returned. As the driver tries multiple times to access a property, this prevents a lot of smbus accesses, which had a significant effect on device boot-up. As when the device is registered lots of property accesses are attempted during boot. If no gpio is used for presence detection no change in behaviour should occur. Signed-off-by: Phil Reid <preid@electromag.com.au> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/power/supply/sbs-battery.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index b19a73176910..8dd4bd70c561 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -321,16 +321,6 @@ static int sbs_get_battery_presence_and_health(
321 union power_supply_propval *val) 321 union power_supply_propval *val)
322{ 322{
323 s32 ret; 323 s32 ret;
324 struct sbs_info *chip = i2c_get_clientdata(client);
325
326 if (psp == POWER_SUPPLY_PROP_PRESENT && chip->gpio_detect) {
327 ret = gpiod_get_value_cansleep(chip->gpio_detect);
328 if (ret < 0)
329 return ret;
330 val->intval = ret;
331 chip->is_present = val->intval;
332 return ret;
333 }
334 324
335 /* 325 /*
336 * Write to ManufacturerAccess with ManufacturerAccess command 326 * Write to ManufacturerAccess with ManufacturerAccess command
@@ -598,6 +588,19 @@ static int sbs_get_property(struct power_supply *psy,
598 struct sbs_info *chip = power_supply_get_drvdata(psy); 588 struct sbs_info *chip = power_supply_get_drvdata(psy);
599 struct i2c_client *client = chip->client; 589 struct i2c_client *client = chip->client;
600 590
591 if (chip->gpio_detect) {
592 ret = gpiod_get_value_cansleep(chip->gpio_detect);
593 if (ret < 0)
594 return ret;
595 if (psp == POWER_SUPPLY_PROP_PRESENT) {
596 val->intval = ret;
597 chip->is_present = val->intval;
598 return 0;
599 }
600 if (ret == 0)
601 return -ENODATA;
602 }
603
601 switch (psp) { 604 switch (psp) {
602 case POWER_SUPPLY_PROP_PRESENT: 605 case POWER_SUPPLY_PROP_PRESENT:
603 case POWER_SUPPLY_PROP_HEALTH: 606 case POWER_SUPPLY_PROP_HEALTH: