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
786d7e1612
"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>
此提交包含在:
@@ -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>
|
||||
@@ -432,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;
|
||||
@@ -461,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);
|
||||
seq_printf(m, "%-16s %s\n", "type", s);
|
||||
if ((s = cinfo->version[VER_DRIVER]) != NULL)
|
||||
len += sprintf(page+len, "%-16s %s\n", "ver_driver", s);
|
||||
seq_printf(m, "%-16s %s\n", "ver_driver", s);
|
||||
if ((s = cinfo->version[VER_CARDTYPE]) != NULL)
|
||||
len += sprintf(page+len, "%-16s %s\n", "ver_cardtype", s);
|
||||
seq_printf(m, "%-16s %s\n", "ver_cardtype", s);
|
||||
if ((s = cinfo->version[VER_SERIAL]) != NULL)
|
||||
len += sprintf(page+len, "%-16s %s\n", "ver_serial", s);
|
||||
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
|
||||
|
||||
@@ -774,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;
|
||||
|
||||
|
新增問題並參考
封鎖使用者