Commit c6fb4495 authored by Tejun Heo's avatar Tejun Heo Committed by Greg Kroah-Hartman

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: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fdbffaa4
...@@ -668,7 +668,7 @@ static void sysfs_put_open_dirent(struct sysfs_dirent *sd, ...@@ -668,7 +668,7 @@ static void sysfs_put_open_dirent(struct sysfs_dirent *sd,
kfree(od); kfree(od);
} }
static int sysfs_open_file(struct inode *inode, struct file *file) static int kernfs_file_open(struct inode *inode, struct file *file)
{ {
struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
struct kobject *kobj = attr_sd->s_parent->priv; struct kobject *kobj = attr_sd->s_parent->priv;
...@@ -771,7 +771,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file) ...@@ -771,7 +771,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
return error; return error;
} }
static int sysfs_release(struct inode *inode, struct file *filp) static int kernfs_file_release(struct inode *inode, struct file *filp)
{ {
struct sysfs_dirent *sd = filp->f_path.dentry->d_fsdata; struct sysfs_dirent *sd = filp->f_path.dentry->d_fsdata;
struct sysfs_open_file *of = sysfs_of(filp); struct sysfs_open_file *of = sysfs_of(filp);
...@@ -822,7 +822,7 @@ void sysfs_unmap_bin_file(struct sysfs_dirent *sd) ...@@ -822,7 +822,7 @@ void sysfs_unmap_bin_file(struct sysfs_dirent *sd)
* to see if it supports poll (Neither 'poll' nor 'select' return * to see if it supports poll (Neither 'poll' nor 'select' return
* an appropriate error code). When in doubt, set a suitable timeout value. * an appropriate error code). When in doubt, set a suitable timeout value.
*/ */
static unsigned int sysfs_poll(struct file *filp, poll_table *wait) static unsigned int kernfs_file_poll(struct file *filp, poll_table *wait)
{ {
struct sysfs_open_file *of = sysfs_of(filp); struct sysfs_open_file *of = sysfs_of(filp);
struct sysfs_dirent *attr_sd = filp->f_path.dentry->d_fsdata; 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) ...@@ -881,24 +881,14 @@ void sysfs_notify(struct kobject *k, const char *dir, const char *attr)
} }
EXPORT_SYMBOL_GPL(sysfs_notify); EXPORT_SYMBOL_GPL(sysfs_notify);
const struct file_operations sysfs_file_operations = { const struct file_operations kernfs_file_operations = {
.read = kernfs_file_read, .read = kernfs_file_read,
.write = kernfs_file_write, .write = kernfs_file_write,
.llseek = generic_file_llseek, .llseek = generic_file_llseek,
.mmap = kernfs_file_mmap, .mmap = kernfs_file_mmap,
.open = sysfs_open_file, .open = kernfs_file_open,
.release = sysfs_release, .release = kernfs_file_release,
.poll = sysfs_poll, .poll = kernfs_file_poll,
};
const struct file_operations sysfs_bin_operations = {
.read = kernfs_file_read,
.write = kernfs_file_write,
.llseek = generic_file_llseek,
.mmap = kernfs_file_mmap,
.open = sysfs_open_file,
.release = sysfs_release,
.poll = sysfs_poll,
}; };
int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd, int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd,
......
...@@ -272,12 +272,12 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode) ...@@ -272,12 +272,12 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
break; break;
case SYSFS_KOBJ_ATTR: case SYSFS_KOBJ_ATTR:
inode->i_size = PAGE_SIZE; inode->i_size = PAGE_SIZE;
inode->i_fop = &sysfs_file_operations; inode->i_fop = &kernfs_file_operations;
break; break;
case SYSFS_KOBJ_BIN_ATTR: case SYSFS_KOBJ_BIN_ATTR:
bin_attr = sd->priv; bin_attr = sd->priv;
inode->i_size = bin_attr->size; inode->i_size = bin_attr->size;
inode->i_fop = &sysfs_bin_operations; inode->i_fop = &kernfs_file_operations;
break; break;
case SYSFS_KOBJ_LINK: case SYSFS_KOBJ_LINK:
inode->i_op = &sysfs_symlink_inode_operations; inode->i_op = &sysfs_symlink_inode_operations;
......
...@@ -212,8 +212,7 @@ int sysfs_inode_init(void); ...@@ -212,8 +212,7 @@ int sysfs_inode_init(void);
/* /*
* file.c * file.c
*/ */
extern const struct file_operations sysfs_file_operations; extern const struct file_operations kernfs_file_operations;
extern const struct file_operations sysfs_bin_operations;
int sysfs_add_file(struct sysfs_dirent *dir_sd, int sysfs_add_file(struct sysfs_dirent *dir_sd,
const struct attribute *attr, int type); const struct attribute *attr, int type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment