mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-26 19:25:02 +00:00
crossystem: Change ReadFileInt to take an unsigned int pointer
Currently ReadFileInt assumes that an integer value read from a file is never going to be "-1" and uses that value to indicate failure. In particular for GPIO values that may be returned by the kernel it is possible for them to be not simply 0 or 1 but instead a bit within the GPIO status register that indicates the value. The function semantics are changed to have the caller pass in the variable to store the integer in, and use the return code explicitly as a pass or fail condition. This requires all the callers of ReadFileInt to be changed to use the new scheme, and the x86 ReadGpio function is changed to normalize the GPIO value that is read from the kernel instead of assuming it is always 1 for active high values. BUG=chrome-os-partner:32645 BRANCH=samus,auron TEST=build for samus, check crossystem output and ensure that all values are properly reported and that wpsw_cur is correct now. Also tested to ensure no changes in output on: x86-alex, daisy, peach_pit, lumpy, stumpy, nyan_big, nyan_blaze, rush_ryu, panther, wolf, zako, auron, rambi, squawks, parrot_ivb, veyron_pinky Change-Id: I824152eed5f96cf1faaa18ba31a01f4d346ad172 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/223009 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
6d03b527fe
commit
d241fff54c
@@ -28,10 +28,10 @@ uint8_t* ReadFile(const char* filename, uint64_t* size);
|
||||
* Returns the destination, or NULL if error. */
|
||||
char* ReadFileString(char* dest, int size, const char* filename);
|
||||
|
||||
/* Read an integer from a file.
|
||||
/* Read an unsigned integer from a file and save into passed pointer.
|
||||
*
|
||||
* Returns the parsed integer, or -1 if error. */
|
||||
int ReadFileInt(const char* filename);
|
||||
* Returns 0 if success, -1 if error. */
|
||||
int ReadFileInt(const char* filename, unsigned* value);
|
||||
|
||||
/* Check if a bit is set in a file which contains an integer.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user