2003-06-07 15:11:08

by Adrian Bunk

[permalink] [raw]
Subject: [patch] 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.o
drivers/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:


--- linux-2.5.70-mm5/drivers/net/irda/vlsi_ir.c.old 2003-06-07 17:01:26.000000000 +0200
+++ linux-2.5.70-mm5/drivers/net/irda/vlsi_ir.c 2003-06-07 17:02:25.000000000 +0200
@@ -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

--

"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 Seed


2003-06-07 15:45:08

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [patch] fix vlsi_ir.c compile if !CONFIG_PROC_FS

On Sat, Jun 07, 2003 at 05:24:34PM +0200, Adrian Bunk wrote:
> I got the following compile error with !CONFIG_PROC_FS:
> CC drivers/net/irda/vlsi_ir.o
> drivers/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 =====
--- 1.16/drivers/net/irda/vlsi_ir.c Thu Apr 24 14:17:12 2003
+++ edited/drivers/net/irda/vlsi_ir.c Sat Jun 7 17:55:29 2003
@@ -1993,9 +1993,7 @@
#endif
};

-#ifdef CONFIG_PROC_FS
#define PROC_DIR ("driver/" DRIVER_NAME)
-#endif

static int __init vlsi_mod_init(void)
{

2003-06-07 16:00:22

by Adrian Bunk

[permalink] [raw]
Subject: Re: [patch] fix vlsi_ir.c compile if !CONFIG_PROC_FS

On Sat, Jun 07, 2003 at 05:58:27PM +0200, Sam Ravnborg wrote:
> On Sat, Jun 07, 2003 at 05:24:34PM +0200, Adrian Bunk wrote:
> > I got the following compile error with !CONFIG_PROC_FS:
> > CC drivers/net/irda/vlsi_ir.o
> > drivers/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.


> Sam
>
> ===== drivers/net/irda/vlsi_ir.c 1.16 vs edited =====
> --- 1.16/drivers/net/irda/vlsi_ir.c Thu Apr 24 14:17:12 2003
> +++ edited/drivers/net/irda/vlsi_ir.c Sat Jun 7 17:55:29 2003
> @@ -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

--

"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 Seed

Subject: Re: [patch] fix vlsi_ir.c compile if !CONFIG_PROC_FS


Apply something like this:

--- linux-2.5.70-bk11/include/proc_fs.h Fri Jun 6 18:43:49 2003
+++ linux/include/proc_fs.h Sat Jun 7 18:11:22 2003
@@ -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

On Sat, 7 Jun 2003, Adrian Bunk wrote:

> I got the following compile error with !CONFIG_PROC_FS:
>
> <-- snip -->
>
> ...
> CC drivers/net/irda/vlsi_ir.o
> drivers/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:
>
>
> --- linux-2.5.70-mm5/drivers/net/irda/vlsi_ir.c.old 2003-06-07 17:01:26.000000000 +0200
> +++ linux-2.5.70-mm5/drivers/net/irda/vlsi_ir.c 2003-06-07 17:02:25.000000000 +0200
> @@ -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);

2003-06-07 16:46:24

by Adrian Bunk

[permalink] [raw]
Subject: Re: [patch] fix vlsi_ir.c compile if !CONFIG_PROC_FS

On Sat, Jun 07, 2003 at 06:22:39PM +0200, Bartlomiej Zolnierkiewicz wrote:
>
> Apply something like this:
>
> --- linux-2.5.70-bk11/include/proc_fs.h Fri Jun 6 18:43:49 2003
> +++ linux/include/proc_fs.h Sat Jun 7 18:11:22 2003
> @@ -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.

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.

> Thanks,
> --
> Bartlomiej

cu
Adrian

--

"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 Seed

2003-06-07 16:56:04

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [patch] fix vlsi_ir.c compile if !CONFIG_PROC_FS

On Sat, Jun 07, 2003 at 06:59:51PM +0200, Adrian Bunk wrote:
> >
> > 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.

Actually both should be applied.
The ifdef/endif pair is redundant when Bartlomiej's patch is applied.

Sam

2003-06-07 19:55:56

by Andrew Morton

[permalink] [raw]
Subject: Re: [patch] fix vlsi_ir.c compile if !CONFIG_PROC_FS

Bartlomiej Zolnierkiewicz <[email protected]> wrote:
>
> -static inline void remove_proc_entry(const char *name, struct proc_dir_entry *parent) {};
> +#define remove_proc_entry(name, parent) /* nothing */

oh, OK.

--- 25/include/linux/proc_fs.h~remove_proc_entry-fix 2003-06-07 13:07:46.000000000 -0700
+++ 25-akpm/include/linux/proc_fs.h 2003-06-07 13:08:51.000000000 -0700
@@ -205,7 +205,8 @@ static inline void proc_pid_flush(struct
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) 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,

_

2003-06-08 10:06:35

by Martin Diehl

[permalink] [raw]
Subject: Re: [patch] fix vlsi_ir.c compile if !CONFIG_PROC_FS

On Sat, 7 Jun 2003, Adrian Bunk wrote:

> 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

> +#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

2003-06-08 10:08:55

by Martin Diehl

[permalink] [raw]
Subject: Re: [patch] fix vlsi_ir.c compile if !CONFIG_PROC_FS

On Sat, 7 Jun 2003, Sam Ravnborg wrote:

> On Sat, Jun 07, 2003 at 05:24:34PM +0200, Adrian Bunk wrote:
> > I got the following compile error with !CONFIG_PROC_FS:
> > CC drivers/net/irda/vlsi_ir.o
> > drivers/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.
>
> -#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

------------------------

--- linux-2.5.70/include/net/irda/vlsi_ir.h Mon Apr 7 19:31:51 2003
+++ v2.5.70/include/net/irda/vlsi_ir.h Sun Jun 8 11:33:40 2003
@@ -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;

--- linux-2.5.70/drivers/net/irda/vlsi_ir.c Wed May 7 09:13:39 2003
+++ v2.5.70/drivers/net/irda/vlsi_ir.c Sun Jun 8 11:33:34 2003
@@ -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_de
return 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(s
down(&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;

}



2003-06-09 07:20:19

by Rusty Russell

[permalink] [raw]
Subject: Re: [patch] fix vlsi_ir.c compile if !CONFIG_PROC_FS

In message <[email protected]> you write:
> -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.