* [PATCH] power/ds2760_battery: Add rated capacity of the hx4700 3600mAh battery
@ 2011-11-23 22:37 Paul Parsons
2011-11-24 18:16 ` Philipp Zabel
0 siblings, 1 reply; 5+ messages in thread
From: Paul Parsons @ 2011-11-23 22:37 UTC (permalink / raw)
To: linux-kernel; +Cc: philipp.zabel, mad_soft, koen, cbouatmailru
Add rated capacity of the HP iPAQ hx4700 3.7V 3600mAh (359114-001) battery.
For this battery the value of the rated capacity EEPROM register at 0x32 is 14;
thus rated_capacities[14] = 3600.
Signed-off-by: Paul Parsons <lost.distance@yahoo.com>
---
diff -uprN clean-3.2-rc2/drivers/power/ds2760_battery.c linux-3.2-rc2/drivers/power/ds2760_battery.c
--- clean-3.2-rc2/drivers/power/ds2760_battery.c 2011-11-15 17:02:59.000000000 +0000
+++ linux-3.2-rc2/drivers/power/ds2760_battery.c 2011-11-23 22:06:46.816841888 +0000
@@ -95,7 +95,11 @@ static int rated_capacities[] = {
2880, /* Samsung */
2880, /* BYD */
2880, /* Lishen */
- 2880 /* NEC */
+ 2880, /* NEC */
+#ifdef CONFIG_MACH_H4700
+ 0,
+ 3600, /* HP iPAQ hx4700 3.7V 3600mAh (359114-001) */
+#endif
};
/* array is level at temps 0°C, 10°C, 20°C, 30°C, 40°C
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] power/ds2760_battery: Add rated capacity of the hx4700 3600mAh battery
2011-11-23 22:37 [PATCH] power/ds2760_battery: Add rated capacity of the hx4700 3600mAh battery Paul Parsons
@ 2011-11-24 18:16 ` Philipp Zabel
2011-11-24 23:52 ` Paul Parsons
0 siblings, 1 reply; 5+ messages in thread
From: Philipp Zabel @ 2011-11-24 18:16 UTC (permalink / raw)
To: Paul Parsons; +Cc: linux-kernel, mad_soft, koen, cbouatmailru
On Wed, Nov 23, 2011 at 11:37 PM, Paul Parsons <lost.distance@yahoo.com> wrote:
> Add rated capacity of the HP iPAQ hx4700 3.7V 3600mAh (359114-001) battery.
> For this battery the value of the rated capacity EEPROM register at 0x32 is 14;
> thus rated_capacities[14] = 3600.
>
> Signed-off-by: Paul Parsons <lost.distance@yahoo.com>
> ---
> diff -uprN clean-3.2-rc2/drivers/power/ds2760_battery.c linux-3.2-rc2/drivers/power/ds2760_battery.c
> --- clean-3.2-rc2/drivers/power/ds2760_battery.c 2011-11-15 17:02:59.000000000 +0000
> +++ linux-3.2-rc2/drivers/power/ds2760_battery.c 2011-11-23 22:06:46.816841888 +0000
> @@ -95,7 +95,11 @@ static int rated_capacities[] = {
> 2880, /* Samsung */
> 2880, /* BYD */
> 2880, /* Lishen */
> - 2880 /* NEC */
> + 2880, /* NEC */
> +#ifdef CONFIG_MACH_H4700
> + 0,
> + 3600, /* HP iPAQ hx4700 3.7V 3600mAh (359114-001) */
> +#endif
Is that #ifdef needed? I know there's another one a few lines up, but
I think that one is already unfortunate and there is no conflict here.
regards
Philipp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] power/ds2760_battery: Add rated capacity of the hx4700 3600mAh battery
2011-11-24 18:16 ` Philipp Zabel
@ 2011-11-24 23:52 ` Paul Parsons
2011-11-25 23:56 ` Anton Vorontsov
0 siblings, 1 reply; 5+ messages in thread
From: Paul Parsons @ 2011-11-24 23:52 UTC (permalink / raw)
To: Philipp Zabel; +Cc: linux-kernel, mad_soft, koen, cbouatmailru
--- On Thu, 24/11/11, Philipp Zabel <philipp.zabel@gmail.com> wrote:
> > +#ifdef CONFIG_MACH_H4700
> > + 0,
> > + 3600, /* HP iPAQ hx4700 3.7V 3600mAh
> (359114-001) */
> > +#endif
>
> Is that #ifdef needed? I know there's another one a few
> lines up, but
> I think that one is already unfortunate and there is no
> conflict here.
Yes it is needed, because the rated_capacities[] table must contain different values for different platforms. The #ifdefs preserve the original table for other platforms.
Agreed it's untidy. Ideally the table would be replaced by platform specific data. However it's not obvious which other platforms use the table, nor whether the original table is correct for those other platforms. I presume that the table was originally believed to be common for all ds2760 based platforms, but the hx4700 demonstrates this is not the case.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] power/ds2760_battery: Add rated capacity of the hx4700 3600mAh battery
2011-11-24 23:52 ` Paul Parsons
@ 2011-11-25 23:56 ` Anton Vorontsov
2011-11-26 0:43 ` Anton Vorontsov
0 siblings, 1 reply; 5+ messages in thread
From: Anton Vorontsov @ 2011-11-25 23:56 UTC (permalink / raw)
To: Paul Parsons; +Cc: Philipp Zabel, linux-kernel, mad_soft, koen
On Thu, Nov 24, 2011 at 11:52:56PM +0000, Paul Parsons wrote:
> --- On Thu, 24/11/11, Philipp Zabel <philipp.zabel@gmail.com> wrote:
> > > +#ifdef CONFIG_MACH_H4700
> > > + 0,
> > > + 3600, /* HP iPAQ hx4700 3.7V 3600mAh
> > (359114-001) */
> > > +#endif
> >
> > Is that #ifdef needed? I know there's another one a few
> > lines up, but
> > I think that one is already unfortunate and there is no
> > conflict here.
>
> Yes it is needed, because the rated_capacities[] table must
> contain different values for different platforms. The #ifdefs
> preserve the original table for other platforms.
>
> Agreed it's untidy. Ideally the table would be replaced by
> platform specific data. However it's not obvious which other
> platforms use the table, nor whether the original table is
> correct for those other platforms. I presume that the table
> was originally believed to be common for all ds2760 based
> platforms, but the hx4700 demonstrates this is not the case.
Well, the really bad thing is that ds2760 is on the hot-pluggable
bus, so basically there is no such thing as 'platform_data'. You
can basically attach any battery, with any value in the
rated_capacity 'register'. :-(
The only thing we can do is some machine-specific fixup. The
universal way is ds2760_battery.rate_capacity module (and kernel
command line) parameter that you can use to fixup the value.
But, having the MACH_HX4700 fixup is just a heuristic that
helps the driver to work on the particular machine 'out of
the box'.
The really bad thing about that patch is that it uses build-time
way for the heuristic. We should really call something like
machine_is(). But that would be architecture-specific today
(i.e. will only work on ARM). Heh.
So... I'm applying the patch as it is not a big deal, and we
have a similar machine fixup already.
Thanks!
--
Anton Vorontsov
Email: cbouatmailru@gmail.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] power/ds2760_battery: Add rated capacity of the hx4700 3600mAh battery
2011-11-25 23:56 ` Anton Vorontsov
@ 2011-11-26 0:43 ` Anton Vorontsov
0 siblings, 0 replies; 5+ messages in thread
From: Anton Vorontsov @ 2011-11-26 0:43 UTC (permalink / raw)
To: Paul Parsons; +Cc: Philipp Zabel, linux-kernel, mad_soft, koen
On Sat, Nov 26, 2011 at 03:56:13AM +0400, Anton Vorontsov wrote:
[...]
> The only thing we can do is some machine-specific fixup. The
> universal way is ds2760_battery.rate_capacity module (and kernel
> command line) parameter that you can use to fixup the value.
Oh, btw, nowadays there is support for writable properties in the
power supply class. So, in addition to the module parameter, for
convenience you might also implement write-function for the
rated_capacity value.
Thanks,
--
Anton Vorontsov
Email: cbouatmailru@gmail.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-11-26 0:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-23 22:37 [PATCH] power/ds2760_battery: Add rated capacity of the hx4700 3600mAh battery Paul Parsons
2011-11-24 18:16 ` Philipp Zabel
2011-11-24 23:52 ` Paul Parsons
2011-11-25 23:56 ` Anton Vorontsov
2011-11-26 0:43 ` Anton Vorontsov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.