proc_fops: convert drivers/isdn/ to seq_file
[safe/jmp/linux-2.6] / drivers / isdn / hardware / eicon / capimain.c
index 98fcdfc..0f073cd 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
+#include <linux/seq_file.h>
 #include <linux/skbuff.h>
 
 #include "os_capi.h"
@@ -75,25 +76,32 @@ void diva_os_free_message_buffer(diva_os_message_buffer_s * dmb)
 /*
  * proc function for controller info
  */
-static int diva_ctl_read_proc(char *page, char **start, off_t off,
-                             int count, int *eof, struct capi_ctr *ctrl)
+static int diva_ctl_proc_show(struct seq_file *m, void *v)
 {
+       struct capi_ctr *ctrl = m->private;
        diva_card *card = (diva_card *) ctrl->driverdata;
-       int len = 0;
-
-       len += sprintf(page + len, "%s\n", ctrl->name);
-       len += sprintf(page + len, "Serial No. : %s\n", ctrl->serial);
-       len += sprintf(page + len, "Id         : %d\n", card->Id);
-       len += sprintf(page + len, "Channels   : %d\n", card->d.channels);
-
-       if (off + count >= len)
-               *eof = 1;
-       if (len < off)
-               return 0;
-       *start = page + off;
-       return ((count < len - off) ? count : len - off);
+
+       seq_printf(m, "%s\n", ctrl->name);
+       seq_printf(m, "Serial No. : %s\n", ctrl->serial);
+       seq_printf(m, "Id         : %d\n", card->Id);
+       seq_printf(m, "Channels   : %d\n", card->d.channels);
+
+       return 0;
+}
+
+static int diva_ctl_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, diva_ctl_proc_show, NULL);
 }
 
+static const struct file_operations diva_ctl_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = diva_ctl_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 /*
  * set additional os settings in capi_ctr struct
  */
@@ -102,7 +110,7 @@ void diva_os_set_controller_struct(struct capi_ctr *ctrl)
        ctrl->driver_name = DRIVERLNAME;
        ctrl->load_firmware = NULL;
        ctrl->reset_ctr = NULL;
-       ctrl->ctr_read_proc = diva_ctl_read_proc;
+       ctrl->proc_fops = &diva_ctl_proc_fops;
        ctrl->owner = THIS_MODULE;
 }