Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

power: supply: bd71828: Support wider register addresses

The BD71828 power-supply driver assumes register addresses to be 8-bit.
The new BD72720 will use stacked register maps to hide paging which is
done using secondary I2C slave address. This requires use of 9-bit
register addresses in the power-supply driver (added offset 0x100 to
the 8-bit hardware register addresses).

The cost is slightly used memory consumption as the members in the
struct pwr_regs will be changed from u8 to unsigned int, which means 3
byte increase / member / instance.
This is currently 14 members (expected to possibly be increased when
adding new variants / new functionality which may introduce new
registers, but not expected to grow much) and 2 instances (will be 3
instances when BD72720 gets added).

So, even if the number of registers grew to 50 it'd be 150 bytes /
instance. Assuming we eventually supported 5 variants, it'd be
5 * 150 bytes, which stays very reasonable considering systems we are
dealing with.

As a side note, we can reduce the "wasted space / member / instance" from
3 bytes to 1 byte, by using u16 instead of the unsigned int if needed. I
rather use unsigned int to be initially prepared for devices with 32 bit
registers if there is no need to count bytes.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://patch.msgid.link/57c87f7e2082a666f0adeafcd11f673c0af7d326.1765804226.git.mazziesaccount@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Matti Vaittinen and committed by
Lee Jones
de8f20af 0234e003

+13 -13
+13 -13
drivers/power/supply/bd71828-power.c
··· 44 44 #define VBAT_LOW_TH 0x00D4 45 45 46 46 struct pwr_regs { 47 - u8 vbat_avg; 48 - u8 ibat; 49 - u8 ibat_avg; 50 - u8 btemp_vth; 51 - u8 chg_state; 52 - u8 bat_temp; 53 - u8 dcin_stat; 54 - u8 dcin_collapse_limit; 55 - u8 chg_set1; 56 - u8 chg_en; 57 - u8 vbat_alm_limit_u; 58 - u8 conf; 59 - u8 vdcin; 47 + unsigned int vbat_avg; 48 + unsigned int ibat; 49 + unsigned int ibat_avg; 50 + unsigned int btemp_vth; 51 + unsigned int chg_state; 52 + unsigned int bat_temp; 53 + unsigned int dcin_stat; 54 + unsigned int dcin_collapse_limit; 55 + unsigned int chg_set1; 56 + unsigned int chg_en; 57 + unsigned int vbat_alm_limit_u; 58 + unsigned int conf; 59 + unsigned int vdcin; 60 60 }; 61 61 62 62 static const struct pwr_regs pwr_regs_bd71828 = {