Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 211913
b: refs/heads/master
c: 4fdaa7b
h: refs/heads/master
i:
  211911: 2010597
v: v3
  • Loading branch information
Robert Richter committed Oct 4, 2010
1 parent 032d30e commit 96e505f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dc0c22b878a60373762495b8e5628a32c1b80ac4
refs/heads/master: 4fdaa7b682b413dfb7ca9fa74ff45b1e0cb3dade
46 changes: 14 additions & 32 deletions trunk/drivers/oprofile/oprofilefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,50 +126,41 @@ static const struct file_operations ulong_ro_fops = {
};


static struct dentry *__oprofilefs_create_file(struct super_block *sb,
static int __oprofilefs_create_file(struct super_block *sb,
struct dentry *root, char const *name, const struct file_operations *fops,
int perm)
int perm, void *priv)
{
struct dentry *dentry;
struct inode *inode;

dentry = d_alloc_name(root, name);
if (!dentry)
return NULL;
return -ENOMEM;
inode = oprofilefs_get_inode(sb, S_IFREG | perm);
if (!inode) {
dput(dentry);
return NULL;
return -ENOMEM;
}
inode->i_fop = fops;
d_add(dentry, inode);
return dentry;
dentry->d_inode->i_private = priv;
return 0;
}


int oprofilefs_create_ulong(struct super_block *sb, struct dentry *root,
char const *name, unsigned long *val)
{
struct dentry *d = __oprofilefs_create_file(sb, root, name,
&ulong_fops, 0644);
if (!d)
return -EFAULT;

d->d_inode->i_private = val;
return 0;
return __oprofilefs_create_file(sb, root, name,
&ulong_fops, 0644, val);
}


int oprofilefs_create_ro_ulong(struct super_block *sb, struct dentry *root,
char const *name, unsigned long *val)
{
struct dentry *d = __oprofilefs_create_file(sb, root, name,
&ulong_ro_fops, 0444);
if (!d)
return -EFAULT;

d->d_inode->i_private = val;
return 0;
return __oprofilefs_create_file(sb, root, name,
&ulong_ro_fops, 0444, val);
}


Expand All @@ -189,31 +180,22 @@ static const struct file_operations atomic_ro_fops = {
int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
char const *name, atomic_t *val)
{
struct dentry *d = __oprofilefs_create_file(sb, root, name,
&atomic_ro_fops, 0444);
if (!d)
return -EFAULT;

d->d_inode->i_private = val;
return 0;
return __oprofilefs_create_file(sb, root, name,
&atomic_ro_fops, 0444, val);
}


int oprofilefs_create_file(struct super_block *sb, struct dentry *root,
char const *name, const struct file_operations *fops)
{
if (!__oprofilefs_create_file(sb, root, name, fops, 0644))
return -EFAULT;
return 0;
return __oprofilefs_create_file(sb, root, name, fops, 0644, NULL);
}


int oprofilefs_create_file_perm(struct super_block *sb, struct dentry *root,
char const *name, const struct file_operations *fops, int perm)
{
if (!__oprofilefs_create_file(sb, root, name, fops, perm))
return -EFAULT;
return 0;
return __oprofilefs_create_file(sb, root, name, fops, perm, NULL);
}


Expand Down

0 comments on commit 96e505f

Please sign in to comment.