Skip to content

Commit 1d74b9d

Browse files
committed
nvme-print: print product name if available
Somewhere in the past the support to print the product name was lost. Bring it back. Signed-off-by: Daniel Wagner <wagi@kernel.org>
1 parent 101fb94 commit 1d74b9d

7 files changed

Lines changed: 23 additions & 12 deletions

File tree

nvme-print-binary.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static void binary_id_ns_descs(void *data, unsigned nsid)
137137
d_raw((unsigned char *)data, 0x1000);
138138
}
139139

140-
static void binary_id_ctrl(struct nvme_id_ctrl *ctrl,
140+
static void binary_id_ctrl(struct nvme_id_ctrl *ctrl, const char *product_name,
141141
void (*vendor_show)(__u8 *vs, struct json_object *root))
142142
{
143143
d_raw((unsigned char *)ctrl, sizeof(*ctrl));

nvme-print-json.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ static void json_nvme_id_ns(struct nvme_id_ns *ns, unsigned int nsid,
349349
json_print(r);
350350
}
351351

352-
void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
353-
void (*vs)(__u8 *vs, struct json_object *r))
352+
void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl, const char *product_name,
353+
void (*vs)(__u8 *vs, struct json_object *r))
354354
{
355355
struct json_object *r = json_create_object();
356356
struct json_object *psds = json_create_array();
@@ -368,6 +368,9 @@ void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
368368
snprintf(fr, sizeof(fr), "%-.*s", (int)sizeof(ctrl->fr), ctrl->fr);
369369
snprintf(subnqn, sizeof(subnqn), "%-.*s", (int)sizeof(ctrl->subnqn), ctrl->subnqn);
370370

371+
if (product_name)
372+
obj_add_str(r, "product_name", product_name);
373+
371374
obj_add_int(r, "vid", le16_to_cpu(ctrl->vid));
372375
obj_add_int(r, "ssvid", le16_to_cpu(ctrl->ssvid));
373376
obj_add_str(r, "sn", sn);

nvme-print-stdout.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3348,11 +3348,13 @@ static void stdout_id_ctrl_power(struct nvme_id_ctrl *ctrl)
33483348
}
33493349
}
33503350

3351-
static void stdout_id_ctrl(struct nvme_id_ctrl *ctrl,
3351+
static void stdout_id_ctrl(struct nvme_id_ctrl *ctrl, const char *product_name,
33523352
void (*vendor_show)(__u8 *vs, struct json_object *root))
33533353
{
33543354
bool human = stdout_print_ops.flags & VERBOSE, vs = stdout_print_ops.flags & VS;
33553355

3356+
if (product_name)
3357+
printf("%s\n\n", product_name);
33563358
printf("NVME Identify Controller:\n");
33573359
printf("vid : %#x\n", le16_to_cpu(ctrl->vid));
33583360
printf("ssvid : %#x\n", le16_to_cpu(ctrl->ssvid));

nvme-print.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,10 +611,13 @@ void nvme_show_id_ns_descs(void *data, unsigned int nsid, nvme_print_flags_t fla
611611
nvme_print(id_ns_descs, flags, data, nsid);
612612
}
613613

614-
void nvme_show_id_ctrl(struct nvme_id_ctrl *ctrl, nvme_print_flags_t flags,
615-
void (*vendor_show)(__u8 *vs, struct json_object *root))
614+
void nvme_show_id_ctrl(struct nvme_id_ctrl *ctrl, const char *devname,
615+
nvme_print_flags_t flags,
616+
void (*vendor_show)(__u8 *vs, struct json_object *root))
616617
{
617-
nvme_print(id_ctrl, flags, ctrl, vendor_show);
618+
__cleanup_free char *product_name = nvme_product_name(devname);
619+
620+
nvme_print(id_ctrl, flags, ctrl, product_name, vendor_show);
618621
}
619622

620623
void nvme_show_id_ctrl_nvm(struct nvme_id_ctrl_nvm *ctrl_nvm,

nvme-print.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ struct print_ops {
5959
void (*fdp_usage_log)(struct nvme_fdp_ruhu_log *log, size_t len);
6060
void (*fid_supported_effects_log)(struct nvme_fid_supported_effects_log *fid_log, const char *devname);
6161
void (*fw_log)(struct nvme_firmware_slot *fw_log, const char *devname);
62-
void (*id_ctrl)(struct nvme_id_ctrl *ctrl, void (*vs)(__u8 *vs, struct json_object *root));
62+
void (*id_ctrl)(struct nvme_id_ctrl *ctrl, const char *product_name,
63+
void (*vs)(__u8 *vs, struct json_object *root));
6364
void (*id_ctrl_nvm)(struct nvme_id_ctrl_nvm *ctrl_nvm);
6465
void (*id_domain_list)(struct nvme_id_domain_list *id_dom);
6566
void (*id_independent_id_ns)(struct nvme_id_independent_id_ns *ns, unsigned int nsid);
@@ -183,8 +184,9 @@ void nvme_show_lba_status_info(__u64 result);
183184
void nvme_show_relatives(struct libnvme_global_ctx *ctx, const char *name, nvme_print_flags_t flags);
184185

185186
void nvme_show_id_iocs(struct nvme_id_iocs *iocs, nvme_print_flags_t flags);
186-
void nvme_show_id_ctrl(struct nvme_id_ctrl *ctrl, nvme_print_flags_t flags,
187-
void (*vendor_show)(__u8 *vs, struct json_object *root));
187+
void nvme_show_id_ctrl(struct nvme_id_ctrl *ctrl, const char *devname,
188+
nvme_print_flags_t flags, void (*vendor_show)(__u8 *vs,
189+
struct json_object *root));
188190
void nvme_show_id_ctrl_rpmbs(__le32 ctrl_rpmbs, nvme_print_flags_t flags);
189191
void nvme_show_id_ns(struct nvme_id_ns *ns, unsigned int nsid,
190192
unsigned int lba_index, bool cap_only, nvme_print_flags_t flags);

nvme.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3668,7 +3668,7 @@ int __id_ctrl(int argc, char **argv, struct command *acmd, struct plugin *plugin
36683668
return err;
36693669
}
36703670

3671-
nvme_show_id_ctrl(ctrl, flags, vs);
3671+
nvme_show_id_ctrl(ctrl, libnvme_transport_handle_get_name(hdl), flags, vs);
36723672

36733673
return err;
36743674
}

plugins/micron/micron-nvme.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4491,7 +4491,8 @@ static int micron_id_ctrl(int argc, char **argv, struct command *acmd,
44914491
return err;
44924492
}
44934493

4494-
nvme_show_id_ctrl(&ctrl, flags, micron_id_ctrl_vs);
4494+
nvme_show_id_ctrl(&ctrl, libnvme_transport_handle_get_name(hdl),
4495+
flags, micron_id_ctrl_vs);
44954496

44964497
return 0;
44974498
}

0 commit comments

Comments
 (0)