proc_fops: convert drivers/isdn/ to seq_file
[safe/jmp/linux-2.6] / drivers / isdn / hysdn / hycapi.c
index 4433ce0..fe874af 100644 (file)
@@ -11,6 +11,8 @@
  */
 
 #include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/signal.h>
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
@@ -67,7 +69,7 @@ hycapi_reset_ctr(struct capi_ctr *ctrl)
        printk(KERN_NOTICE "HYCAPI hycapi_reset_ctr\n");
 #endif
        capilib_release(&cinfo->ncci_head);
-       capi_ctr_reseted(ctrl);
+       capi_ctr_down(ctrl);
 }
 
 /******************************
@@ -347,7 +349,7 @@ int hycapi_capi_stop(hysdn_card *card)
        if(cinfo) {
                ctrl = &cinfo->capi_ctrl;
 /*             ctrl->suspend_output(ctrl); */
-               capi_ctr_reseted(ctrl);
+               capi_ctr_down(ctrl);
        }
        return 0;
 }
@@ -399,7 +401,8 @@ static u16 hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
                        if (_len > 22) {
                                _len2 = _len - 22;
                                skb_copy_from_linear_data(skb, msghead, 22);
-                               memcpy(skb->data + _len2, msghead, 22);
+                               skb_copy_to_linear_data_offset(skb, _len2,
+                                                              msghead, 22);
                                skb_pull(skb, _len2);
                                CAPIMSG_SETLEN(skb->data, 22);
                                retval = capilib_data_b3_req(&cinfo->ncci_head,
@@ -431,26 +434,16 @@ static u16 hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
        return retval;
 }
 
-/*********************************************************************
-hycapi_read_proc
-
-Informations provided in the /proc/capi-entries.
-
-*********************************************************************/
-
-static int hycapi_read_proc(char *page, char **start, off_t off,
-                           int count, int *eof, struct capi_ctr *ctrl)
+static int hycapi_proc_show(struct seq_file *m, void *v)
 {
+       struct capi_ctr *ctrl = m->private;
        hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);
        hysdn_card *card = cinfo->card;
-       int len = 0;
        char *s;
-#ifdef HYCAPI_PRINTFNAMES
-       printk(KERN_NOTICE "hycapi_read_proc\n");    
-#endif
-       len += sprintf(page+len, "%-16s %s\n", "name", cinfo->cardname);
-       len += sprintf(page+len, "%-16s 0x%x\n", "io", card->iobase);
-       len += sprintf(page+len, "%-16s %d\n", "irq", card->irq);
+
+       seq_printf(m, "%-16s %s\n", "name", cinfo->cardname);
+       seq_printf(m, "%-16s 0x%x\n", "io", card->iobase);
+       seq_printf(m, "%-16s %d\n", "irq", card->irq);
     
        switch (card->brdtype) {
                case BD_PCCARD:  s = "HYSDN Hycard"; break;
@@ -460,24 +453,32 @@ static int hycapi_read_proc(char *page, char **start, off_t off,
                case BD_PLEXUS: s = "HYSDN Plexus30"; break;
                default: s = "???"; break;
        }
-       len += sprintf(page+len, "%-16s %s\n", "type", s);
-       if ((s = cinfo->version[VER_DRIVER]) != 0)
-               len += sprintf(page+len, "%-16s %s\n", "ver_driver", s);
-       if ((s = cinfo->version[VER_CARDTYPE]) != 0)
-               len += sprintf(page+len, "%-16s %s\n", "ver_cardtype", s);
-       if ((s = cinfo->version[VER_SERIAL]) != 0)
-               len += sprintf(page+len, "%-16s %s\n", "ver_serial", s);
+       seq_printf(m, "%-16s %s\n", "type", s);
+       if ((s = cinfo->version[VER_DRIVER]) != NULL)
+               seq_printf(m, "%-16s %s\n", "ver_driver", s);
+       if ((s = cinfo->version[VER_CARDTYPE]) != NULL)
+               seq_printf(m, "%-16s %s\n", "ver_cardtype", s);
+       if ((s = cinfo->version[VER_SERIAL]) != NULL)
+               seq_printf(m, "%-16s %s\n", "ver_serial", s);
     
-       len += sprintf(page+len, "%-16s %s\n", "cardname", cinfo->cardname);
+       seq_printf(m, "%-16s %s\n", "cardname", cinfo->cardname);
     
-       if (off+count >= len)
-               *eof = 1;
-       if (len < off)
-               return 0;
-       *start = page + off;
-       return ((count < len-off) ? count : len-off);
+       return 0;
+}
+
+static int hycapi_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, hycapi_proc_show, PDE(inode)->data);
 }
 
+static const struct file_operations hycapi_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = hycapi_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 /**************************************************************
 hycapi_load_firmware
 
@@ -540,7 +541,7 @@ hycapi_rx_capipkt(hysdn_card * card, unsigned char *buf, unsigned short len)
        }
        ctrl = &cinfo->capi_ctrl;
        if(len < CAPI_MSG_BASELEN) {
-               printk(KERN_ERR "HYSDN Card%d: invalid CAPI-message, lenght %d!\n",
+               printk(KERN_ERR "HYSDN Card%d: invalid CAPI-message, length %d!\n",
                       card->myid, len);
                return;
        }       
@@ -773,7 +774,7 @@ hycapi_capi_create(hysdn_card *card)
                ctrl->load_firmware = hycapi_load_firmware;
                ctrl->reset_ctr     = hycapi_reset_ctr;
                ctrl->procinfo      = hycapi_procinfo;
-               ctrl->ctr_read_proc = hycapi_read_proc;
+               ctrl->proc_fops = &hycapi_proc_fops;
                strcpy(ctrl->name, cinfo->cardname);
                ctrl->owner = THIS_MODULE;