summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorPatrick Mochel <mochel@osdl.org>2002-07-29 22:30:18 -0700
committerPatrick Mochel <mochel@osdl.org>2002-07-29 22:30:18 -0700
commita4a9a623bab07ee0b02e1bfa5cce4f7f625facab (patch)
treead098d42192050e0a92e9c2b565f28525c1c5a64 /fs
parent16d45177bba0b4e3852ad6dc386c71082636d707 (diff)
driverfs: use the parent directory's struct driver_dir_entry (in struct dentry::d_fsdata)
to access the struct device, rather than via struct driver_file_entry::parent pointer.
Diffstat (limited to 'fs')
-rw-r--r--fs/driverfs/inode.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/fs/driverfs/inode.c b/fs/driverfs/inode.c
index 8fa5f4b160e0..899bb2d1c88f 100644
--- a/fs/driverfs/inode.c
+++ b/fs/driverfs/inode.c
@@ -278,10 +278,12 @@ static ssize_t
driverfs_read_file(struct file *file, char *buf, size_t count, loff_t *ppos)
{
struct driver_file_entry * entry;
+ struct driver_dir_entry * dir;
unsigned char *page;
ssize_t retval = 0;
struct device * dev;
+ dir = file->f_dentry->d_parent->d_fsdata;
entry = (struct driver_file_entry *)file->f_dentry->d_fsdata;
if (!entry) {
DBG("%s: file entry is NULL\n",__FUNCTION__);
@@ -293,7 +295,7 @@ driverfs_read_file(struct file *file, char *buf, size_t count, loff_t *ppos)
if (count > PAGE_SIZE)
count = PAGE_SIZE;
- dev = to_device(entry->parent);
+ dev = to_device(dir);
page = (unsigned char*)__get_free_page(GFP_KERNEL);
if (!page)
@@ -342,10 +344,13 @@ static ssize_t
driverfs_write_file(struct file *file, const char *buf, size_t count, loff_t *ppos)
{
struct driver_file_entry * entry;
+ struct driver_dir_entry * dir;
struct device * dev;
ssize_t retval = 0;
char * page;
+ dir = file->f_dentry->d_parent->d_fsdata;
+
entry = (struct driver_file_entry *)file->f_dentry->d_fsdata;
if (!entry) {
DBG("%s: file entry is NULL\n",__FUNCTION__);
@@ -354,7 +359,7 @@ driverfs_write_file(struct file *file, const char *buf, size_t count, loff_t *pp
if (!entry->store)
return 0;
- dev = to_device(entry->parent);
+ dev = to_device(dir);
page = (char *)__get_free_page(GFP_KERNEL);
if (!page)
@@ -414,26 +419,24 @@ driverfs_file_lseek(struct file *file, loff_t offset, int orig)
static int driverfs_open_file(struct inode * inode, struct file * filp)
{
- struct driver_file_entry * entry;
+ struct driver_dir_entry * dir;
struct device * dev;
- entry = (struct driver_file_entry *)filp->f_dentry->d_fsdata;
- if (!entry)
+ dir = (struct driver_dir_entry *)filp->f_dentry->d_parent->d_fsdata;
+ if (!dir)
return -EFAULT;
- dev = to_device(entry->parent);
+ dev = to_device(dir);
get_device(dev);
return 0;
}
static int driverfs_release(struct inode * inode, struct file * filp)
{
- struct driver_file_entry * entry;
+ struct driver_dir_entry * dir;
struct device * dev;
- entry = (struct driver_file_entry *)filp->f_dentry->d_fsdata;
- if (!entry)
- return -EFAULT;
- dev = to_device(entry->parent);
+ dir = (struct driver_dir_entry *)filp->f_dentry->d_parent->d_fsdata;
+ dev = to_device(dir);
put_device(dev);
return 0;
}