]> err.no Git - linux-2.6/blobdiff - drivers/video/fbmem.c
mac80211: fix an oops in several failure paths in key allocation
[linux-2.6] / drivers / video / fbmem.c
index 279c2dbef8f8cbca800f1ec9babe06423da727e2..776f7fcd2fbf4f508a0bb72398391aeb8f5a32d0 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/init.h>
 #include <linux/linux_logo.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/console.h>
 #ifdef CONFIG_KMOD
 #include <linux/kmod.h>
@@ -632,27 +633,51 @@ int fb_prepare_logo(struct fb_info *info, int rotate) { return 0; }
 int fb_show_logo(struct fb_info *info, int rotate) { return 0; }
 #endif /* CONFIG_LOGO */
 
-static int fbmem_read_proc(char *buf, char **start, off_t offset,
-                          int len, int *eof, void *private)
+static void *fb_seq_start(struct seq_file *m, loff_t *pos)
 {
-       struct fb_info **fi;
-       int clen;
-
-       clen = 0;
-       for (fi = registered_fb; fi < &registered_fb[FB_MAX] && clen < 4000;
-            fi++)
-               if (*fi)
-                       clen += sprintf(buf + clen, "%d %s\n",
-                                       (*fi)->node,
-                                       (*fi)->fix.id);
-       *start = buf + offset;
-       if (clen > offset)
-               clen -= offset;
-       else
-               clen = 0;
-       return clen < len ? clen : len;
+       return (*pos < FB_MAX) ? pos : NULL;
+}
+
+static void *fb_seq_next(struct seq_file *m, void *v, loff_t *pos)
+{
+       (*pos)++;
+       return (*pos < FB_MAX) ? pos : NULL;
+}
+
+static void fb_seq_stop(struct seq_file *m, void *v)
+{
+}
+
+static int fb_seq_show(struct seq_file *m, void *v)
+{
+       int i = *(loff_t *)v;
+       struct fb_info *fi = registered_fb[i];
+
+       if (fi)
+               seq_printf(m, "%d %s\n", fi->node, fi->fix.id);
+       return 0;
+}
+
+static const struct seq_operations proc_fb_seq_ops = {
+       .start  = fb_seq_start,
+       .next   = fb_seq_next,
+       .stop   = fb_seq_stop,
+       .show   = fb_seq_show,
+};
+
+static int proc_fb_open(struct inode *inode, struct file *file)
+{
+       return seq_open(file, &proc_fb_seq_ops);
 }
 
+static const struct file_operations fb_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = proc_fb_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = seq_release,
+};
+
 static ssize_t
 fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 {
@@ -1057,7 +1082,7 @@ fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
        case FBIOPUT_CON2FBMAP:
                if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
                        return - EFAULT;
-               if (con2fb.console < 0 || con2fb.console > MAX_NR_CONSOLES)
+               if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
                    return -EINVAL;
                if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
                    return -EINVAL;
@@ -1533,7 +1558,7 @@ void fb_set_suspend(struct fb_info *info, int state)
 static int __init
 fbmem_init(void)
 {
-       create_proc_read_entry("fb", 0, NULL, fbmem_read_proc, NULL);
+       proc_create("fb", 0, NULL, &fb_proc_fops);
 
        if (register_chrdev(FB_MAJOR,"fb",&fb_fops))
                printk("unable to get major %d for fb devs\n", FB_MAJOR);