Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 165506
b: refs/heads/master
c: c1e7219
h: refs/heads/master
v: v3
  • Loading branch information
Daniel Mack authored and Anton Vorontsov committed Jul 30, 2009
1 parent db1a036 commit 7092228
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5c6e9bf2c96e746237516bc8897add67682ee452
refs/heads/master: c1e72193ea3fa02e96bf3aa66006e18d107d0266
19 changes: 19 additions & 0 deletions trunk/drivers/power/ds2760_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ static unsigned int pmod_enabled;
module_param(pmod_enabled, bool, 0644);
MODULE_PARM_DESC(pmod_enabled, "PMOD enable bit");

static unsigned int rated_capacity;
module_param(rated_capacity, uint, 0644);
MODULE_PARM_DESC(rated_capacity, "rated battery capacity, 10*mAh or index");

/* Some batteries have their rated capacity stored a N * 10 mAh, while
* others use an index into this table. */
static int rated_capacities[] = {
Expand Down Expand Up @@ -274,6 +278,17 @@ static void ds2760_battery_write_status(struct ds2760_device_info *di,
w1_ds2760_recall_eeprom(di->w1_dev, DS2760_EEPROM_BLOCK1);
}

static void ds2760_battery_write_rated_capacity(struct ds2760_device_info *di,
unsigned char rated_capacity)
{
if (rated_capacity == di->raw[DS2760_RATED_CAPACITY])
return;

w1_ds2760_write(di->w1_dev, &rated_capacity, DS2760_RATED_CAPACITY, 1);
w1_ds2760_store_eeprom(di->w1_dev, DS2760_EEPROM_BLOCK1);
w1_ds2760_recall_eeprom(di->w1_dev, DS2760_EEPROM_BLOCK1);
}

static void ds2760_battery_work(struct work_struct *work)
{
struct ds2760_device_info *di = container_of(work,
Expand Down Expand Up @@ -399,6 +414,10 @@ static int ds2760_battery_probe(struct platform_device *pdev)

ds2760_battery_write_status(di, status);

/* set rated capacity from module param */
if (rated_capacity)
ds2760_battery_write_rated_capacity(di, rated_capacity);

retval = power_supply_register(&pdev->dev, &di->bat);
if (retval) {
dev_err(di->dev, "failed to register battery\n");
Expand Down

0 comments on commit 7092228

Please sign in to comment.