Skip to content

Commit

Permalink
[ACCTON][AS9947-36XKB] Add model and serial string checking
Browse files Browse the repository at this point in the history
Signed-off-by: Willy Liu <[email protected]>
  • Loading branch information
Willy Liu committed Dec 12, 2024
1 parent 9c001dd commit 73e52c0
Showing 1 changed file with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,38 @@ _onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info)
if (info->percentage > 100)
info->percentage = 100;


/* Read model name */
snprintf(file, sizeof(file), "fan%d_model", fid);
len = onlp_file_read_str(&str, FAN_SYSFS_FORMAT_1, hwmon_idx, file);

if (str && len) {
memcpy(info->model, str, len);
info->model[len] = '\0';
if (sizeof(info->model) > len)
{
memcpy(info->model, str, len);
info->model[len] = '\0';
}
else
{
memcpy(info->model, str, sizeof(info->model));
info->model[sizeof(info->model)] = '\0';
}
}
AIM_FREE_IF_PTR(str);

/* serial number*/
snprintf(file, sizeof(file), "fan%d_serial", fid);
len = onlp_file_read_str(&str, FAN_SYSFS_FORMAT_1, hwmon_idx, file);
if (str && len) {
memcpy(info->serial, str, len);
info->serial[len] = '\0';
if (sizeof(info->serial) > len)
{
memcpy(info->serial, str, len);
info->serial[len] = '\0';
}
else
{
memcpy(info->serial, str, len);
info->serial[len] = '\0';
}
}
AIM_FREE_IF_PTR(str);

Expand Down

0 comments on commit 73e52c0

Please sign in to comment.