summaryrefslogtreecommitdiffstats
path: root/plugins/ocp/ocp-utils.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:11:06 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:11:06 +0000
commita8123060e6717f82ee27efca50c7d2daf4392809 (patch)
tree3b0b740dd83d6a1244e81e4270497ad8db31a9b7 /plugins/ocp/ocp-utils.c
parentAdding debian version 2.8-2. (diff)
downloadnvme-cli-a8123060e6717f82ee27efca50c7d2daf4392809.tar.xz
nvme-cli-a8123060e6717f82ee27efca50c7d2daf4392809.zip
Merging upstream version 2.9.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--plugins/ocp/ocp-utils.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/plugins/ocp/ocp-utils.c b/plugins/ocp/ocp-utils.c
index 1257b30..8a1462e 100644
--- a/plugins/ocp/ocp-utils.c
+++ b/plugins/ocp/ocp-utils.c
@@ -1,19 +1,32 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
- * Copyright (c) 2022 Solidigm.
+ * Copyright (c) 2022-2024 Solidigm.
*
* Author: leonardo.da.cunha@solidigm.com
*/
#include <unistd.h>
+#include <errno.h>
#include "ocp-utils.h"
-#include "nvme-print.h"
const unsigned char ocp_uuid[NVME_UUID_LEN] = {
0xc1, 0x94, 0xd5, 0x5b, 0xe0, 0x94, 0x47, 0x94, 0xa2, 0x1d,
0x29, 0x99, 0x8f, 0x56, 0xbe, 0x6f };
-int ocp_get_uuid_index(struct nvme_dev *dev, int *index)
+int ocp_find_uuid_index(struct nvme_id_uuid_list *uuid_list, __u8 *index)
+{
+ int i = nvme_uuid_find(uuid_list, ocp_uuid);
+
+ *index = 0;
+ if (i > 0)
+ *index = i;
+ else
+ return -errno;
+
+ return 0;
+}
+
+int ocp_get_uuid_index(struct nvme_dev *dev, __u8 *index)
{
struct nvme_id_uuid_list uuid_list;
int err = nvme_identify_uuid(dev_fd(dev), &uuid_list);
@@ -22,11 +35,5 @@ int ocp_get_uuid_index(struct nvme_dev *dev, int *index)
if (err)
return err;
- for (int i = 0; i < NVME_ID_UUID_LIST_MAX; i++) {
- if (memcmp(ocp_uuid, &uuid_list.entry[i].uuid, NVME_UUID_LEN) == 0) {
- *index = i + 1;
- break;
- }
- }
- return err;
+ return ocp_find_uuid_index(&uuid_list, index);
}