*/
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;
}
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;
{
int res;
mode = (mode & S_IALLUGO) | S_IFREG;
- dentry->d_op = &driverfs_dentry_file_ops;
res = driverfs_mknod(dir, dentry, mode, 0);
return res;
}
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,
.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,