Re: [PATCH] power_supply: support CHARGE_NOW in OLPC battery

From: Anton Vorontsov
Date: Thu May 08 2008 - 13:13:36 EST


On Thu, May 08, 2008 at 01:01:02PM -0400, Andres Salomon wrote:
> Ok, CC'ing Richard as I should've done in the first place...
[...]
> > > + case POWER_SUPPLY_PROP_CHARGE_NOW:
> > > + ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void
> > > *)&ec_word, 2);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + val->intval = be16_to_cpu(ec_word);
> >
> > But you didn't convert it to the uAh, I think you should.
>
>
> We have logic in userspace that converts ACR to a useful number; for
> our purposes, we'd just like to read the raw ACR values.

No. The purpose of power supply class is to report values in common
units. Not some random value that userspace then should guess how to
compute.

> Perhaps CHARGE_NOW is the wrong thing to be using, if we can't get
> uAh and CHARGE_* requires that unit.

I don't think that converting X * uAh or uAh / Y to uAh is impossible.
I'd suggest you to convert the ACR value to uAh using fractions, see
ds2760_battery.c. Even if the final value losing precision a bit, it is
still useful to do CHARGE_NOW.

Of course, additionally you can create your own private attribute
which reports raw value, if this is anyhow useful.

--
Anton Vorontsov
email: cbouatmailru@xxxxxxxxx
irc://irc.freenode.net/bd2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/