mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
nyan: add 'max_size' parameter to read_mapped_string()
We changed the behavior of indata.size==0 case in cros_ec kernel driver. This breaks the nyan battery driver. Change the ectool as well. BUG=chrome-os-partner:24851 BRANCH=nyan TEST=verified on nyan rev B % ectool battery Battery info: OEM name: SANYO Model number: AP13J3K Chemistry : LION Serial number: 174E Design capacity: 4030 mAh Last full charge: 4030 mAh Design output voltage 11250 mV Cycle count 0 Present voltage 12934 mV Present current 0 mA Remaining capacity 3966 mAh Flags 0x03 AC_PRESENT BATT_PRESENT Change-Id: Id63d933802ed85d7f5d8f1c53e6389b083f41a8a Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/181667 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
143763421c
commit
9ccbedda19
@@ -245,11 +245,11 @@ static uint32_t read_mapped_mem32(uint8_t offset)
|
||||
return val;
|
||||
}
|
||||
|
||||
static int read_mapped_string(uint8_t offset, char *buffer)
|
||||
static int read_mapped_string(uint8_t offset, char *buffer, int max_size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ec_readmem(offset, 0, buffer);
|
||||
ret = ec_readmem(offset, max_size, buffer);
|
||||
if (ret <= 0) {
|
||||
fprintf(stderr, "failure in %s(): %d\n", __func__, ret);
|
||||
exit(1);
|
||||
@@ -2769,22 +2769,26 @@ int cmd_battery(int argc, char *argv[])
|
||||
|
||||
printf("Battery info:\n");
|
||||
|
||||
rv = read_mapped_string(EC_MEMMAP_BATT_MFGR, batt_text);
|
||||
rv = read_mapped_string(EC_MEMMAP_BATT_MFGR, batt_text,
|
||||
sizeof(batt_text));
|
||||
if (rv < 0 || !is_string_printable(batt_text))
|
||||
goto cmd_error;
|
||||
printf(" OEM name: %s\n", batt_text);
|
||||
|
||||
rv = read_mapped_string(EC_MEMMAP_BATT_MODEL, batt_text);
|
||||
rv = read_mapped_string(EC_MEMMAP_BATT_MODEL, batt_text,
|
||||
sizeof(batt_text));
|
||||
if (rv < 0 || !is_string_printable(batt_text))
|
||||
goto cmd_error;
|
||||
printf(" Model number: %s\n", batt_text);
|
||||
|
||||
rv = read_mapped_string(EC_MEMMAP_BATT_TYPE, batt_text);
|
||||
rv = read_mapped_string(EC_MEMMAP_BATT_TYPE, batt_text,
|
||||
sizeof(batt_text));
|
||||
if (rv < 0 || !is_string_printable(batt_text))
|
||||
goto cmd_error;
|
||||
printf(" Chemistry : %s\n", batt_text);
|
||||
|
||||
rv = read_mapped_string(EC_MEMMAP_BATT_SERIAL, batt_text);
|
||||
rv = read_mapped_string(EC_MEMMAP_BATT_SERIAL, batt_text,
|
||||
sizeof(batt_text));
|
||||
printf(" Serial number: %s\n", batt_text);
|
||||
|
||||
val = read_mapped_mem32(EC_MEMMAP_BATT_DCAP);
|
||||
|
||||
Reference in New Issue
Block a user