From 4ed089396bc7f14bcb94e80f0f9f4757fd8c48b7 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 5 Nov 2022 19:23:30 +0100 Subject: Merging upstream version 2.2.1. Signed-off-by: Daniel Baumann --- plugins/transcend/transcend-nvme.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'plugins/transcend/transcend-nvme.c') 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; } -- cgit v1.2.3