Skip to content

Commit

Permalink
nvme: Change phy-rx-eom-log command to use NVME_ARGS instead
Browse files Browse the repository at this point in the history
Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t committed Oct 13, 2023
1 parent 8f56b42 commit e98bc40
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -1908,27 +1908,22 @@ static int get_phy_rx_eom_log(int argc, char **argv, struct command *cmd,
struct config {
__u8 lsp;
__u16 controller;
char *output_format;
};

struct config cfg = {
.lsp = 0,
.controller = NVME_LOG_LSI_NONE,
.output_format = "normal",
};

OPT_ARGS(opts) = {
OPT_BYTE("lsp", 's', &cfg.lsp, lsp),
OPT_SHRT("controller", 'c', &cfg.controller, controller),
OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
OPT_END()
};
NVME_ARGS(opts, cfg,
OPT_BYTE("lsp", 's', &cfg.lsp, lsp),
OPT_SHRT("controller", 'c', &cfg.controller, controller));

err = parse_and_open(&dev, argc, argv, desc, opts);
if (err)
return err;

err = flags = validate_output_format(cfg.output_format);
err = flags = validate_output_format(output_format_val);
if (err < 0) {
nvme_show_error("Invalid output format");
return err;
Expand All @@ -1954,8 +1949,8 @@ static int get_phy_rx_eom_log(int argc, char **argv, struct command *cmd,
/* Just read measurement, take given action when fetching full log */
lsp_tmp = cfg.lsp & 0xf3;

err = nvme_cli_get_log_phy_rx_eom(dev, lsp_tmp, cfg.controller,
phy_rx_eom_log_len, phy_rx_eom_log);
err = nvme_cli_get_log_phy_rx_eom(dev, lsp_tmp, cfg.controller, phy_rx_eom_log_len,
phy_rx_eom_log);
if (err) {
if (err > 0)
nvme_show_status(err);
Expand All @@ -1965,20 +1960,19 @@ static int get_phy_rx_eom_log(int argc, char **argv, struct command *cmd,
return err;
}

if (phy_rx_eom_log->eomip == NVME_PHY_RX_EOM_COMPLETED) {
if (phy_rx_eom_log->eomip == NVME_PHY_RX_EOM_COMPLETED)
phy_rx_eom_log_len = le16_to_cpu(phy_rx_eom_log->hsize) +
le32_to_cpu(phy_rx_eom_log->dsize) *
le16_to_cpu(phy_rx_eom_log->nd);
} else {
else
phy_rx_eom_log_len = le16_to_cpu(phy_rx_eom_log->hsize);
}

phy_rx_eom_log = nvme_realloc(phy_rx_eom_log, phy_rx_eom_log_len);
if (!phy_rx_eom_log)
return -ENOMEM;

err = nvme_cli_get_log_phy_rx_eom(dev, cfg.lsp, cfg.controller,
phy_rx_eom_log_len, phy_rx_eom_log);
err = nvme_cli_get_log_phy_rx_eom(dev, cfg.lsp, cfg.controller, phy_rx_eom_log_len,
phy_rx_eom_log);
if (!err)
nvme_show_phy_rx_eom_log(phy_rx_eom_log, cfg.controller, flags);
else if (err > 0)
Expand Down

0 comments on commit e98bc40

Please sign in to comment.