[PATCH v4 6/7] nvme-tcp: Allow userspace to trigger a KeyUpdate with debugfs
Christoph Hellwig
hch at lst.de
Thu Oct 16 21:31:57 PDT 2025
On Fri, Oct 17, 2025 at 02:23:11PM +1000, alistair23 at gmail.com wrote:
> +#ifdef CONFIG_NVME_TCP_TLS
> +#define NVME_DEBUGFS_RW_ATTR(field) \
> + static int field##_open(struct inode *inode, struct file *file) \
> + { return single_open(file, field##_show, inode->i_private); } \
Please use normal indentation in the macro, but do not add an extra
level of indentation just for being inside a macro.
Then again the macro is only used once anyway, so why add it at all?
> +static ssize_t nvme_ctrl_key_update_write(struct file *file, const char __user *buf,
Please avoid the overly long line.
> + size_t count, loff_t *ppos)
> +{
> + struct seq_file *m = file->private_data;
> + struct nvme_ctrl *nctrl = m->private;
> + struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl);
> + char kbuf[16] = {0};
> + int queue_nr, rc;
> + struct nvme_tcp_queue *queue;
> +
> + if (count > sizeof(kbuf) - 1)
> + return -EINVAL;
> + if (copy_from_user(kbuf, buf, count))
> + return -EFAULT;
> + kbuf[count] = 0;
> +
> + rc = kstrtouint(kbuf, 10, &queue_nr);
> + if (rc)
> + return rc;
kstrtoint_from_user?
More information about the Linux-nvme
mailing list