[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070415194001.GF10097@ucw.cz>
Date: Sun, 15 Apr 2007 19:40:01 +0000
From: Pavel Machek <pavel@....cz>
To: Anton Vorontsov <cbou@...l.ru>
Cc: linux-kernel@...r.kernel.org, kernel-discuss@...dhelds.org,
dwmw2@...radead.org
Subject: Re: [PATCH 6/7] [RFC] ds2760 battery driver
Hi!
> This is driver for batteries with ds2760 chip inside. Such batteries
> used in almost every HP iPaq and HTC PDAs/phones.
Looks nice to me. It even knows about dependency between temperature
and remaining power :-).
> + di->update_time = jiffies;
> +
> + /* DS2760 reports voltage in units of 4.88mV, but the battery class
> + * reports in units of mV, so convert by multiplying by 4.875.
> + * We approximate because integer math is cheap, and close enough. */
> + di->voltage_raw = (di->raw[DS2760_VOLTAGE_MSB] << 3) |
> + (di->raw[DS2760_VOLTAGE_LSB] >> 5);
> + di->voltage_mV = (di->voltage_raw * 5) - (di->voltage_raw / 8);
Hmm, not sure if such tricks re really worth it... should not compiler
be doing this?
> + /* Calculate the empty level at the present temperature. */
> + scale[4] = di->raw[DS2760_ACTIVE_EMPTY + 4];
> + for (i = 3; i >= 0; i--)
> + scale[i] = scale[i + 1] + di->raw[DS2760_ACTIVE_EMPTY + i];
> +
> + di->empty_mAh = battery_interpolate(scale, di->temp_C / 10);
Wow.
> +static struct platform_driver ds2760_battery_driver = {
> + .driver = {
> + .name = "ds2760-battery",
> + },
> + .probe = ds2760_battery_probe,
> + .remove = ds2760_battery_remove,
> + #ifdef CONFIG_PM
> + .suspend = ds2760_battery_suspend,
> + .resume = ds2760_battery_resume,
> + #endif
I thought ifdefs need to be at column 0?
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists