Skip to content

Commit 54e9fc6

Browse files
committed
nvme-print-json: fix get feature 128-bit host id print
Since implemented as always 64-bit host id print. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 9e36c66 commit 54e9fc6

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

nvme-print-json.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4020,19 +4020,22 @@ static void json_feature_show_fields_sw_progress(struct json_object *r, unsigned
40204020
obj_add_uint(r, "Pre-boot Software Load Count (PBSLC)", result & 0xff);
40214021
}
40224022

4023-
static void json_feature_show_fields_host_id(struct json_object *r, unsigned char *buf)
4023+
static void json_feature_show_fields_host_id(struct json_object *r,
4024+
unsigned int result, unsigned char *hostid)
40244025
{
4025-
uint64_t ull = 0;
4026-
int i;
4026+
bool exhid;
40274027

4028-
if (buf) {
4029-
for (i = sizeof(ull) / sizeof(*buf); i; i--) {
4030-
ull |= buf[i - 1];
4031-
if (i - 1)
4032-
ull <<= BYTE_TO_BIT(sizeof(buf[i]));
4033-
}
4034-
obj_add_uint64(r, "Host Identifier (HOSTID)", ull);
4035-
}
4028+
if (!hostid)
4029+
return;
4030+
4031+
nvme_feature_decode_host_id(result, &exhid);
4032+
4033+
if (exhid)
4034+
obj_add_str(r, "Host Identifier (HOSTID)",
4035+
uint128_t_to_l10n_string(le128_to_cpu(hostid)));
4036+
else
4037+
obj_add_uint64(r, "Host Identifier (HOSTID)",
4038+
le64_to_cpu(*(__le64 *)hostid));
40364039
}
40374040

40384041
static void json_feature_show_fields_resv_mask(struct json_object *r, unsigned int result)
@@ -4296,7 +4299,7 @@ static void json_feature_show_fields(enum nvme_features_id fid, unsigned int res
42964299
json_feature_show_fields_sw_progress(r, result);
42974300
break;
42984301
case NVME_FEAT_FID_HOST_ID:
4299-
json_feature_show_fields_host_id(r, buf);
4302+
json_feature_show_fields_host_id(r, result, buf);
43004303
break;
43014304
case NVME_FEAT_FID_RESV_MASK:
43024305
json_feature_show_fields_resv_mask(r, result);

0 commit comments

Comments
 (0)