From: "Heiko Stübner" <heiko@sntech.de>
To: Anton Vorontsov <cbou@mail.ru>, David Woodhouse <dwmw2@infradead.org>
Cc: "Vasily Khoruzhick" <anarsoul@gmail.com>,
linux-kernel@vger.kernel.org,
"Linux PM mailing list" <linux-pm@lists.linux-foundation.org>,
"Heiko Stübner" <heiko@sntech.de>
Subject: [PATCH] s3c-adc-battery: Add naive POWER_SUPPLY_PROP_PRESENT implementation
Date: Thu, 10 Nov 2011 09:56:43 +0100 [thread overview]
Message-ID: <201111100956.43979.heiko@sntech.de> (raw)
Userspace programs like upower seem to depend on the presence of the
POWER_SUPPLY_PROP_PRESENT property.
The real presence of the battery cannot be sensed and all other
routines of s3c-adc-battery simply expect it to be present.
Therefore we simply return 1, unless the battery struct is not present at all.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
drivers/power/s3c_adc_battery.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/drivers/power/s3c_adc_battery.c b/drivers/power/s3c_adc_battery.c
index d32d0d7..42d1f92 100644
--- a/drivers/power/s3c_adc_battery.c
+++ b/drivers/power/s3c_adc_battery.c
@@ -51,6 +51,7 @@ static enum power_supply_property s3c_adc_backup_bat_props[] = {
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_VOLTAGE_MIN,
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
+ POWER_SUPPLY_PROP_PRESENT,
};
static int s3c_adc_backup_bat_get_property(struct power_supply *psy,
@@ -60,6 +61,11 @@ static int s3c_adc_backup_bat_get_property(struct power_supply *psy,
struct s3c_adc_bat *bat = container_of(psy, struct s3c_adc_bat, psy);
if (!bat) {
+ if (psp == POWER_SUPPLY_PROP_PRESENT) {
+ val->intval = 0;
+ return 0;
+ }
+
dev_err(psy->dev, "%s: no battery infos ?!\n", __func__);
return -EINVAL;
}
@@ -83,6 +89,9 @@ static int s3c_adc_backup_bat_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
val->intval = bat->pdata->backup_volt_max;
return 0;
+ case POWER_SUPPLY_PROP_PRESENT:
+ val->intval = 1;
+ return 0;
default:
return -EINVAL;
}
@@ -106,6 +115,7 @@ static enum power_supply_property s3c_adc_main_bat_props[] = {
POWER_SUPPLY_PROP_CHARGE_NOW,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_CURRENT_NOW,
+ POWER_SUPPLY_PROP_PRESENT,
};
static int calc_full_volt(int volt_val, int cur_val, int impedance)
@@ -132,6 +142,11 @@ static int s3c_adc_bat_get_property(struct power_supply *psy,
unsigned int lut_size = bat->pdata->lut_noac_cnt;
if (!bat) {
+ if (psp == POWER_SUPPLY_PROP_PRESENT) {
+ val->intval = 0;
+ return 0;
+ }
+
dev_err(psy->dev, "no battery infos ?!\n");
return -EINVAL;
}
@@ -205,6 +220,9 @@ static int s3c_adc_bat_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_CURRENT_NOW:
val->intval = bat->cur_value;
return 0;
+ case POWER_SUPPLY_PROP_PRESENT:
+ val->intval = 1;
+ return 0;
default:
return -EINVAL;
}
--
1.6.1
next reply other threads:[~2011-11-10 8:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-10 8:56 Heiko Stübner [this message]
2011-11-10 11:05 ` [PATCH] s3c-adc-battery: Add naive POWER_SUPPLY_PROP_PRESENT implementation Vasily Khoruzhick
2011-11-10 11:05 ` Vasily Khoruzhick
2011-11-10 13:30 ` Anton Vorontsov
2011-11-10 13:30 ` Anton Vorontsov
2011-11-11 15:18 ` Heiko Stübner
2011-11-11 15:18 ` Heiko Stübner
-- strict thread matches above, loose matches on Subject: below --
2011-11-10 8:56 Heiko Stübner
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=201111100956.43979.heiko@sntech.de \
--to=heiko@sntech.de \
--cc=anarsoul@gmail.com \
--cc=cbou@mail.ru \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.