]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/sysfs/file.c
SYSFS: Explicitly include required header file slab.h.
[linux-2.6-omap-h63xx.git] / fs / sysfs / file.c
index 8acf82bba44c60c14f46317448c792abd19ceb52..a859c32ff93a56b184c3d7a92ebec776d4d9eaa6 100644 (file)
@@ -12,6 +12,8 @@
 
 #include <linux/module.h>
 #include <linux/kobject.h>
+#include <linux/kallsyms.h>
+#include <linux/slab.h>
 #include <linux/namei.h>
 #include <linux/poll.h>
 #include <linux/list.h>
@@ -86,7 +88,12 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
         * The code works fine with PAGE_SIZE return but it's likely to
         * indicate truncated result or overflow in normal use cases.
         */
-       BUG_ON(count >= (ssize_t)PAGE_SIZE);
+       if (count >= (ssize_t)PAGE_SIZE) {
+               print_symbol("fill_read_buffer: %s returned bad count\n",
+                       (unsigned long)ops->show);
+               /* Try to struggle along */
+               count = PAGE_SIZE - 1;
+       }
        if (count >= 0) {
                buffer->needs_read_fill = 0;
                buffer->count = count;
@@ -523,7 +530,11 @@ int sysfs_add_file_to_group(struct kobject *kobj,
        struct sysfs_dirent *dir_sd;
        int error;
 
-       dir_sd = sysfs_get_dirent(kobj->sd, group);
+       if (group)
+               dir_sd = sysfs_get_dirent(kobj->sd, group);
+       else
+               dir_sd = sysfs_get(kobj->sd);
+
        if (!dir_sd)
                return -ENOENT;
 
@@ -611,7 +622,10 @@ void sysfs_remove_file_from_group(struct kobject *kobj,
 {
        struct sysfs_dirent *dir_sd;
 
-       dir_sd = sysfs_get_dirent(kobj->sd, group);
+       if (group)
+               dir_sd = sysfs_get_dirent(kobj->sd, group);
+       else
+               dir_sd = sysfs_get(kobj->sd);
        if (dir_sd) {
                sysfs_hash_and_remove(dir_sd, attr->name);
                sysfs_put(dir_sd);