From: Tejun Heo <tj@kernel.org>
To: gregkh@linuxfoundation.org
Cc: kay@vrfy.org, linux-kernel@vger.kernel.org,
ebiederm@xmission.com, Tejun Heo <tj@kernel.org>
Subject: [PATCH 06/14] sysfs: add sysfs_open_file->sd and ->file
Date: Sat, 28 Sep 2013 17:49:36 -0400 [thread overview]
Message-ID: <1380404984-31858-7-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1380404984-31858-1-git-send-email-tj@kernel.org>
sysfs will be converted to use seq_file for read path, which will make
it difficult to pass around multiple pointers directly. This patch
adds sysfs_open_file->sd and ->file so that we can reach all the
necessary data structures from sysfs_open_file.
flush_write_buffer() is updated to drop @dentry which was used to
discover the sysfs_dirent as it's now available through
sysfs_open_file->sd.
This patch doesn't cause any behavior difference.
Signed-off-by: Tejun Heo <tj@kernel.org>
---
fs/sysfs/file.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 4b55bcf..af6e909 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -45,6 +45,8 @@ struct sysfs_open_dirent {
};
struct sysfs_open_file {
+ struct sysfs_dirent *sd;
+ struct file *file;
size_t count;
char *page;
struct mutex mutex;
@@ -192,7 +194,6 @@ static int fill_write_buffer(struct sysfs_open_file *of,
/**
* flush_write_buffer - push buffer to kobject.
- * @dentry: dentry to the attribute
* @of: open file
* @count: number of bytes
*
@@ -200,22 +201,20 @@ static int fill_write_buffer(struct sysfs_open_file *of,
* dealing with, then call the store() method for the attribute,
* passing the buffer that we acquired in fill_write_buffer().
*/
-static int flush_write_buffer(struct dentry *dentry,
- struct sysfs_open_file *of, size_t count)
+static int flush_write_buffer(struct sysfs_open_file *of, size_t count)
{
- struct sysfs_dirent *attr_sd = dentry->d_fsdata;
- struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
+ struct kobject *kobj = of->sd->s_parent->s_dir.kobj;
const struct sysfs_ops *ops;
int rc;
- /* need attr_sd for attr and ops, its parent for kobj */
- if (!sysfs_get_active(attr_sd))
+ /* need @of->sd for attr and ops, its parent for kobj */
+ if (!sysfs_get_active(of->sd))
return -ENODEV;
- ops = sysfs_file_ops(attr_sd);
- rc = ops->store(kobj, attr_sd->s_attr.attr, of->page, count);
+ ops = sysfs_file_ops(of->sd);
+ rc = ops->store(kobj, of->sd->s_attr.attr, of->page, count);
- sysfs_put_active(attr_sd);
+ sysfs_put_active(of->sd);
return rc;
}
@@ -245,7 +244,7 @@ static ssize_t sysfs_write_file(struct file *file, const char __user *buf,
mutex_lock(&of->mutex);
len = fill_write_buffer(of, buf, count);
if (len > 0)
- len = flush_write_buffer(file->f_path.dentry, of, len);
+ len = flush_write_buffer(of, len);
if (len > 0)
*ppos += len;
mutex_unlock(&of->mutex);
@@ -385,6 +384,8 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
goto err_out;
mutex_init(&of->mutex);
+ of->sd = attr_sd;
+ of->file = file;
file->private_data = of;
/* make sure we have open dirent struct */
--
1.8.3.1
next prev parent reply other threads:[~2013-09-28 21:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-28 21:49 [PATCHSET] sysfs: use seq_file and unify regular and bin file handling Tejun Heo
2013-09-28 21:49 ` [PATCH 01/14] sysfs: remove unused sysfs_buffer->pos Tejun Heo
2013-09-28 21:49 ` [PATCH 02/14] sysfs: remove sysfs_buffer->needs_read_fill Tejun Heo
2013-09-28 21:49 ` [PATCH 03/14] sysfs: remove sysfs_buffer->ops Tejun Heo
2013-09-28 21:49 ` [PATCH 04/14] sysfs: add sysfs_open_file_mutex Tejun Heo
2013-09-28 21:49 ` [PATCH 05/14] sysfs: rename sysfs_buffer to sysfs_open_file Tejun Heo
2013-09-28 21:49 ` Tejun Heo [this message]
2013-09-28 21:49 ` [PATCH 07/14] sysfs: use transient write buffer Tejun Heo
2013-09-28 21:49 ` [PATCH 08/14] sysfs: use seq_file when reading regular files Tejun Heo
2013-09-28 21:49 ` [PATCH 09/14] sysfs: prepare llseek path for unified regular / bin file handling Tejun Heo
2013-09-28 21:49 ` [PATCH 10/14] sysfs: prepare path write " Tejun Heo
2013-09-28 21:49 ` [PATCH 11/14] sysfs: prepare read path " Tejun Heo
2013-09-28 21:49 ` [PATCH 12/14] sysfs: copy bin mmap support from fs/sysfs/bin.c to fs/sysfs/file.c Tejun Heo
2013-09-28 21:49 ` [PATCH 13/14] sysfs: prepare open path for unified regular / bin file handling Tejun Heo
2013-09-28 21:49 ` [PATCH 14/14] sysfs: merge regular and " Tejun Heo
2013-09-28 22:15 ` [PATCHSET] sysfs: use seq_file and unify " Tejun Heo
2013-09-30 19:54 ` Tejun Heo
2013-09-30 20:14 ` Greg KH
2013-10-01 5:03 ` Bjorn Helgaas
2013-10-01 14:23 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1380404984-31858-7-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=ebiederm@xmission.com \
--cc=gregkh@linuxfoundation.org \
--cc=kay@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome