Re: [PATCH] ds2782_battery: add support for ds2786 battery gas gauge

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ryan Mallon
Date: Thursday, April 22, 2010 - 2:24 pm

Mike Rapoport wrote:

Thanks for this, some comments below.


I have only used the DS2782 chip. Can we just change this to DS278x? May
as well change to CONFIG_BATTERY_DS278x while we are here.


#define DS278x_REG_CURRENT_MSB		0x0e

Its the same register on both chips, no need for two #defines. Same of
the other registers, except for RARC.


If we make this a member of the info structure, we can easily use it in
calculations for both chips, ie

 	current_uA = raw * (info->current_units / sense_res);
	

This is basically the same as the ds2782 version. See Jean's comments on
my original patch about the sign math:
http://www.mail-archive.com/linux-i2c@vger.kernel.org/msg01220.html


Can we combine the implementations of the get_current function? Both
have get rsns (though in different ways) and eventually divide the
current register by the rsns value? Possibly move the get_rsns into
separate battery ops and attempt to coalesce these?


Again, if we move the multiplier value (1220 for ds2786 and 4800 for
ds2782) to the info structure then we can use the same code to get the
voltage for both chips.


Same here, move the divider to the info structure (will be 1 for ds2782)
and combine the functions.



-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon         		5 Amuri Park, 404 Barbadoes St
ryan@bluewatersys.com         	PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com	New Zealand
Phone: +64 3 3779127		Freecall: Australia 1800 148 751
Fax:   +64 3 3779135			  USA 1800 261 2934
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] ds2782_battery: add support for ds2786 battery ..., Ryan Mallon, (Thu Apr 22, 2:24 pm)