aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hardware/avm/b1.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2010-01-14 06:10:54 -0500
committerDavid S. Miller <davem@davemloft.net>2010-01-14 06:10:54 -0500
commit9a58a80a701bdb2d220cdab4914218df5b48d781 (patch)
tree01eeb65ec70f22ec326d0938d002cc6a2aec73e8 /drivers/isdn/hardware/avm/b1.c
parent508e14b4a4fb1a824a14f2c5b8d7df67b313f8e4 (diff)
proc_fops: convert drivers/isdn/ to seq_file
Convert code away from ->read_proc/->write_proc interfaces. Switch to proc_create()/proc_create_data() which make addition of proc entries reliable wrt NULL ->proc_fops, NULL ->data and so on. Problem with ->read_proc et al is described here commit 786d7e1612f0b0adb6046f19b906609e4fe8b1ba "Fix rmmod/read/write races in /proc entries" [akpm@linux-foundation.org: CONFIG_PROC_FS=n build fix] Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Tilman Schmidt <tilman@imap.cc> Signed-off-by: Karsten Keil <keil@b1-systems.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/hardware/avm/b1.c')
-rw-r--r--drivers/isdn/hardware/avm/b1.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
index a7c0083e78a7..c38fa0f4c729 100644
--- a/drivers/isdn/hardware/avm/b1.c
+++ b/drivers/isdn/hardware/avm/b1.c
@@ -12,6 +12,8 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/pci.h> 14#include <linux/pci.h>
15#include <linux/proc_fs.h>
16#include <linux/seq_file.h>
15#include <linux/skbuff.h> 17#include <linux/skbuff.h>
16#include <linux/delay.h> 18#include <linux/delay.h>
17#include <linux/mm.h> 19#include <linux/mm.h>
@@ -634,18 +636,17 @@ irqreturn_t b1_interrupt(int interrupt, void *devptr)
634} 636}
635 637
636/* ------------------------------------------------------------- */ 638/* ------------------------------------------------------------- */
637int b1ctl_read_proc(char *page, char **start, off_t off, 639static int b1ctl_proc_show(struct seq_file *m, void *v)
638 int count, int *eof, struct capi_ctr *ctrl)
639{ 640{
641 struct capi_ctr *ctrl = m->private;
640 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); 642 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
641 avmcard *card = cinfo->card; 643 avmcard *card = cinfo->card;
642 u8 flag; 644 u8 flag;
643 int len = 0;
644 char *s; 645 char *s;
645 646
646 len += sprintf(page+len, "%-16s %s\n", "name", card->name); 647 seq_printf(m, "%-16s %s\n", "name", card->name);
647 len += sprintf(page+len, "%-16s 0x%x\n", "io", card->port); 648 seq_printf(m, "%-16s 0x%x\n", "io", card->port);
648 len += sprintf(page+len, "%-16s %d\n", "irq", card->irq); 649 seq_printf(m, "%-16s %d\n", "irq", card->irq);
649 switch (card->cardtype) { 650 switch (card->cardtype) {
650 case avm_b1isa: s = "B1 ISA"; break; 651 case avm_b1isa: s = "B1 ISA"; break;
651 case avm_b1pci: s = "B1 PCI"; break; 652 case avm_b1pci: s = "B1 PCI"; break;
@@ -658,20 +659,20 @@ int b1ctl_read_proc(char *page, char **start, off_t off,
658 case avm_c2: s = "C2"; break; 659 case avm_c2: s = "C2"; break;
659 default: s = "???"; break; 660 default: s = "???"; break;
660 } 661 }
661 len += sprintf(page+len, "%-16s %s\n", "type", s); 662 seq_printf(m, "%-16s %s\n", "type", s);
662 if (card->cardtype == avm_t1isa) 663 if (card->cardtype == avm_t1isa)
663 len += sprintf(page+len, "%-16s %d\n", "cardnr", card->cardnr); 664 seq_printf(m, "%-16s %d\n", "cardnr", card->cardnr);
664 if ((s = cinfo->version[VER_DRIVER]) != NULL) 665 if ((s = cinfo->version[VER_DRIVER]) != NULL)
665 len += sprintf(page+len, "%-16s %s\n", "ver_driver", s); 666 seq_printf(m, "%-16s %s\n", "ver_driver", s);
666 if ((s = cinfo->version[VER_CARDTYPE]) != NULL) 667 if ((s = cinfo->version[VER_CARDTYPE]) != NULL)
667 len += sprintf(page+len, "%-16s %s\n", "ver_cardtype", s); 668 seq_printf(m, "%-16s %s\n", "ver_cardtype", s);
668 if ((s = cinfo->version[VER_SERIAL]) != NULL) 669 if ((s = cinfo->version[VER_SERIAL]) != NULL)
669 len += sprintf(page+len, "%-16s %s\n", "ver_serial", s); 670 seq_printf(m, "%-16s %s\n", "ver_serial", s);
670 671
671 if (card->cardtype != avm_m1) { 672 if (card->cardtype != avm_m1) {
672 flag = ((u8 *)(ctrl->profile.manu))[3]; 673 flag = ((u8 *)(ctrl->profile.manu))[3];
673 if (flag) 674 if (flag)
674 len += sprintf(page+len, "%-16s%s%s%s%s%s%s%s\n", 675 seq_printf(m, "%-16s%s%s%s%s%s%s%s\n",
675 "protocol", 676 "protocol",
676 (flag & 0x01) ? " DSS1" : "", 677 (flag & 0x01) ? " DSS1" : "",
677 (flag & 0x02) ? " CT1" : "", 678 (flag & 0x02) ? " CT1" : "",
@@ -685,7 +686,7 @@ int b1ctl_read_proc(char *page, char **start, off_t off,
685 if (card->cardtype != avm_m1) { 686 if (card->cardtype != avm_m1) {
686 flag = ((u8 *)(ctrl->profile.manu))[5]; 687 flag = ((u8 *)(ctrl->profile.manu))[5];
687 if (flag) 688 if (flag)
688 len += sprintf(page+len, "%-16s%s%s%s%s\n", 689 seq_printf(m, "%-16s%s%s%s%s\n",
689 "linetype", 690 "linetype",
690 (flag & 0x01) ? " point to point" : "", 691 (flag & 0x01) ? " point to point" : "",
691 (flag & 0x02) ? " point to multipoint" : "", 692 (flag & 0x02) ? " point to multipoint" : "",
@@ -693,16 +694,25 @@ int b1ctl_read_proc(char *page, char **start, off_t off,
693 (flag & 0x04) ? " leased line with D-channel" : "" 694 (flag & 0x04) ? " leased line with D-channel" : ""
694 ); 695 );
695 } 696 }
696 len += sprintf(page+len, "%-16s %s\n", "cardname", cinfo->cardname); 697 seq_printf(m, "%-16s %s\n", "cardname", cinfo->cardname);
697 698
698 if (off+count >= len) 699 return 0;
699 *eof = 1; 700}
700 if (len < off) 701
701 return 0; 702static int b1ctl_proc_open(struct inode *inode, struct file *file)
702 *start = page + off; 703{
703 return ((count < len-off) ? count : len-off); 704 return single_open(file, b1ctl_proc_show, PDE(inode)->data);
704} 705}
705 706
707const struct file_operations b1ctl_proc_fops = {
708 .owner = THIS_MODULE,
709 .open = b1ctl_proc_open,
710 .read = seq_read,
711 .llseek = seq_lseek,
712 .release = single_release,
713};
714EXPORT_SYMBOL(b1ctl_proc_fops);
715
706/* ------------------------------------------------------------- */ 716/* ------------------------------------------------------------- */
707 717
708#ifdef CONFIG_PCI 718#ifdef CONFIG_PCI
@@ -781,8 +791,6 @@ EXPORT_SYMBOL(b1_send_message);
781EXPORT_SYMBOL(b1_parse_version); 791EXPORT_SYMBOL(b1_parse_version);
782EXPORT_SYMBOL(b1_interrupt); 792EXPORT_SYMBOL(b1_interrupt);
783 793
784EXPORT_SYMBOL(b1ctl_read_proc);
785
786static int __init b1_init(void) 794static int __init b1_init(void)
787{ 795{
788 char *p; 796 char *p;