: Use proc_create() to setup ->proc_fops first
Subsystems (2)
PATCH 6/15 : Use proc_create() to setup ->proc_fops first
Use proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree.
--- net/irda/ircomm/ircomm_core.c | 7 ++----- net/irda/irlan/irlan_common.c | 7 ++----- net/irda/irproc.c | 8 +++----- 3 files changed, 7 insertions(+), 15 deletions(-)
net/irda/ircomm/ircomm_core.c +2 -5
@@ -75,11 +75,8 @@ static int __init ircomm_init(void) }#ifdef CONFIG_PROC_FS - {struct proc_dir_entry *ent; - ent =create_proc_entry ("ircomm" ,0 , proc_irda); -if (ent) - ent->proc_fops = &ircomm_proc_fops; - } +struct proc_dir_entry *ent; + ent =proc_create ("ircomm" ,0 , proc_irda, &ircomm_proc_fops);#endif /* CONFIG_PROC_FS */ IRDA_MESSAGE ("IrCOMM protocol (Dag Brattli)\n" );
net/irda/irlan/irlan_common.c +2 -5
@@ -127,15 +127,12 @@ static int __init irlan_init(void)IRDA_DEBUG (2 ,"%s()\n" , __FUNCTION__ );#ifdef CONFIG_PROC_FS - {struct proc_dir_entry *proc; - proc =create_proc_entry ("irlan" ,0 , proc_irda); +struct proc_dir_entry *proc; + proc =proc_create ("irlan" ,0 , proc_irda, &irlan_fops);if (!proc) {printk (KERN_ERR "irlan_init: can't create /proc entry!\n" );return -ENODEV ; } - - proc->proc_fops = &irlan_fops; - }#endif /* CONFIG_PROC_FS */ IRDA_DEBUG (4 ,"%s()\n" , __FUNCTION__ );
net/irda/irproc.c +3 -5
@@ -72,11 +72,9 @@ void __init irda_proc_register(void)return ; proc_irda->owner =THIS_MODULE ; -for (i=0 ; i<ARRAY_SIZE (irda_dirs); i++) { - d =create_proc_entry (irda_dirs[i].name,0 , proc_irda); -if (d) - d->proc_fops = irda_dirs[i].fops; - } +for (i=0 ; i<ARRAY_SIZE (irda_dirs); i++) + d =proc_create (irda_dirs[i].name,0 , proc_irda, + irda_dirs[i].fops); }/*
Signature · 1 line
WCN
David Miller
maintainerFrom: Wang Chen <[email protected]>
Date: Thu, 28 Feb 2008 18:56:39 +0800
Quoted 4 lines
net/irda/ircomm/ircomm_core.c +0
-0@@ -75,11 +75,8 @@ static int __init ircomm_init(void) }#ifdef CONFIG_PROC_FS
net/irda/ircomm/ircomm_core.c static int __init ircomm_init(void) · line 82
Quoted 10 lines
net/irda/ircomm/ircomm_core.c +2
-5- {struct proc_dir_entry *ent; - ent =create_proc_entry ("ircomm" ,0 , proc_irda); -if (ent) - ent->proc_fops = &ircomm_proc_fops; - } +struct proc_dir_entry *ent; + ent =proc_create ("ircomm" ,0 , proc_irda, &ircomm_proc_fops);#endif /* CONFIG_PROC_FS */ IRDA_MESSAGE ("IrCOMM protocol (Dag Brattli)\n" );
This is not C++, you therefore cannot declare local variables in arbitrary locations of the function body. That's what the braces were there for, to create the necessary new local scope.
For certain versions of GCC this won't even build, newer versions default to c99 or similar and therefore just so happen to work.
take#2 [PATCH 06/15] [IRDA]: Use proc_create() to setup ->proc_fops first
David Miller said the following on 2008-2-29 6:08:
Quoted 13 lines
Review
Quoted 9 lines
#ifdef
CONFIG_PROC_FS(quoted diff) +2
-5- { struct proc_dir_entry *ent; - ent = create_proc_entry("ircomm", 0, proc_irda); - if (ent) - ent->proc_fops = &ircomm_proc_fops; - } + struct proc_dir_entry *ent; + ent = proc_create("ircomm", 0, proc_irda, &ircomm_proc_fops); #endif /* CONFIG_PROC_FS */This is not C++, you therefore cannot declare local variables in arbitrary locations of the function body. That's what the braces were there for, to create the necessary new local scope.
Quoted 3 lines
For certain versions of GCC this won't even build, newer versions default to c99 or similar and therefore just so happen to work.
Use proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree.
--- net/irda/ircomm/ircomm_core.c | 8 +++++--- net/irda/irlan/irlan_common.c | 4 +--- net/irda/irproc.c | 8 +++----- 3 files changed, 9 insertions(+), 11 deletions(-)
net/irda/ircomm/ircomm_core.c +5 -3
@@ -76,9 +76,11 @@ static int __init ircomm_init(void)#ifdef CONFIG_PROC_FS {struct proc_dir_entry *ent; - ent =create_proc_entry ("ircomm" ,0 , proc_irda); -if (ent) - ent->proc_fops = &ircomm_proc_fops; + ent =proc_create ("ircomm" ,0 , proc_irda, &ircomm_proc_fops); +if (!ent) { +printk (KERN_ERR "ircomm_init: can't create /proc entry!\n" ); +return -ENODEV ; + } }#endif /* CONFIG_PROC_FS */
net/irda/irlan/irlan_common.c +1 -3
@@ -128,13 +128,11 @@ static int __init irlan_init(void)#ifdef CONFIG_PROC_FS {struct proc_dir_entry *proc; - proc =create_proc_entry ("irlan" ,0 , proc_irda); + proc =proc_create ("irlan" ,0 , proc_irda, &irlan_fops);if (!proc) {printk (KERN_ERR "irlan_init: can't create /proc entry!\n" );return -ENODEV ; } - - proc->proc_fops = &irlan_fops; }#endif /* CONFIG_PROC_FS */
net/irda/irproc.c +3 -5
@@ -72,11 +72,9 @@ void __init irda_proc_register(void)return ; proc_irda->owner =THIS_MODULE ; -for (i=0 ; i<ARRAY_SIZE (irda_dirs); i++) { - d =create_proc_entry (irda_dirs[i].name,0 , proc_irda); -if (d) - d->proc_fops = irda_dirs[i].fops; - } +for (i =0 ; i <ARRAY_SIZE (irda_dirs); i++) + d =proc_create (irda_dirs[i].name,0 , proc_irda, + irda_dirs[i].fops); }/*
Signature · 1 line
WCN
Re: take#2 [PATCH 06/15] [IRDA]: Use proc_create() to setup ->proc_fops first
From: Wang Chen <[email protected]>
Date: Fri, 29 Feb 2008 15:10:10 +0800
Quoted 4 lines
Use
proc_create()to make sure that ->proc_fops be setup before gluing PDE to main tree.Signed-off-by Wang Chen <[email protected]>
Applied, thanks for fixing up this patch.