Skip to content

Commit

Permalink
wdc: Review changes and build fixes
Browse files Browse the repository at this point in the history
Signed-off-by: jeff-lien-wdc <[email protected]>
  • Loading branch information
jeff-lien-sndk committed Mar 13, 2024
1 parent d21dc8d commit 804c65a
Showing 1 changed file with 35 additions and 38 deletions.
73 changes: 35 additions & 38 deletions plugins/wdc/wdc-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -5553,11 +5553,13 @@ static void wdc_print_fw_act_history_log_normal(__u8 *data, int num_entries,
char previous_fw[9];
char new_fw[9];
char commit_action_bin[8];
char time_str[11];
char time_str[100];
__u16 oldestEntryIdx = 0, entryIdx = 0;
uint64_t timestamp;
__u64 timestamp_sec;
char *null_fw = "--------";

memset((void *)time_str, 0, 11);
memset((void *)time_str, '\0', 100);

if (data[0] == WDC_NVME_GET_FW_ACT_HISTORY_C2_LOG_ID) {
printf(" Firmware Activate History Log\n");
Expand Down Expand Up @@ -5604,27 +5606,28 @@ static void wdc_print_fw_act_history_log_normal(__u8 *data, int num_entries,

printf("%5"PRIu16"", (uint16_t)le16_to_cpu(fw_act_history_entry->entry[entryIdx].fw_act_hist_entries));

uint64_t timestamp = (0x0000FFFFFFFFFFFF &
le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp));
__u64 timestamp_sec = le64_to_cpu(timestamp) / 1000;
timestamp = (0x0000FFFFFFFFFFFF &
le64_to_cpu(
fw_act_history_entry->entry[entryIdx].timestamp));
timestamp_sec = timestamp / 1000;
if (cust_id == WDC_CUSTOMER_ID_0x1005) {
printf(" ");
memset((void *)time_str, 0, 9);
sprintf((char *)time_str, "%04d:%02d:%02d",
(int)(le64_to_cpu(timestamp_sec)/3600),
(int)((le64_to_cpu(timestamp_sec%3600)/60)),
(int)(le64_to_cpu(timestamp_sec%60)));
sprintf((char *)time_str, "%"PRIu32":%u:%u",
(__u32)(timestamp_sec/3600),
(__u8)(timestamp_sec%3600/60),
(__u8)(timestamp_sec%60));

printf("%s", time_str);
printf(" ");
} else if (vendor_id == WDC_NVME_SNDK_VID) {
printf(" ");

memset((void *)time_str, 0, 9);
sprintf((char *)time_str, "%04d:%02d:%02d",
(int)((le64_to_cpu(timestamp_sec)/3600)%24),
(int)((le64_to_cpu(timestamp_sec)/60)%60),
(int)(le64_to_cpu(timestamp_sec)%60));
sprintf((char *)time_str, "%"PRIu32":%u:%u",
(__u32)((timestamp_sec/3600)%24),
(__u8)((timestamp_sec/60)%60),
(__u8)(timestamp_sec%60));
printf("%s", time_str);
printf(" ");
} else {
Expand Down Expand Up @@ -5733,13 +5736,15 @@ static void wdc_print_fw_act_history_log_json(__u8 *data, int num_entries,
char new_fw[9];
char commit_action_bin[8];
char fail_str[32];
char time_str[11];
char time_str[100];
char ext_time_str[20];
uint64_t timestamp;
__u64 timestamp_sec;

memset((void *)previous_fw, 0, 9);
memset((void *)new_fw, 0, 9);
memset((void *)commit_action_bin, 0, 8);
memset((void *)time_str, 0, 11);
memset((void *)time_str, '\0', 100);
memset((void *)ext_time_str, 0, 20);
memset((void *)fail_str, 0, 11);
char *null_fw = "--------";
Expand Down Expand Up @@ -5779,22 +5784,23 @@ static void wdc_print_fw_act_history_log_json(__u8 *data, int num_entries,
json_object_add_value_int(root, "Entry",
le16_to_cpu(fw_act_history_entry->entry[entryIdx].fw_act_hist_entries));

uint64_t timestamp = (0x0000FFFFFFFFFFFF &
le64_to_cpu(fw_act_history_entry->entry[entryIdx].timestamp));
__u64 timestamp_sec = le64_to_cpu(timestamp)/1000;
timestamp = (0x0000FFFFFFFFFFFF &
le64_to_cpu(
fw_act_history_entry->entry[entryIdx].timestamp));
timestamp_sec = timestamp / 1000;
if (cust_id == WDC_CUSTOMER_ID_0x1005) {
sprintf((char *)time_str, "%04d:%02d:%02d",
(int)(le64_to_cpu(timestamp_sec)/3600),
(int)((le64_to_cpu(timestamp_sec)%3600/60)),
(int)(le64_to_cpu(timestamp_sec)%60));
sprintf((char *)time_str, "%"PRIu32":%u:%u",
(__u32)(timestamp_sec/3600),
(__u8)(timestamp_sec%3600/60),
(__u8)(timestamp_sec%60));

json_object_add_value_string(root, "Power on Hour", time_str);

} else if (vendor_id == WDC_NVME_SNDK_VID) {
sprintf((char *)time_str, "%04d:%02d:%02d",
(int)((le64_to_cpu(timestamp_sec)/3600)%24),
(int)((le64_to_cpu(timestamp_sec)/60)%60),
(int)(le64_to_cpu(timestamp_sec)%60));
sprintf((char *)time_str, "%"PRIu32":%u:%u",
(__u32)((timestamp_sec/3600)%24),
(__u8)((timestamp_sec/60)%60),
(__u8)(timestamp_sec%60));
json_object_add_value_string(root, "Power on Hour", time_str);
} else {
json_object_add_value_uint64(root, "Timestamp", timestamp);
Expand Down Expand Up @@ -9063,7 +9069,6 @@ static int wdc_get_fw_act_history_C2(nvme_root_t r, struct nvme_dev *dev,
enum nvme_print_flags fmt;
__u8 *data;
int ret;
int i;
bool c2GuidMatch = false;

if (!wdc_check_device(r, dev))
Expand Down Expand Up @@ -9096,15 +9101,7 @@ static int wdc_get_fw_act_history_C2(nvme_root_t r, struct nvme_dev *dev,
/* Get the log page data and verify the GUID */
fw_act_history_log = (struct wdc_fw_act_history_log_format_c2 *)(data);

for (i = 0; i < 16; i++) {
if (ocp_C2_guid[i] != fw_act_history_log->log_page_guid[i]) {
c2GuidMatch = false;
break;
}
}

if (i == 16)
c2GuidMatch = true;
c2GuidMatch = !memcmp(ocp_C2_guid, fw_act_history_log->log_page_guid, WDC_C2_GUID_LENGTH);

Check failure on line 9104 in plugins/wdc/wdc-nvme.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 106 exceeds 100 columns

if (c2GuidMatch) {
/* parse the data */
Expand All @@ -9127,7 +9124,7 @@ static int wdc_get_fw_act_history_C2(nvme_root_t r, struct nvme_dev *dev,
ret = wdc_print_fw_act_history_log(data, num_entries,
fmt, cust_id, vendor_id, device_id);
} else {
fprintf(stderr, "INFO: WDC: No FW Activate History entries found.\n");
fprintf(stderr, "INFO: WDC: No entries found.\n");
ret = 0;
}
} else {
Expand Down Expand Up @@ -9195,7 +9192,7 @@ static int wdc_vs_fw_activate_history(int argc, char **argv, struct command *com
ret = wdc_get_fw_act_history_C2(r, dev, cfg.output_format);
else
ret = wdc_get_fw_act_history(r, dev, cfg.output_format);
} else if (capabilities & WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY_C2 {
} else if (capabilities & WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY_C2) {
ret = wdc_get_fw_act_history_C2(r, dev, cfg.output_format);
}

Expand Down

0 comments on commit 804c65a

Please sign in to comment.