These changes are to replace the hardcoded SEL values.
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
const char *nvme_select_to_string(int sel)
{
switch (sel) {
- case 0: return "Current";
- case 1: return "Default";
- case 2: return "Saved";
- case 3: return "Supported capabilities";
- case 8: return "Changed";
- default: return "Reserved";
+ case NVME_GET_FEATURES_SEL_CURRENT:
+ return "Current";
+ case NVME_GET_FEATURES_SEL_DEFAULT:
+ return "Default";
+ case NVME_GET_FEATURES_SEL_SAVED:
+ return "Saved";
+ case NVME_GET_FEATURES_SEL_SUPPORTED:
+ return "Supported capabilities";
+ case NVME_GET_FEATURES_SEL_CHANGED:
+ return "Changed";
+ default:
+ break;
}
+ return "Reserved";
}
void nvme_show_select_result(enum nvme_features_id fid, __u32 result)
_cleanup_free_ void *buf_def = NULL;
if (changed)
- cfg.sel = 0;
+ cfg.sel = NVME_GET_FEATURES_SEL_CURRENT;
err = get_feature_id(dev, &cfg, &buf, &result);
if (!err && changed) {
- cfg.sel = 1;
+ cfg.sel = NVME_GET_FEATURES_SEL_DEFAULT;
err_def = get_feature_id(dev, &cfg, &buf_def, &result_def);
}
if (changed)
- cfg.sel = 8;
+ cfg.sel = NVME_GET_FEATURES_SEL_CHANGED;
if (err || !changed || err_def || result != result_def ||
(buf && buf_def && !strcmp(buf, buf_def)))
int status = 0;
enum nvme_status_type type = NVME_STATUS_TYPE_NVME;
- if (cfg.sel == 8)
+ if (cfg.sel == NVME_GET_FEATURES_SEL_CHANGED)
changed = true;
if (cfg.feature_id)
struct feat_cfg cfg = {
.feature_id = 0,
.namespace_id = 0,
- .sel = 0,
+ .sel = NVME_GET_FEATURES_SEL_CURRENT,
.data_len = 0,
.raw_binary = false,
.cdw11 = 0,
}
}
- if (cfg.sel > 8) {
+ if (cfg.sel > NVME_GET_FEATURES_SEL_CHANGED) {
nvme_show_error("invalid 'select' param:%d", cfg.sel);
return -EINVAL;
}
OPT_END() \
}
+#define NVME_GET_FEATURES_SEL_CHANGED 8
+
static inline int __dev_fd(struct nvme_dev *dev, const char *func, int line)
{
if (dev->type != NVME_DEV_DIRECT) {