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>
This commit is contained in:
committed by
David S. Miller
parent
508e14b4a4
commit
9a58a80a70
@@ -21,7 +21,8 @@
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/kernel.h>
|
||||
@@ -516,33 +517,37 @@ static char *cmtp_procinfo(struct capi_ctr *ctrl)
|
||||
return "CAPI Message Transport Protocol";
|
||||
}
|
||||
|
||||
static int cmtp_ctr_read_proc(char *page, char **start, off_t off, int count, int *eof, struct capi_ctr *ctrl)
|
||||
static int cmtp_proc_show(struct seq_file *m, void *v)
|
||||
{
|
||||
struct capi_ctr *ctrl = m->private;
|
||||
struct cmtp_session *session = ctrl->driverdata;
|
||||
struct cmtp_application *app;
|
||||
struct list_head *p, *n;
|
||||
int len = 0;
|
||||
|
||||
len += sprintf(page + len, "%s\n\n", cmtp_procinfo(ctrl));
|
||||
len += sprintf(page + len, "addr %s\n", session->name);
|
||||
len += sprintf(page + len, "ctrl %d\n", session->num);
|
||||
seq_printf(m, "%s\n\n", cmtp_procinfo(ctrl));
|
||||
seq_printf(m, "addr %s\n", session->name);
|
||||
seq_printf(m, "ctrl %d\n", session->num);
|
||||
|
||||
list_for_each_safe(p, n, &session->applications) {
|
||||
app = list_entry(p, struct cmtp_application, list);
|
||||
len += sprintf(page + len, "appl %d -> %d\n", app->appl, app->mapping);
|
||||
seq_printf(m, "appl %d -> %d\n", app->appl, app->mapping);
|
||||
}
|
||||
|
||||
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 cmtp_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, cmtp_proc_show, PDE(inode)->data);
|
||||
}
|
||||
|
||||
static const struct file_operations cmtp_proc_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = cmtp_proc_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
int cmtp_attach_device(struct cmtp_session *session)
|
||||
{
|
||||
@@ -582,7 +587,7 @@ int cmtp_attach_device(struct cmtp_session *session)
|
||||
session->ctrl.send_message = cmtp_send_message;
|
||||
|
||||
session->ctrl.procinfo = cmtp_procinfo;
|
||||
session->ctrl.ctr_read_proc = cmtp_ctr_read_proc;
|
||||
session->ctrl.proc_fops = &cmtp_proc_fops;
|
||||
|
||||
if (attach_capi_ctr(&session->ctrl) < 0) {
|
||||
BT_ERR("Can't attach new controller");
|
||||
|
Reference in New Issue
Block a user