From aec85d96e07f444b7f165216749009ffbb2ae519 Mon Sep 17 00:00:00 2001 From: Steven Seungcheol Lee Date: Sun, 16 Mar 2025 15:07:14 +0900 Subject: [PATCH] nvme: add error message for mmap_registers To indicate that backward compatibility is not supported since we drop the block device fallback Signed-off-by: Steven Seungcheol Lee --- Documentation/nvme-get-reg.txt | 3 +++ Documentation/nvme-set-reg.txt | 3 +++ nvme.c | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Documentation/nvme-get-reg.txt b/Documentation/nvme-get-reg.txt index 5e9cd950..74fe324f 100644 --- a/Documentation/nvme-get-reg.txt +++ b/Documentation/nvme-get-reg.txt @@ -22,6 +22,9 @@ DESCRIPTION ----------- Read and show the defined NVMe controller register. +The parameter is mandatory and must be the nvme admin character +device (ex: /dev/nvme0). + OPTIONS ------- -O :: diff --git a/Documentation/nvme-set-reg.txt b/Documentation/nvme-set-reg.txt index 2978c82a..bd86c3a5 100644 --- a/Documentation/nvme-set-reg.txt +++ b/Documentation/nvme-set-reg.txt @@ -22,6 +22,9 @@ DESCRIPTION ----------- Writes and shows the defined NVMe controller register. +The parameter is mandatory and must be the nvme admin character +device (ex: /dev/nvme0). + OPTIONS ------- -O :: diff --git a/nvme.c b/nvme.c index 0549bf0b..bb412843 100644 --- a/nvme.c +++ b/nvme.c @@ -1113,7 +1113,10 @@ static int get_effects_log(int argc, char **argv, struct command *cmd, struct pl if (cfg.csi < 0) { __u64 cap; - + if (is_blkdev(dev)) { + nvme_show_error("Block device isn't allowed without csi"); + return -EINVAL; + } bar = mmap_registers(dev, false); if (bar) { @@ -5611,6 +5614,11 @@ static int show_registers(int argc, char **argv, struct command *cmd, struct plu if (err) return err; + if (is_blkdev(dev)) { + nvme_show_error("Only character device is allowed"); + return -EINVAL; + } + err = validate_output_format(nvme_cfg.output_format, &flags); if (err < 0) { nvme_show_error("Invalid output format"); @@ -5887,6 +5895,11 @@ static int get_register(int argc, char **argv, struct command *cmd, struct plugi if (err) return err; + if (is_blkdev(dev)) { + nvme_show_error("Only character device is allowed"); + return -EINVAL; + } + err = validate_output_format(nvme_cfg.output_format, &flags); if (err < 0) { nvme_show_error("Invalid output format"); @@ -6191,6 +6204,11 @@ static int set_register(int argc, char **argv, struct command *cmd, struct plugi if (err) return err; + if (is_blkdev(dev)) { + nvme_show_error("Only character device is allowed"); + return -EINVAL; + } + bar = mmap_registers(dev, true); if (argconfig_parse_seen(opts, "offset")) -- 2.50.1