[BATTERY] Add status_caps file,
showing which status flags the driver supports
David Woodhouse
dwmw2 at infradead.org
Tue Nov 7 22:38:26 EST 2006
Commit: ed23611d8ed5df17d755afd88b9ed41763d92568
Parent: 2c569104e3d59f809b0ba87691379975de49601b
commit ed23611d8ed5df17d755afd88b9ed41763d92568
Author: David Woodhouse <dwmw2 at infradead.org>
AuthorDate: Wed Oct 25 13:04:38 2006 +0300
Commit: David Woodhouse <dwmw2 at infradead.org>
CommitDate: Wed Oct 25 13:04:38 2006 +0300
[BATTERY] Add status_caps file, showing which status flags the driver supports
Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
drivers/battery/battery-class.c | 12 ++++++++++++
drivers/battery/olpc-battery.c | 4 ++++
include/linux/battery.h | 2 +-
3 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/drivers/battery/battery-class.c b/drivers/battery/battery-class.c
index 31fdf97..64e7001 100644
--- a/drivers/battery/battery-class.c
+++ b/drivers/battery/battery-class.c
@@ -70,6 +70,15 @@ ssize_t battery_attribute_show_ac_status
EXPORT_SYMBOL_GPL(battery_attribute_show_ac_status);
+static ssize_t battery_attribute_show_caps(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct battery_dev *battery_dev = dev_get_drvdata(dev);
+
+ return battery_attribute_show_status(buf, battery_dev->status_cap);
+}
+
static ssize_t battery_attribute_show_name(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -89,6 +98,7 @@ static ssize_t battery_attribute_show_ty
return 1 + sprintf(buf, "%s\n", dev_types[battery_dev->type]);
}
+static DEVICE_ATTR(status_cap, 0444, battery_attribute_show_caps, NULL);
static DEVICE_ATTR(name, 0444, battery_attribute_show_name, NULL);
static DEVICE_ATTR(type, 0444, battery_attribute_show_type, NULL);
@@ -131,6 +141,7 @@ int battery_device_register(struct devic
dev_set_drvdata(battery_dev->dev, battery_dev);
/* register the attributes */
+ device_create_file(battery_dev->dev, &dev_attr_status_cap);
device_create_file(battery_dev->dev, &dev_attr_type);
device_create_file(battery_dev->dev, &dev_attr_name);
@@ -149,6 +160,7 @@ EXPORT_SYMBOL_GPL(battery_device_registe
*/
void battery_device_unregister(struct battery_dev *battery_dev)
{
+ device_remove_file(battery_dev->dev, &dev_attr_status_cap);
device_remove_file(battery_dev->dev, &dev_attr_type);
device_remove_file(battery_dev->dev, &dev_attr_name);
diff --git a/drivers/battery/olpc-battery.c b/drivers/battery/olpc-battery.c
index e62bbdb..c7182cd 100644
--- a/drivers/battery/olpc-battery.c
+++ b/drivers/battery/olpc-battery.c
@@ -249,11 +249,15 @@ static struct olpc_bat_attr_str attrs_st
static struct battery_dev olpc_bat = {
.name = "OLPC battery",
.type = PWRDEV_TYPE_BATTERY,
+ .status_cap = BAT_STAT_PRESENT|BAT_STAT_FULL|BAT_STAT_CRITICAL|
+ BAT_STAT_LOW|BAT_STAT_CHARGING|BAT_STAT_DISCHARGING|
+ BAT_STAT_OVERTEMP;
};
static struct battery_dev olpc_ac = {
.name = "OLPC AC",
.type = PWRDEV_TYPE_AC,
+ .status_cap = BAT_STAT_PRESENT
};
static struct platform_device *bat_plat_dev;
diff --git a/include/linux/battery.h b/include/linux/battery.h
index 6148d5f..679e2c8 100644
--- a/include/linux/battery.h
+++ b/include/linux/battery.h
@@ -75,7 +75,7 @@ #define BAT_INFO_MFR_DATE "manufacture_d
#define BAT_INFO_FIRST_USE "first_use" /* YYYY[-MM[-DD]] */
struct battery_dev {
-
+ int status_cap;
int id;
int type;
const char *name;
More information about the Commits-kernel
mailing list