Merge branches 'acpi-pm', 'acpi-video', 'acpi-apei' and 'acpi-extlog'
[linux-2.6-microblaze.git] / fs / debugfs / file.c
index 6d7c1a4..c6f4a9a 100644 (file)
@@ -1100,17 +1100,35 @@ static ssize_t read_file_blob(struct file *file, char __user *user_buf,
        return r;
 }
 
+static ssize_t write_file_blob(struct file *file, const char __user *user_buf,
+                              size_t count, loff_t *ppos)
+{
+       struct debugfs_blob_wrapper *blob = file->private_data;
+       struct dentry *dentry = F_DENTRY(file);
+       ssize_t r;
+
+       r = debugfs_file_get(dentry);
+       if (unlikely(r))
+               return r;
+       r = simple_write_to_buffer(blob->data, blob->size, ppos, user_buf,
+                                  count);
+
+       debugfs_file_put(dentry);
+       return r;
+}
+
 static const struct file_operations fops_blob = {
        .read =         read_file_blob,
+       .write =        write_file_blob,
        .open =         simple_open,
        .llseek =       default_llseek,
 };
 
 /**
- * debugfs_create_blob - create a debugfs file that is used to read a binary blob
+ * debugfs_create_blob - create a debugfs file that is used to read and write
+ * a binary blob
  * @name: a pointer to a string containing the name of the file to create.
- * @mode: the read permission that the file should have (other permissions are
- *       masked out)
+ * @mode: the permission that the file should have
  * @parent: a pointer to the parent dentry for this file.  This should be a
  *          directory dentry if set.  If this parameter is %NULL, then the
  *          file will be created in the root of the debugfs filesystem.
@@ -1119,7 +1137,7 @@ static const struct file_operations fops_blob = {
  *
  * This function creates a file in debugfs with the given name that exports
  * @blob->data as a binary blob. If the @mode variable is so set it can be
- * read from. Writing is not supported.
+ * read from and written to.
  *
  * This function will return a pointer to a dentry if it succeeds.  This
  * pointer must be passed to the debugfs_remove() function when the file is
@@ -1134,7 +1152,7 @@ struct dentry *debugfs_create_blob(const char *name, umode_t mode,
                                   struct dentry *parent,
                                   struct debugfs_blob_wrapper *blob)
 {
-       return debugfs_create_file_unsafe(name, mode & 0444, parent, blob, &fops_blob);
+       return debugfs_create_file_unsafe(name, mode & 0644, parent, blob, &fops_blob);
 }
 EXPORT_SYMBOL_GPL(debugfs_create_blob);