mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
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:
parent
b407077050
commit
bb50659745
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user