summaryrefslogtreecommitdiff
path: root/fs/debugfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/debugfs')
-rw-r--r--fs/debugfs/file.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 2340f6978d6e..a09d3c0aad68 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -526,12 +526,6 @@ struct array_data {
u32 elements;
};
-static int u32_array_open(struct inode *inode, struct file *file)
-{
- file->private_data = NULL;
- return nonseekable_open(inode, file);
-}
-
static size_t format_array(char *buf, size_t bufsize, const char *fmt,
u32 *array, u32 array_size)
{
@@ -573,26 +567,21 @@ static char *format_array_alloc(const char *fmt, u32 *array,
return ret;
}
-static ssize_t u32_array_read(struct file *file, char __user *buf, size_t len,
- loff_t *ppos)
+static int u32_array_open(struct inode *inode, struct file *file)
{
- struct inode *inode = file->f_path.dentry->d_inode;
struct array_data *data = inode->i_private;
- size_t size;
- if (*ppos == 0) {
- if (file->private_data) {
- kfree(file->private_data);
- file->private_data = NULL;
- }
-
- file->private_data = format_array_alloc("%u", data->array,
- data->elements);
- }
+ file->private_data = format_array_alloc("%u", data->array,
+ data->elements);
+ if (!file->private_data)
+ return -ENOMEM;
+ return nonseekable_open(inode, file);
+}
- size = 0;
- if (file->private_data)
- size = strlen(file->private_data);
+static ssize_t u32_array_read(struct file *file, char __user *buf, size_t len,
+ loff_t *ppos)
+{
+ size_t size = strlen(file->private_data);
return simple_read_from_buffer(buf, len, ppos,
file->private_data, size);