Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Documentation/nvme-get-reg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ DESCRIPTION
-----------
Read and show the defined NVMe controller register.

The <device> parameter is mandatory and must be the nvme admin character
device (ex: /dev/nvme0).

OPTIONS
-------
-O <offset>::
Expand Down
3 changes: 3 additions & 0 deletions Documentation/nvme-set-reg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ DESCRIPTION
-----------
Writes and shows the defined NVMe controller register.

The <device> parameter is mandatory and must be the nvme admin character
device (ex: /dev/nvme0).

OPTIONS
-------
-O <offset>::
Expand Down
20 changes: 19 additions & 1 deletion nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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"))
Expand Down