Commit a4a9a623 authored by Patrick Mochel's avatar Patrick Mochel

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.
parent 16d45177
...@@ -278,10 +278,12 @@ static ssize_t ...@@ -278,10 +278,12 @@ static ssize_t
driverfs_read_file(struct file *file, char *buf, size_t count, loff_t *ppos) driverfs_read_file(struct file *file, char *buf, size_t count, loff_t *ppos)
{ {
struct driver_file_entry * entry; struct driver_file_entry * entry;
struct driver_dir_entry * dir;
unsigned char *page; unsigned char *page;
ssize_t retval = 0; ssize_t retval = 0;
struct device * dev; struct device * dev;
dir = file->f_dentry->d_parent->d_fsdata;
entry = (struct driver_file_entry *)file->f_dentry->d_fsdata; entry = (struct driver_file_entry *)file->f_dentry->d_fsdata;
if (!entry) { if (!entry) {
DBG("%s: file entry is NULL\n",__FUNCTION__); 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) ...@@ -293,7 +295,7 @@ driverfs_read_file(struct file *file, char *buf, size_t count, loff_t *ppos)
if (count > PAGE_SIZE) if (count > PAGE_SIZE)
count = PAGE_SIZE; count = PAGE_SIZE;
dev = to_device(entry->parent); dev = to_device(dir);
page = (unsigned char*)__get_free_page(GFP_KERNEL); page = (unsigned char*)__get_free_page(GFP_KERNEL);
if (!page) if (!page)
...@@ -342,10 +344,13 @@ static ssize_t ...@@ -342,10 +344,13 @@ static ssize_t
driverfs_write_file(struct file *file, const char *buf, size_t count, loff_t *ppos) driverfs_write_file(struct file *file, const char *buf, size_t count, loff_t *ppos)
{ {
struct driver_file_entry * entry; struct driver_file_entry * entry;
struct driver_dir_entry * dir;
struct device * dev; struct device * dev;
ssize_t retval = 0; ssize_t retval = 0;
char * page; char * page;
dir = file->f_dentry->d_parent->d_fsdata;
entry = (struct driver_file_entry *)file->f_dentry->d_fsdata; entry = (struct driver_file_entry *)file->f_dentry->d_fsdata;
if (!entry) { if (!entry) {
DBG("%s: file entry is NULL\n",__FUNCTION__); 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 ...@@ -354,7 +359,7 @@ driverfs_write_file(struct file *file, const char *buf, size_t count, loff_t *pp
if (!entry->store) if (!entry->store)
return 0; return 0;
dev = to_device(entry->parent); dev = to_device(dir);
page = (char *)__get_free_page(GFP_KERNEL); page = (char *)__get_free_page(GFP_KERNEL);
if (!page) if (!page)
...@@ -414,26 +419,24 @@ driverfs_file_lseek(struct file *file, loff_t offset, int orig) ...@@ -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) static int driverfs_open_file(struct inode * inode, struct file * filp)
{ {
struct driver_file_entry * entry; struct driver_dir_entry * dir;
struct device * dev; struct device * dev;
entry = (struct driver_file_entry *)filp->f_dentry->d_fsdata; dir = (struct driver_dir_entry *)filp->f_dentry->d_parent->d_fsdata;
if (!entry) if (!dir)
return -EFAULT; return -EFAULT;
dev = to_device(entry->parent); dev = to_device(dir);
get_device(dev); get_device(dev);
return 0; return 0;
} }
static int driverfs_release(struct inode * inode, struct file * filp) static int driverfs_release(struct inode * inode, struct file * filp)
{ {
struct driver_file_entry * entry; struct driver_dir_entry * dir;
struct device * dev; struct device * dev;
entry = (struct driver_file_entry *)filp->f_dentry->d_fsdata; dir = (struct driver_dir_entry *)filp->f_dentry->d_parent->d_fsdata;
if (!entry) dev = to_device(dir);
return -EFAULT;
dev = to_device(entry->parent);
put_device(dev); put_device(dev);
return 0; return 0;
} }
......
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