RDMA/hns: Add write support to debugfs

Add write support to debugfs.

Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Link: https://patch.msgid.link/20260507012148.1079712-3-huangjunxian6@hisilicon.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
Junxian Huang 2026-05-07 09:21:47 +08:00 committed by Leon Romanovsky
parent b407077050
commit bb50659745
2 changed files with 21 additions and 0 deletions

View File

@ -18,11 +18,31 @@ static int hns_debugfs_seqfile_open(struct inode *inode, struct file *f)
return single_open(f, seqfile->read, seqfile->data);
}
static ssize_t hns_debugfs_seqfile_write(struct file *file,
const char __user *buffer,
size_t count, loff_t *ppos)
{
struct hns_debugfs_seqfile *seqfile = file_inode(file)->i_private;
char buf[16] = {};
if (!seqfile->write)
return -EOPNOTSUPP;
if (count >= sizeof(buf))
return -EINVAL;
if (copy_from_user(buf, buffer, count))
return -EFAULT;
return seqfile->write(buf, count, seqfile->data);
}
static const struct file_operations hns_debugfs_seqfile_fops = {
.owner = THIS_MODULE,
.open = hns_debugfs_seqfile_open,
.release = single_release,
.read = seq_read,
.write = hns_debugfs_seqfile_write,
.llseek = seq_lseek
};

View File

@ -9,6 +9,7 @@
/* debugfs seqfile */
struct hns_debugfs_seqfile {
int (*read)(struct seq_file *seq, void *data);
ssize_t (*write)(char *buf, size_t count, void *data);
void *data;
};