From: Jeremy Kerr Date: Tue, 12 Jul 2022 09:20:25 +0000 (+0800) Subject: tree: Change nvme_dev from global to static X-Git-Tag: v2.2~57 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=110f6f152db8943ee1990532639538e67e644b68;p=users%2Fsagi%2Fnvme-cli.git tree: Change nvme_dev from global to static We're currently exposing the global struct nvme_dev, to allow the old users access to the name and statbuf data. Now that users have their local reference (along with the fd) through parse_and_open instead, we can drop the public definition, and declare it static to nvme.c. We still keep the static declaration; this will be removed in an upcoming change. Signed-off-by: Jeremy Kerr --- diff --git a/nvme.c b/nvme.c index 86d624de..3c11aea8 100644 --- a/nvme.c +++ b/nvme.c @@ -79,8 +79,8 @@ struct feat_cfg { bool human_readable; }; -struct nvme_dev _nvme_dev; -struct nvme_dev *nvme_dev = &_nvme_dev; +static struct nvme_dev _nvme_dev; +static struct nvme_dev *nvme_dev = &_nvme_dev; static const char nvme_version_string[] = NVME_VERSION; diff --git a/nvme.h b/nvme.h index c149ed35..25b9c2a7 100644 --- a/nvme.h +++ b/nvme.h @@ -53,7 +53,6 @@ int parse_and_open(struct nvme_dev **dev, int argc, char **argv, const char *des void dev_close(struct nvme_dev *dev); -extern struct nvme_dev *nvme_dev; extern const char *output_format; enum nvme_print_flags validate_output_format(const char *format); diff --git a/plugins/innogrit/innogrit-nvme.c b/plugins/innogrit/innogrit-nvme.c index 2e720a92..3769a260 100644 --- a/plugins/innogrit/innogrit-nvme.c +++ b/plugins/innogrit/innogrit-nvme.c @@ -44,8 +44,7 @@ static int innogrit_smart_log_additional(int argc, char **argv, return err; nvme_get_log_smart(dev->fd, cfg.namespace_id, false, &smart_log); - nvme_show_smart_log(&smart_log, cfg.namespace_id, - nvme_dev->name, NORMAL); + nvme_show_smart_log(&smart_log, cfg.namespace_id, dev->name, NORMAL); printf("DW0[0-1] Defect Cnt : %u\n", pvsc_smart->defect_cnt); printf("DW0[2-3] Slc Spb Cnt : %u\n", pvsc_smart->slc_spb_cnt); diff --git a/plugins/intel/intel-nvme.c b/plugins/intel/intel-nvme.c index 6bde9999..3425a22c 100644 --- a/plugins/intel/intel-nvme.c +++ b/plugins/intel/intel-nvme.c @@ -372,10 +372,10 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, if (!err) { if (cfg.json) show_intel_smart_log_jsn(&smart_log, cfg.namespace_id, - nvme_dev->name); + dev->name); else if (!cfg.raw_binary) show_intel_smart_log(&smart_log, cfg.namespace_id, - nvme_dev->name); + dev->name); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } diff --git a/plugins/memblaze/memblaze-nvme.c b/plugins/memblaze/memblaze-nvme.c index 856a5790..921ecb9b 100644 --- a/plugins/memblaze/memblaze-nvme.c +++ b/plugins/memblaze/memblaze-nvme.c @@ -483,8 +483,7 @@ static int mb_get_additional_smart_log(int argc, char **argv, struct command *cm if (!err) { if (!cfg.raw_binary) err = show_memblaze_smart_log(dev->fd, cfg.namespace_id, - nvme_dev->name, - &smart_log); + dev->name, &smart_log); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } diff --git a/plugins/scaleflux/sfx-nvme.c b/plugins/scaleflux/sfx-nvme.c index e42c28fa..44f4feaf 100644 --- a/plugins/scaleflux/sfx-nvme.c +++ b/plugins/scaleflux/sfx-nvme.c @@ -432,10 +432,10 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, if (!err) { if (cfg.json) show_sfx_smart_log_jsn(&smart_log, cfg.namespace_id, - nvme_dev->name); + dev->name); else if (!cfg.raw_binary) show_sfx_smart_log(&smart_log, cfg.namespace_id, - nvme_dev->name); + dev->name); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } diff --git a/plugins/seagate/seagate-nvme.c b/plugins/seagate/seagate-nvme.c index 63ff5261..179a7e6e 100644 --- a/plugins/seagate/seagate-nvme.c +++ b/plugins/seagate/seagate-nvme.c @@ -1128,7 +1128,7 @@ static int get_host_tele(int argc, char **argv, struct command *cmd, struct plug if (!cfg.raw_binary) { printf("Device:%s log-id:%d namespace-id:%#x\n", - nvme_dev->name, cfg.log_id, + dev->name, cfg.log_id, cfg.namespace_id); printf("Data Block 1 Last Block:%d Data Block 2 Last Block:%d Data Block 3 Last Block:%d\n", tele_log.tele_data_area1, tele_log.tele_data_area2, tele_log.tele_data_area3); @@ -1249,7 +1249,7 @@ static int get_ctrl_tele(int argc, char **argv, struct command *cmd, struct plug if (!cfg.raw_binary) { printf("Device:%s namespace-id:%#x\n", - nvme_dev->name, cfg.namespace_id); + dev->name, cfg.namespace_id); printf("Data Block 1 Last Block:%d Data Block 2 Last Block:%d Data Block 3 Last Block:%d\n", tele_log.tele_data_area1, tele_log.tele_data_area2, tele_log.tele_data_area3); diff --git a/plugins/shannon/shannon-nvme.c b/plugins/shannon/shannon-nvme.c index 7b02b452..c1c5b5a9 100644 --- a/plugins/shannon/shannon-nvme.c +++ b/plugins/shannon/shannon-nvme.c @@ -146,7 +146,7 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, if (!err) { if (!cfg.raw_binary) show_shannon_smart_log(&smart_log, cfg.namespace_id, - nvme_dev->name); + dev->name); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } diff --git a/plugins/solidigm/solidigm-garbage-collection.c b/plugins/solidigm/solidigm-garbage-collection.c index bd0041c6..9e40c88e 100644 --- a/plugins/solidigm/solidigm-garbage-collection.c +++ b/plugins/solidigm/solidigm-garbage-collection.c @@ -99,9 +99,9 @@ int solidigm_get_garbage_collection_log(int argc, char **argv, struct command *c if (flags & BINARY) { d_raw((unsigned char *)&gc_log, sizeof(gc_log)); } else if (flags & JSON) { - vu_gc_log_show_json(&gc_log, nvme_dev->name); + vu_gc_log_show_json(&gc_log, dev->name); } else { - vu_gc_log_show(&gc_log, nvme_dev->name); + vu_gc_log_show(&gc_log, dev->name); } } else if (err > 0) { diff --git a/plugins/solidigm/solidigm-smart.c b/plugins/solidigm/solidigm-smart.c index 7d885951..5e01066e 100644 --- a/plugins/solidigm/solidigm-smart.c +++ b/plugins/solidigm/solidigm-smart.c @@ -236,13 +236,12 @@ int solidigm_get_additional_smart_log(int argc, char **argv, struct command *cmd if (!err) { if (flags & JSON) { vu_smart_log_show_json(&smart_log_payload, - cfg.namespace_id, - nvme_dev->name); + cfg.namespace_id, dev->name); } else if (flags & BINARY) { d_raw((unsigned char *)&smart_log_payload, sizeof(smart_log_payload)); } else { vu_smart_log_show(&smart_log_payload, cfg.namespace_id, - nvme_dev->name); + dev->name); } } else if (err > 0) { nvme_show_status(err); diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index b9fd6b6f..f1893051 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -10507,7 +10507,7 @@ static int wdc_vs_temperature_stats(int argc, char **argv, if (fmt == NORMAL) { /* print the temperature stats */ printf("Temperature Stats for NVME device:%s namespace-id:%x\n", - nvme_dev->name, WDC_DE_GLOBAL_NSID); + dev->name, WDC_DE_GLOBAL_NSID); printf("Current Composite Temperature : %d °C\n", temperature); printf("WCTEMP : %"PRIu16" °C\n", id_ctrl.wctemp - 273); @@ -10582,7 +10582,7 @@ static int wdc_capabilities(int argc, char **argv, capabilities = wdc_get_drive_capabilities(r, dev); /* print command and supported status */ - printf("WDC Plugin Capabilities for NVME device:%s\n", nvme_dev->name); + printf("WDC Plugin Capabilities for NVME device:%s\n", dev->name); printf("cap-diag : %s\n", capabilities & WDC_DRIVE_CAP_CAP_DIAG ? "Supported" : "Not Supported"); printf("drive-log : %s\n",