fix vlsi_ir.c compile if !CONFIG_PROC_FS
Subsystems (3)
PATCH 1/1 fix vlsi_ir.c compile if !CONFIG_PROC_FS
I got the following compile error with !CONFIG_PROC_FS:
<-- snip -->
...
CC drivers/net/irda/vlsi_ir.odrivers/net/irda/vlsi_ir.c: In function `vlsi_irda_probe':drivers/net/irda/vlsi_ir.c:1826: warning: label out_unregister' defined but not used drivers/net/irda/vlsi_ir.c: In function vlsi_mod_exit':drivers/net/irda/vlsi_ir.c:2047: `PROC_DIR' undeclared (first use in this function) drivers/net/irda/vlsi_ir.c:2047: (Each undeclared identifier is reported only once drivers/net/irda/vlsi_ir.c:2047: for each function it appears in.) make[3]: *** [drivers/net/irda/vlsi_ir.o] Error 1
<-- snip -->
The following patch fixes it:
drivers/net/irda/vlsi_ir.c renamed from drivers/net/irda/vlsi_ir.c.old +4 -0
@@ -2044,7 +2044,11 @@ static void __exit vlsi_mod_exit(void) {pci_unregister_driver (&vlsi_irda_driver); + +#ifdef CONFIG_PROC_FS remove_proc_entry (PROC_DIR ,0 ); +#endif + }module_init (vlsi_mod_init);
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 5 lines · Adrian Bunk
I got the following compile error with !CONFIG_PROC_FS:
CCdrivers/net/irda/vlsi_ir.odrivers/net/irda/vlsi_ir.c:2047: `PROC_DIR' undeclared (first use in this function) The following patch fixes it:
[snip]
I prefer the following patch:
Get rid of one ifdef/endif pair.
Sam
===== drivers/net/irda/vlsi_ir.c 1.16 vs edited =====
drivers/net/irda/vlsi_ir.c +0 -2
@@ -1993,9 +1993,7 @@#endif }; -#ifdef CONFIG_PROC_FS #define PROC_DIR ("driver/" DRIVER_NAME) -#endif static int __init vlsi_mod_init (void ) {
Quoted 11 lines · Sam Ravnborg
Quoted 5 lines · Adrian Bunk
I got the following compile error with !CONFIG_PROC_FS:
CCdrivers/net/irda/vlsi_ir.odrivers/net/irda/vlsi_ir.c:2047: `PROC_DIR' undeclared (first use in this function) The following patch fixes it:[snip]
I prefer the following patch:
Get rid of one ifdef/endif pair.
Yup, I agree, your patch is better.
Quoted 6 lines
Sam
=====
drivers/net/irda/vlsi_ir.c1.16 vs edited =====
drivers/net/irda/vlsi_ir.c line 1999
Quoted 9 lines
drivers/net/irda/vlsi_ir.c +0
-2@@ -1993,9 +1993,7 @@#endif }; -#ifdef CONFIG_PROC_FS #define PROC_DIR ("driver/" DRIVER_NAME) -#endif static int __init vlsi_mod_init (void ) {
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedReview
Quoted 12 lines · Sam Ravnborg
Quoted 4 lines · Adrian Bunk
I got the following compile error with !CONFIG_PROC_FS:
CCdrivers/net/irda/vlsi_ir.odrivers/net/irda/vlsi_ir.c:2047: `PROC_DIR' undeclared (first use in this function) The following patch fixes it:I prefer the following patch:
Get rid of one ifdef/endif pair.(quoted diff) +0
-2-#ifdef CONFIG_PROC_FS #define PROC_DIR ("driver/" DRIVER_NAME) -#endif
Yes, Thanks. In fact walking over the proc-stuff in vlsi_ir, there are some more places which need cleanup and fixing.
Jean, please apply the patch below - ChangeLog:
* make it compile without CONFIG_PROC_FS (problem reported by Adrian Bunk, original patch by Sam Ravnborg)
* get rid of a number of unneeded ifdef/endif CONFIG_PROC_FS (also removing an "unused label" warning)
* use proc entry's owner field to protect against module removal racing with proc entry access.
Martin
------------------------
include/net/irda/vlsi_ir.h +0 -2
@@ -730,9 +730,7 @@ typedef struct vlsi_irda_dev {u32 cfg_space[64 /sizeof (u32)];u8 resume_ok; -#ifdef CONFIG_PROC_FS struct proc_dir_entry *proc_entry; -#endif } vlsi_irda_dev_t;
drivers/net/irda/vlsi_ir.c +14 -15
@@ -149,6 +149,9 @@ static void vlsi_ring_debug(struct vlsi_/********************************************************/ +/* needed regardless of CONFIG_PROC_FS */ +static struct proc_dir_entry *vlsi_proc_root =NULL ; +#ifdef CONFIG_PROC_FS static int vlsi_proc_pdev (struct pci_dev *pdev,char *buf,int len)
@@ -394,8 +397,6 @@ static int vlsi_proc_print(struct net_dereturn out - buf; } -static struct proc_dir_entry *vlsi_proc_root =NULL ; -struct vlsi_proc_data {int size;char *data;
@@ -499,6 +500,11 @@ static struct file_operations vlsi_proc_ .read = vlsi_proc_read, .release = vlsi_proc_release, }; + +#define VLSI_PROC_FOPS (&vlsi_proc_fops) + +#else /* CONFIG_PROC_FS */ +#define VLSI_PROC_FOPS NULL#endif /********************************************************/
@@ -1800,8 +1806,7 @@ vlsi_irda_probe(struct pci_dev *pdev, co goto out_freedev; } -#ifdef CONFIG_PROC_FS - { +if (vlsi_proc_root !=NULL ) {struct proc_dir_entry *ent; ent =create_proc_entry (ndev->name,S_IFREG |S_IRUGO , vlsi_proc_root);
@@ -1810,11 +1815,11 @@ vlsi_irda_probe(struct pci_dev *pdev, co goto out_unregister; } ent->data = ndev; - ent->proc_fops = &vlsi_proc_fops; + ent->proc_fops =VLSI_PROC_FOPS ; ent->size =0 ; idev->proc_entry = ent; - } -#endif + }else + idev->proc_entry =NULL ;printk (KERN_INFO "%s: registered device %s\n" , drivername, ndev->name);
@@ -1851,12 +1856,10 @@ static void __devexit vlsi_irda_remove(sdown (&idev->sem);pci_set_drvdata (pdev,NULL );pci_disable_device (pdev); -#ifdef CONFIG_PROC_FS if (idev->proc_entry) {remove_proc_entry (ndev->name, vlsi_proc_root); idev->proc_entry =NULL ; } -#endif up (&idev->sem);unregister_netdev (ndev);
@@ -1993,9 +1996,7 @@ static struct pci_driver vlsi_irda_drive#endif }; -#ifdef CONFIG_PROC_FS #define PROC_DIR ("driver/" DRIVER_NAME) -#endif static int __init vlsi_mod_init (void ) {
@@ -2025,18 +2026,16 @@ static int __init vlsi_mod_init(void) sirpulse = !!sirpulse; -#ifdef CONFIG_PROC_FS vlsi_proc_root =create_proc_entry (PROC_DIR ,S_IFDIR ,0 );if (!vlsi_proc_root)return -ENOMEM ; -#endif +/* protect registered procdir against module removal */ + vlsi_proc_root->owner =THIS_MODULE ; ret =pci_module_init (&vlsi_irda_driver); -#ifdef CONFIG_PROC_FS if (ret)remove_proc_entry (PROC_DIR ,0 ); -#endif return ret; }
Apply something like this:
include/proc_fs.h +1 -1
@@ -205,7 +205,7 @@static inline struct proc_dir_entry *create_proc_entry (const char *name,mode_t mode,struct proc_dir_entry *parent) {return NULL ; } -static inline void remove_proc_entry (const char *name,struct proc_dir_entry *parent) {}; +#define remove_proc_entry (name, parent)/* nothing */ static inline struct proc_dir_entry *proc_symlink (const char *name,struct proc_dir_entry *parent,char *dest) {return NULL ;} static inline struct proc_dir_entry *proc_mknod(const char *name,mode_t mode,
And you wil not have to readd #ifdef/#endif pair.
I've seen Sam's mail but this is generic solution to quiet compiler and will work for any remove_proc_entry() user.
Thanks,
--
Bartlomiej
Quoted 34 lines · Adrian Bunk
I got the following compile error with !CONFIG_PROC_FS:
<-- snip -->
...
CCdrivers/net/irda/vlsi_ir.odrivers/net/irda/vlsi_ir.c: In function `vlsi_irda_probe':drivers/net/irda/vlsi_ir.c:1826: warning: labelout_unregister' defined but not used drivers/net/irda/vlsi_ir.c: In functionvlsi_mod_exit':drivers/net/irda/vlsi_ir.c:2047: `PROC_DIR' undeclared (first use in this function)drivers/net/irda/vlsi_ir.c:2047: (Each undeclared identifier is reported only oncedrivers/net/irda/vlsi_ir.c:2047: for each function it appears in.) make[3]: *** [drivers/net/irda/vlsi_ir.o] Error 1<-- snip -->
The following patch fixes it:
drivers/net/irda/vlsi_ir.c renamed from drivers/net/irda/vlsi_ir.c.old +4
-0@@ -2044,7 +2044,11 @@ static void __exit vlsi_mod_exit(void) {pci_unregister_driver (&vlsi_irda_driver); + +#ifdef CONFIG_PROC_FS remove_proc_entry (PROC_DIR ,0 ); +#endif + }module_init (vlsi_mod_init);
Quoted 15 lines · Bartlomiej Zolnierkiewicz
Apply something like this:
include/proc_fs.h +1
-1@@ -205,7 +205,7 @@static inline struct proc_dir_entry *create_proc_entry (const char *name,mode_t mode,struct proc_dir_entry *parent) {return NULL ; } -static inline void remove_proc_entry (const char *name,struct proc_dir_entry *parent) {}; +#define remove_proc_entry (name, parent)/* nothing */ static inline struct proc_dir_entry *proc_symlink (const char *name,struct proc_dir_entry *parent,char *dest) {return NULL ;} static inline struct proc_dir_entry *proc_mknod(const char *name,mode_t mode,
Quoted 4 lines
And you wil not have to readd #ifdef/#endif pair.
I've seen Sam's mail but this is generic solution to quiet compiler and will work for any
remove_proc_entry()user.
Yup, for this specific error Sam's solution is the best one, but your patch e.g. solves the ieee1394_core.c compile error I reported, too.
Quoted 3 lines
Thanks,
--
Bartlomiej
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 6 lines · Adrian Bunk
Quoted 3 lines
I've seen Sam's mail but this is generic solution to quiet compiler and will work for any
remove_proc_entry()user.Yup, for this specific error Sam's solution is the best one, but your patch e.g. solves the
ieee1394_core.ccompile error I reported, too.
Actually both should be applied.
The ifdef/endif pair is redundant when Bartlomiej's patch is applied.
Sam
Quoted 3 lines · Bartlomiej Zolnierkiewicz
-static inline void
remove_proc_entry(const char *name, struct proc_dir_entry *parent){};
+#defineremove_proc_entry(name, parent)/* nothing */
oh, OK.
include/linux/proc_fs.h renamed from include/linux/proc_fs.h~remove_proc_entry-fix +2 -1
@@ -205,7 +205,8 @@ static inline void proc_pid_flush(structstatic inline struct proc_dir_entry *create_proc_entry (const char *name,mode_t mode,struct proc_dir_entry *parent) {return NULL ; } -static inline void remove_proc_entry (const char *name,struct proc_dir_entry *parent) {}; +#define remove_proc_entry (name, parent) do {} while (0) +static inline struct proc_dir_entry *proc_symlink (const char *name,struct proc_dir_entry *parent,char *dest) {return NULL ;} static inline struct proc_dir_entry *proc_mknod(const char *name,mode_t mode,
_
In message <[email protected]> you write:
Quoted 7 lines
include/proc_fs.h +1
-1-static inline void remove_proc_entry (const char *name,struct proc_dir_entry *parent) {}; +#define remove_proc_entry (name, parent)/* nothing */ And you wil not have to readd #ifdef/#endif pair.
I've seen Sam's mail but this is generic solution to quiet compiler and will work for any
remove_proc_entry()user.
And it'll leave unused warnings all over the place, meaning you have to add __unused to all the callers. Now gcc 3.3 will actually discard those unused functions, this might be worth considering.
But if you're going to do that, make create_proc_entry etc *not* return NULL if !CONFIG_PROC_FS, otherwise you need the #ifdef anyway. This has been noted before.
Good luck!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 2 lines · Adrian Bunk
drivers/net/irda/vlsi_ir.c: In function `vlsi_mod_exit':drivers/net/irda/vlsi_ir.c:2047: `PROC_DIR' undeclared (first use in this function)
Thank you for finding this! Actually, I had something similar to your patch
drivers/net/irda/vlsi_ir.c line 2050
Quoted 3 lines
drivers/net/irda/vlsi_ir.c renamed from drivers/net/irda/vlsi_ir.c.old +2
-0+#ifdef CONFIG_PROC_FS remove_proc_entry (PROC_DIR ,0 ); +#endif
already pending here, but the proc-stuff in vlsi_ir needs some more fixing. Patch will follow.
Martin