Skip to content

Commit c6fb449

Browse files
htejungregkh
authored andcommitted
sysfs, kernfs: prepare open, release, poll paths for kernfs
We're in the process of separating out core sysfs functionality into kernfs which will deal with sysfs_dirents directly. This patch prepares the rest - open, release and poll. There isn't much to do. Just renaming is enough. As sysfs_file_operations and sysfs_bin_operations are identical now, use the same file_operations for both - kernfs_file_operations. This patch doesn't introduce any behavior changes. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fdbffaa commit c6fb449

3 files changed

Lines changed: 10 additions & 21 deletions

File tree

‎fs/sysfs/file.c‎

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ static void sysfs_put_open_dirent(struct sysfs_dirent *sd,
668668
kfree(od);
669669
}
670670

671-
static int sysfs_open_file(struct inode *inode, struct file *file)
671+
static int kernfs_file_open(struct inode *inode, struct file *file)
672672
{
673673
struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
674674
struct kobject *kobj = attr_sd->s_parent->priv;
@@ -771,7 +771,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
771771
return error;
772772
}
773773

774-
static int sysfs_release(struct inode *inode, struct file *filp)
774+
static int kernfs_file_release(struct inode *inode, struct file *filp)
775775
{
776776
struct sysfs_dirent *sd = filp->f_path.dentry->d_fsdata;
777777
struct sysfs_open_file *of = sysfs_of(filp);
@@ -822,7 +822,7 @@ void sysfs_unmap_bin_file(struct sysfs_dirent *sd)
822822
* to see if it supports poll (Neither 'poll' nor 'select' return
823823
* an appropriate error code). When in doubt, set a suitable timeout value.
824824
*/
825-
static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
825+
static unsigned int kernfs_file_poll(struct file *filp, poll_table *wait)
826826
{
827827
struct sysfs_open_file *of = sysfs_of(filp);
828828
struct sysfs_dirent *attr_sd = filp->f_path.dentry->d_fsdata;
@@ -881,24 +881,14 @@ void sysfs_notify(struct kobject *k, const char *dir, const char *attr)
881881
}
882882
EXPORT_SYMBOL_GPL(sysfs_notify);
883883

884-
const struct file_operations sysfs_file_operations = {
884+
const struct file_operations kernfs_file_operations = {
885885
.read = kernfs_file_read,
886886
.write = kernfs_file_write,
887887
.llseek = generic_file_llseek,
888888
.mmap = kernfs_file_mmap,
889-
.open = sysfs_open_file,
890-
.release = sysfs_release,
891-
.poll = sysfs_poll,
892-
};
893-
894-
const struct file_operations sysfs_bin_operations = {
895-
.read = kernfs_file_read,
896-
.write = kernfs_file_write,
897-
.llseek = generic_file_llseek,
898-
.mmap = kernfs_file_mmap,
899-
.open = sysfs_open_file,
900-
.release = sysfs_release,
901-
.poll = sysfs_poll,
889+
.open = kernfs_file_open,
890+
.release = kernfs_file_release,
891+
.poll = kernfs_file_poll,
902892
};
903893

904894
int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd,

‎fs/sysfs/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,12 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
272272
break;
273273
case SYSFS_KOBJ_ATTR:
274274
inode->i_size = PAGE_SIZE;
275-
inode->i_fop = &sysfs_file_operations;
275+
inode->i_fop = &kernfs_file_operations;
276276
break;
277277
case SYSFS_KOBJ_BIN_ATTR:
278278
bin_attr = sd->priv;
279279
inode->i_size = bin_attr->size;
280-
inode->i_fop = &sysfs_bin_operations;
280+
inode->i_fop = &kernfs_file_operations;
281281
break;
282282
case SYSFS_KOBJ_LINK:
283283
inode->i_op = &sysfs_symlink_inode_operations;

‎fs/sysfs/sysfs.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ int sysfs_inode_init(void);
212212
/*
213213
* file.c
214214
*/
215-
extern const struct file_operations sysfs_file_operations;
216-
extern const struct file_operations sysfs_bin_operations;
215+
extern const struct file_operations kernfs_file_operations;
217216

218217
int sysfs_add_file(struct sysfs_dirent *dir_sd,
219218
const struct attribute *attr, int type);

0 commit comments

Comments
 (0)