[as5912-54x] Support PSU serial number

This commit is contained in:
Brandon Chuang
2018-03-06 16:18:52 +08:00
parent 867ac4152f
commit 6eacf04db4
3 changed files with 28 additions and 1 deletions

View File

@@ -200,3 +200,27 @@ int psu_ym2651y_pmbus_info_set(int id, char *node, int value)
return ONLP_STATUS_OK;
}
#define PSU_SERIAL_NUMBER_LEN 18
int psu_serial_number_get(int id, char *serial, int serial_len)
{
int size = 0;
int ret = ONLP_STATUS_OK;
char *prefix = NULL;
if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) {
return ONLP_STATUS_E_PARAM;
}
prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX;
ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, "%s%s", prefix, "psu_mfr_serial");
if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) {
return ONLP_STATUS_E_INTERNAL;
}
serial[PSU_SERIAL_NUMBER_LEN] = '\0';
return ONLP_STATUS_OK;
}

View File

@@ -67,6 +67,7 @@ typedef enum psu_type {
} psu_type_t;
psu_type_t get_psu_type(int id, char* modelname, int modelname_len);
int psu_serial_number_get(int id, char *serial, int serial_len);
enum onlp_thermal_id
{

View File

@@ -101,7 +101,9 @@ psu_ym2651y_info_get(onlp_psu_info_t* info)
if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) {
info->mpout = val;
info->caps |= ONLP_PSU_CAPS_POUT;
}
}
psu_serial_number_get(index, info->serial, sizeof(info->serial));
return ONLP_STATUS_OK;
}