diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2009-11-04 10:31:25 +0100 |
---|---|---|
committer | Lars-Peter Clausen <lars@metafoo.de> | 2009-11-04 10:51:44 +0100 |
commit | bbfeb9cbfdf307a6d707243ffbb9a9849358ae9f (patch) | |
tree | 5be3a7edfd6fbd9819e3570c9849d9c8aa167ff7 | |
parent | a4ad28f450b3fa2a2b0aee1729b81b7d4e808f67 (diff) |
pcf50606-charger: Set proper mode for charge_mode sysfsfile
The owner of the file should be able to modify it's content.
Also output the string representation of a charge mode if it exists.
-rw-r--r-- | drivers/power/pcf50606-charger.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/drivers/power/pcf50606-charger.c b/drivers/power/pcf50606-charger.c index c803dce1acc..ee270714a74 100644 --- a/drivers/power/pcf50606-charger.c +++ b/drivers/power/pcf50606-charger.c @@ -65,15 +65,38 @@ int pcf50606_charge_fast(struct pcf50606 *pcf, int on) } EXPORT_SYMBOL_GPL(pcf50606_charge_fast); +static const char *charge_mode_descs[] = { + "qualification", + "pre", + "trickle", + "fast_cccv", + "idle", +}; + static ssize_t show_charge_mode(struct device *dev, struct device_attribute *attr, char *buf) { struct pcf50606_mbc *mbc = dev_get_drvdata(dev); + const char **desc = charge_mode_descs; uint8_t charge_mode = pcf50606_reg_read(mbc->pcf, PCF50606_REG_MBCC1); charge_mode &= PCF50606_MBCC1_CHGMOD_MASK; - - return sprintf(buf, "%d\n", charge_mode); + switch (charge_mode) { + case PCF50606_MBCC1_CHGMOD_IDLE: + ++desc; + case PCF50606_MBCC1_CHGMOD_FAST_CCCV: + ++desc; + case PCF50606_MBCC1_CHGMOD_TRICKLE: + ++desc; + case PCF50606_MBCC1_CHGMOD_PRE: + ++desc; + case PCF50606_MBCC1_CHGMOD_QUAL: + return sprintf(buf, "%s\n", *desc); + break; + default: + return sprintf(buf, "unkown: %d\n", charge_mode); + break; + } } static ssize_t set_charge_mode(struct device *dev, struct device_attribute *attr, @@ -103,7 +126,7 @@ static ssize_t set_charge_mode(struct device *dev, struct device_attribute *attr return count; } -static DEVICE_ATTR(charge_mode, S_IRUGO, show_charge_mode, set_charge_mode); +static DEVICE_ATTR(charge_mode, S_IRUGO | S_IWUSR, show_charge_mode, set_charge_mode); static void pcf50606_mbc_irq_handler(int irq, void *data) |