]> git.neil.brown.name Git - history.git/commitdiff
driverfs: don't dynamically allocate and duplicate struct driver_file_entry's any...
authorPatrick Mochel <mochel@osdl.org>
Tue, 30 Jul 2002 12:14:39 +0000 (05:14 -0700)
committerPatrick Mochel <mochel@osdl.org>
Tue, 30 Jul 2002 12:14:39 +0000 (05:14 -0700)
Now that all unique information about struct driver_file_entry's are gone (the dentry and parent pointers),
the data in them is shared among all users of the entry. So, we don't have any reason to dynamically allocate
and duplicate the data anymore.

drivers/base/fs.c
fs/driverfs/inode.c

index e1cc14f6ff94cbb2ac0a8dffd4b9e6c589119a4c..52da49ce04502e1a1330290b3bb5317fe78b1218 100644 (file)
@@ -26,23 +26,13 @@ extern struct driver_file_entry * device_default_files[];
  */
 int device_create_file(struct device * dev, struct driver_file_entry * entry)
 {
-       struct driver_file_entry * new_entry;
-       int error = -ENOMEM;
+       int error = -EINVAL;
 
-       if (!dev)
-               return -EINVAL;
-       get_device(dev);
-
-       new_entry = kmalloc(sizeof(*new_entry),GFP_KERNEL);
-       if (!new_entry)
-               goto done;
-
-       memcpy(new_entry,entry,sizeof(*entry));
-       error = driverfs_create_file(new_entry,&dev->dir);
-       if (error)
-               kfree(new_entry);
- done:
-       put_device(dev);
+       if (dev) {
+               get_device(dev);
+               error = driverfs_create_file(entry,&dev->dir);
+               put_device(dev);
+       }
        return error;
 }
 
index b9f71fc94e8532a3f92b10ccd57b20d0c9504fae..10b028ea0f3d4fa4eee48a097a6d8ef227273294 100644 (file)
@@ -50,7 +50,6 @@
 static struct super_operations driverfs_ops;
 static struct file_operations driverfs_file_operations;
 static struct inode_operations driverfs_dir_inode_operations;
-static struct dentry_operations driverfs_dentry_file_ops;
 static struct address_space_operations driverfs_aops;
 
 static struct vfsmount *driverfs_mount;
@@ -161,7 +160,6 @@ static int driverfs_create(struct inode *dir, struct dentry *dentry, int mode)
 {
        int res;
        mode = (mode & S_IALLUGO) | S_IFREG;
-       dentry->d_op = &driverfs_dentry_file_ops;
        res = driverfs_mknod(dir, dentry, mode, 0);
        return res;
 }
@@ -441,16 +439,6 @@ static int driverfs_release(struct inode * inode, struct file * filp)
        return 0;
 }
 
-static int driverfs_d_delete_file (struct dentry * dentry)
-{
-       struct driver_file_entry * entry;
-
-       entry = (struct driver_file_entry *)dentry->d_fsdata;
-       if (entry)
-               kfree(entry);
-       return 0;
-}
-
 static struct file_operations driverfs_file_operations = {
        .read           = driverfs_read_file,
        .write          = driverfs_write_file,
@@ -470,10 +458,6 @@ static struct address_space_operations driverfs_aops = {
        .commit_write   = driverfs_commit_write
 };
 
-static struct dentry_operations driverfs_dentry_file_ops = {
-       .d_delete       = driverfs_d_delete_file,
-};
-
 static struct super_operations driverfs_ops = {
        .statfs         = simple_statfs,
        .drop_inode     = generic_delete_inode,