summaryrefslogtreecommitdiffstats
path: root/plugins/transcend/transcend-nvme.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:23:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:23:26 +0000
commitfab3f41b7b3f080c215157a026ee6bc7efbfe968 (patch)
treef0fafb0805c3eb11eb2a278f9f8058376c8f0f2b /plugins/transcend/transcend-nvme.c
parentAdding upstream version 2.1.2. (diff)
downloadnvme-cli-fab3f41b7b3f080c215157a026ee6bc7efbfe968.tar.xz
nvme-cli-fab3f41b7b3f080c215157a026ee6bc7efbfe968.zip
Adding upstream version 2.2.1.upstream/2.2.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/transcend/transcend-nvme.c')
-rw-r--r--plugins/transcend/transcend-nvme.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/plugins/transcend/transcend-nvme.c b/plugins/transcend/transcend-nvme.c
index a3b739d..024351f 100644
--- a/plugins/transcend/transcend-nvme.c
+++ b/plugins/transcend/transcend-nvme.c
@@ -21,20 +21,20 @@ static int getHealthValue(int argc, char **argv, struct command *cmd, struct plu
{
struct nvme_smart_log smart_log;
char *desc = "Get nvme health percentage.";
- int result=0, fd;
int percent_used = 0, healthvalue=0;
-
+ struct nvme_dev *dev;
+ int result;
+
OPT_ARGS(opts) = {
OPT_END()
};
- fd = parse_and_open(argc, argv, desc, opts);
-
- if (fd < 0) {
+ result = parse_and_open(&dev, argc, argv, desc, opts);
+ if (result) {
printf("\nDevice not found \n");;
return -1;
}
- result = nvme_get_log_smart(fd, 0xffffffff, false, &smart_log);
+ result = nvme_get_log_smart(dev_fd(dev), 0xffffffff, false, &smart_log);
if (!result) {
printf("Transcend NVME heath value: ");
percent_used =smart_log.percent_used;
@@ -50,7 +50,7 @@ static int getHealthValue(int argc, char **argv, struct command *cmd, struct plu
}
}
- close(fd);
+ dev_close(dev);
return result;
}
@@ -59,15 +59,16 @@ static int getBadblock(int argc, char **argv, struct command *cmd, struct plugin
{
char *desc = "Get nvme bad block number.";
- int result=0, fd;
+ struct nvme_dev *dev;
+ int result;
OPT_ARGS(opts) = {
OPT_END()
};
- fd = parse_and_open(argc, argv, desc, opts);
- if (fd < 0) {
+ result = parse_and_open(&dev, argc, argv, desc, opts);
+ if (result) {
printf("\nDevice not found \n");;
return -1;
}
@@ -79,11 +80,11 @@ static int getBadblock(int argc, char **argv, struct command *cmd, struct plugin
nvmecmd.cdw12=DW12_BAD_BLOCK;
nvmecmd.addr = (__u64)(uintptr_t)data;
nvmecmd.data_len = 0x1;
- result = nvme_submit_admin_passthru(fd, &nvmecmd, NULL);
+ result = nvme_submit_admin_passthru(dev_fd(dev), &nvmecmd, NULL);
if(!result) {
int badblock = data[0];
printf("Transcend NVME badblock count: %d\n",badblock);
}
- close(fd);
+ dev_close(dev);
return result;
}