summaryrefslogtreecommitdiffstats
path: root/plugins/solidigm/solidigm-temp-stats.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:08:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:09:05 +0000
commit81e5ef4ae340ae4041f8029e7c14a3bc8baab46d (patch)
tree3b0b740dd83d6a1244e81e4270497ad8db31a9b7 /plugins/solidigm/solidigm-temp-stats.c
parentReleasing debian version 2.8-2. (diff)
downloadnvme-cli-81e5ef4ae340ae4041f8029e7c14a3bc8baab46d.tar.xz
nvme-cli-81e5ef4ae340ae4041f8029e7c14a3bc8baab46d.zip
Merging upstream version 2.9.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/solidigm/solidigm-temp-stats.c')
-rw-r--r--plugins/solidigm/solidigm-temp-stats.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/plugins/solidigm/solidigm-temp-stats.c b/plugins/solidigm/solidigm-temp-stats.c
index 85a3c37..7f385db 100644
--- a/plugins/solidigm/solidigm-temp-stats.c
+++ b/plugins/solidigm/solidigm-temp-stats.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
- * Copyright (c) 2023 Solidigm.
+ * Copyright (c) 2023-2024 Solidigm.
*
* Author: leonardo.da.cunha@solidigm.com
*/
@@ -11,7 +11,8 @@
#include "nvme-print.h"
#include "solidigm-util.h"
-#define SLDGM_TEMP_STATS_LID 0xC5
+#define SLDGM_LEGACY_TEMP_STATS_LID 0xC5
+#define SLDGM_TEMP_STATS_LID 0xD5
struct temp_stats {
__le64 curr;
@@ -40,7 +41,7 @@ static void show_temp_stats(struct temp_stats *stats)
int sldgm_get_temp_stats_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
{
unsigned char buffer[4096] = {0};
- struct nvme_dev *dev;
+ _cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
__u8 uuid_idx;
int err;
@@ -63,7 +64,7 @@ int sldgm_get_temp_stats_log(int argc, char **argv, struct command *cmd, struct
if (err)
return err;
- uuid_idx = solidigm_get_vu_uuid_index(dev);
+ sldgm_get_uuid_index(dev, &uuid_idx);
struct nvme_get_log_args args = {
.lpo = 0,
@@ -84,25 +85,26 @@ int sldgm_get_temp_stats_log(int argc, char **argv, struct command *cmd, struct
};
err = nvme_get_log(&args);
- if (!err) {
- uint64_t *guid = (uint64_t *)&buffer[4080];
+ if (err > 0) {
+ args.lid = SLDGM_LEGACY_TEMP_STATS_LID;
+ err = nvme_get_log(&args);
+ if (!err) {
+ uint64_t *guid = (uint64_t *)&buffer[4080];
- if (guid[1] == 0xC7BB98B7D0324863 && guid[0] == 0xBB2C23990E9C722F) {
- fprintf(stderr, "Error: Log page has 'OCP unsupported Requirements' GUID\n");
- err = -EBADMSG;
- goto closefd;
+ if (guid[1] == 0xC7BB98B7D0324863 && guid[0] == 0xBB2C23990E9C722F) {
+ fprintf(stderr,
+ "Error: Log page has OCP unsupported Requirements GUID\n");
+ return -EBADMSG;
+ }
}
+ }
+ if (!err) {
if (!cfg.raw_binary)
show_temp_stats((struct temp_stats *) buffer);
else
d_raw(buffer, sizeof(struct temp_stats));
- } else if (err > 0) {
+ } else if (err > 0)
nvme_show_status(err);
- }
-closefd:
- /* Redundant close() to make static code analysis happy */
- close(dev->direct.fd);
- dev_close(dev);
return err;
}