From af627ba96a2490c48539d91427aaac6bef5c4ba8 Mon Sep 17 00:00:00 2001 From: roy_lee Date: Wed, 29 Aug 2018 09:15:22 +0000 Subject: [PATCH] Store thermal1 addr after 1st get. Signed-off-by: roy_lee --- .../onlp/builds/src/module/src/thermali.c | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/thermali.c index 6e2e6c45..1e9f4161 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xm/onlp/builds/src/module/src/thermali.c @@ -26,6 +26,7 @@ #include #include #include "platform_lib.h" +#include #define VALIDATE(_id) \ do { \ @@ -36,7 +37,8 @@ /*Thermal 1 can be at 0x48 for R0A board, or 0x4C otherwise.*/ -static int thermal1_addr[] = {0x4c, 0x48}; +static int thermal1_addrs[] = {0x4c, 0x48}; +static int thermal1_addr = -1; static char* devfiles__[] = /* must map with onlp_thermal_id */ { @@ -101,18 +103,23 @@ onlp_thermali_init(void) return ONLP_STATUS_OK; } -/*check which addr of thermal1_addr[] can be read.*/ +/*check which addr of thermal1_addrs[] can be read.*/ static int _get_valid_t1_addr(char *path, int *addr) { - char fname[ONLP_OID_DESC_SIZE]; + char fname[PATH_MAX]; int i, rv, tmp; + if (thermal1_addr > 0){ + *addr = thermal1_addr; + return ONLP_STATUS_OK; + } - for (i=0; ihdr.description; - char tmp[ONLP_OID_DESC_SIZE]; - int t1_addr = thermal1_addr[0]; + char tmp[PATH_MAX]; + int t1_addr = thermal1_addrs[0]; int rv; rv = _get_valid_t1_addr(devfiles__[tid], &t1_addr);