--- driver.c~ 2010-05-17 11:51:30.315940940 +0200 +++ driver.c 2010-05-17 11:51:30.362264370 +0200 @@ -48,6 +48,8 @@ #include "defs.h" #include "lib.h" #include "driver.h" +#include +#include /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ @@ -490,39 +492,34 @@ /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ -static int __kcapi ctr_info ( - char * page, - char ** start, - off_t ofs, - int count, - int * eof, - struct capi_ctr * ctrl + +static int __kcapi ctr_info (struct seq_file *m, void *v ) { + struct capi_ctr *ctrl = m->private; card_t * card; char * temp; unsigned char flag; - int len = 0; assert (ctrl != NULL); card = (card_t *) ctrl->driverdata; assert (card != NULL); - pprintf (page, &len, "%-16s %s\n", "name", SHORT_LOGO); - pprintf (page, &len, "%-16s 0x%04x\n", "io", card->base); - pprintf (page, &len, "%-16s %d\n", "irq", card->irq); + seq_printf(m, "%-16s %s\n", "name", SHORT_LOGO); + seq_printf(m, "%-16s 0x%04x\n", "io", card->base); + seq_printf(m, "%-16s %d\n", "irq", card->irq); temp = card->version ? card->string[1] : "A1"; - pprintf (page, &len, "%-16s %s\n", "type", temp); + seq_printf(m, "%-16s %s\n", "type", temp); temp = card->version ? card->string[0] : "-"; #if defined (__fcclassic__) || defined (__fcpcmcia__) - pprintf (page, &len, "%-16s 0x%04x\n", "revision", card->info); + seq_printf(m, "%-16s 0x%04x\n", "revision", card->info); #elif defined (__fcpci__) - pprintf (page, &len, "%-16s %d\n", "class", card_id); + seq_printf(m, "%-16s %d\n", "class", card_id); #endif - pprintf (page, &len, "%-16s %s\n", "ver_driver", temp); - pprintf (page, &len, "%-16s %s\n", "ver_cardtype", SHORT_LOGO); + seq_printf(m, "%-16s %s\n", "ver_driver", temp); + seq_printf(m, "%-16s %s\n", "ver_cardtype", SHORT_LOGO); flag = ((unsigned char *) (ctrl->profile.manu))[3]; if (flag) { - pprintf(page, &len, "%-16s%s%s%s%s%s%s%s\n", "protocol", + seq_printf(m, "%-16s%s%s%s%s%s%s%s\n", "protocol", (flag & 0x01) ? " DSS1" : "", (flag & 0x02) ? " CT1" : "", (flag & 0x04) ? " VN3" : "", @@ -534,21 +531,30 @@ } flag = ((unsigned char *) (ctrl->profile.manu))[5]; if (flag) { - pprintf(page, &len, "%-16s%s%s%s%s\n", "linetype", + seq_printf(m, "%-16s%s%s%s%s\n", "linetype", (flag & 0x01) ? " point to point" : "", (flag & 0x02) ? " point to multipoint" : "", (flag & 0x08) ? " leased line without D-channel" : "", (flag & 0x04) ? " leased line with D-channel" : "" ); } - if (len < ofs) { - return 0; - } - *eof = 1; - *start = page - ofs; - return ((count < len - ofs) ? count : len - ofs); + + return 0; } /* ctr_info */ +static int ctr_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, ctr_info, PDE(inode)->data); +} + +const struct file_operations ctr_proc_fops = { + .owner = THIS_MODULE, + .open = ctr_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + /*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ static void __kcapi reset_ctrl (struct capi_ctr * ctrl) { --- driver.c~ 2010-05-17 19:55:09.158499792 +0200 +++ driver.c 2010-05-17 19:55:09.190784099 +0200 @@ -222,16 +222,6 @@ } /* kill_version */ /*---------------------------------------------------------------------------*\ -\*---------------------------------------------------------------------------*/ -static void pprintf (char * page, int * len, const char * fmt, ...) { - va_list args; - - va_start (args, fmt); - *len += vsprintf (page + *len, fmt, args); - va_end (args); -} /* pprintf */ - -/*---------------------------------------------------------------------------*\ \*-C-------------------------------------------------------------------------*/ static inline int in_critical (void) { @@ -632,7 +622,7 @@ ctrl->release_appl = release_appl; ctrl->send_message = send_msg; ctrl->procinfo = proc_info; - ctrl->ctr_read_proc = ctr_info; + ctrl->proc_fops = &ctr_proc_fops; if (0 != (res = attach_capi_ctr (ctrl))) { dec_use_count (); stop (card);