Skip to content

Commit a8e8ef5

Browse files
ikegami-tigaw
authored andcommitted
ocp: fix firmware activation history entry endian
Fix the entry data fields to little endian format. Basically print functions convert the fields data to cpu format. But still some errors then fixed the print functions also. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 01abe63 commit a8e8ef5

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

plugins/ocp/ocp-fw-activation-history.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@ struct plugin;
1616
struct __packed fw_activation_history_entry {
1717
__u8 ver_num;
1818
__u8 entry_length;
19-
__u16 reserved1;
20-
__u16 activation_count;
21-
__u64 timestamp;
22-
__u64 reserved2;
23-
__u64 power_cycle_count;
19+
__le16 reserved1;
20+
__le16 activation_count;
21+
__le64 timestamp;
22+
__le64 reserved2;
23+
__le64 power_cycle_count;
2424
char previous_fw[8];
2525
char new_fw[8];
2626
__u8 slot_number;
2727
__u8 commit_action;
28-
__u16 result;
28+
__le16 result;
2929
__u8 reserved3[14];
3030
};
3131

3232
struct __packed fw_activation_history {
3333
__u8 log_id;
3434
__u8 reserved1[3];
35-
__u32 valid_entries;
35+
__le32 valid_entries;
3636
struct fw_activation_history_entry entries[20];
3737
__u8 reserved2[2790];
38-
__u16 log_page_version;
39-
__u64 log_page_guid[2];
38+
__le16 log_page_version;
39+
__le64 log_page_guid[2];
4040
};
4141

4242
int ocp_fw_activation_history_log(int argc, char **argv, struct command *cmd,

plugins/ocp/ocp-print-json.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static void json_fw_activation_history(const struct fw_activation_history *fw_hi
8888

8989
struct json_object *entries = json_create_array();
9090

91-
for (int index = 0; index < fw_history->valid_entries; index++) {
91+
for (int index = 0; index < le32_to_cpu(fw_history->valid_entries); index++) {
9292
const struct fw_activation_history_entry *entry = &fw_history->entries[index];
9393
struct json_object *entry_obj = json_create_object();
9494

plugins/ocp/ocp-print-stdout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ static void stdout_fw_activation_history(const struct fw_activation_history *fw_
6464

6565
printf(" entries:\n");
6666

67-
for (int index = 0; index < fw_history->valid_entries; index++) {
67+
for (int index = 0; index < le32_to_cpu(fw_history->valid_entries); index++) {
6868
const struct fw_activation_history_entry *entry = &fw_history->entries[index];
6969

70-
printf(" entry[%d]:\n", le32_to_cpu(index));
70+
printf(" entry[%d]:\n", index);
7171
printf(" %-22s%d\n", "version number:", entry->ver_num);
7272
printf(" %-22s%d\n", "entry length:", entry->entry_length);
7373
printf(" %-22s%d\n", "activation count:",

0 commit comments

Comments
 (0)