All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Herrmann <aherrman@arcor.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Eric Van Hensbergen <ericvh@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] 9p: fix compile error if !CONFIG_SYSCTL
Date: Thu, 20 Sep 2007 09:23:28 +0200	[thread overview]
Message-ID: <20070920072328.GA5113@devil> (raw)
In-Reply-To: <20070919233110.18a057ac.akpm@linux-foundation.org>

On Wed, Sep 19, 2007 at 11:31:10PM -0700, Andrew Morton wrote:
> On Tue, 18 Sep 2007 10:05:37 +0200 Andreas Herrmann <aherrman@arcor.de> wrote:
> 
> > Fix compile error if !CONFIG_SYSCTL:
> > 
> >     ...
> >   LD      .tmp_vmlinux1
> > net/built-in.o: In function `init_p9':
> > net/9p/mod.c:59: undefined reference to `p9_sysctl_register'
> > net/built-in.o: In function `exit_p9':
> > net/9p/mod.c:75: undefined reference to `p9_sysctl_unregister'
> > make: *** [.tmp_vmlinux1] Error 1
> >     ...
> 
> A better fix would be

But only if you add another
    #endif /* CONFIG_SYSCTL */

Right?
;-)

> 
> --- a/include/net/9p/9p.h~9p-fix-compile-error-if-config_sysctl
> +++ a/include/net/9p/9p.h
> @@ -412,6 +412,17 @@ int p9_idpool_check(int id, struct p9_id
>  
>  int p9_error_init(void);
>  int p9_errstr2errno(char *, int);
> +#ifdef CONFIG_SYSCTL
>  int __init p9_sysctl_register(void);
>  void __exit p9_sysctl_unregister(void);
> +#else
> +static inline int p9_sysctl_register(void)
> +{
> +	return 0;
> +}
> +
> +static inline void p9_sysctl_unregister(void)
> +{
> +}
> +
>  #endif /* NET_9P_H */
> diff -puN net/9p/mod.c~9p-fix-compile-error-if-config_sysctl net/9p/mod.c
> _
> 
> I struggled for five minutes trying to work out how to make CONFIG_SYSCTL
> go away and gave up in disgust.
> 
> God I hate select.

Hmm, you mean to completely avoid "#ifdef CONFIG_SYSCTL" in the net/p9 code?
How about below patch, which just merges net/9p/sysctl.c into net/9p/mod.c.


Regards,

Andreas

--
Merge net/p9/sysctl.c into net/p9/mod.c to avoid build errors
if !CONFIG_SYSCTL.

Signed-off-by: Andreas Herrmann <aherrman@arcor.de>
---
 include/net/9p/9p.h |    2 -
 net/9p/Makefile     |    4 +--
 net/9p/mod.c        |   54 +++++++++++++++++++++++++++++----
 net/9p/sysctl.c     |   81 ---------------------------------------------------
 4 files changed, 48 insertions(+), 93 deletions(-)
 delete mode 100644 net/9p/sysctl.c

diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
index 88884d3..f69992f 100644
--- a/include/net/9p/9p.h
+++ b/include/net/9p/9p.h
@@ -412,6 +412,4 @@ int p9_idpool_check(int id, struct p9_idpool *p);
 
 int p9_error_init(void);
 int p9_errstr2errno(char *, int);
-int __init p9_sysctl_register(void);
-void __exit p9_sysctl_unregister(void);
 #endif /* NET_9P_H */
diff --git a/net/9p/Makefile b/net/9p/Makefile
index 85b3a78..488026a 100644
--- a/net/9p/Makefile
+++ b/net/9p/Makefile
@@ -8,6 +8,4 @@ obj-$(CONFIG_NET_9P) := 9pnet.o
 	conv.o \
 	error.o \
 	fcprint.o \
-	util.o \
-
-9pnet-$(CONFIG_SYSCTL) += sysctl.o
+	util.o
diff --git a/net/9p/mod.c b/net/9p/mod.c
index 4f9e1d2..8d4ce1b 100644
--- a/net/9p/mod.c
+++ b/net/9p/mod.c
@@ -24,6 +24,10 @@
  *
  */
 
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/sysctl.h>
+#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <net/9p/9p.h>
@@ -37,8 +41,44 @@ MODULE_PARM_DESC(debug, "9P debugging level");
 
 extern int p9_mux_global_init(void);
 extern void p9_mux_global_exit(void);
-extern int p9_sysctl_register(void);
-extern void p9_sysctl_unregister(void);
+
+static struct ctl_table p9_table[] = {
+#ifdef CONFIG_NET_9P_DEBUG
+	{
+		.ctl_name       = CTL_UNNUMBERED,
+		.procname       = "debug",
+		.data           = &p9_debug_level,
+		.maxlen         = sizeof(int),
+		.mode           = 0644,
+		.proc_handler   = &proc_dointvec
+	},
+#endif
+	{},
+};
+
+static struct ctl_table p9_net_table[] = {
+	{
+		.ctl_name	= CTL_UNNUMBERED,
+		.procname	= "9p",
+		.maxlen		= 0,
+		.mode		= 0555,
+		.child		= p9_table,
+	},
+	{},
+};
+
+static struct ctl_table p9_ctl_table[] = {
+	{
+		.ctl_name	= CTL_NET,
+		.procname	= "net",
+		.maxlen		= 0,
+		.mode		= 0555,
+		.child		= p9_net_table,
+	},
+	{},
+};
+
+static struct ctl_table_header *p9_table_header;
 
 /**
  * v9fs_init - Initialize module
@@ -56,13 +96,13 @@ static int __init init_p9(void)
 		return ret;
 	}
 
-	ret = p9_sysctl_register();
-	if (ret) {
+	p9_table_header = register_sysctl_table(p9_ctl_table);
+	if (!p9_table_header) {
 		printk(KERN_WARNING "9p: registering sysctl failed\n");
-		return ret;
+		return -ENOMEM;
 	}
 
-	return ret;
+	return 0;
 }
 
 /**
@@ -72,7 +112,7 @@ static int __init init_p9(void)
 
 static void __exit exit_p9(void)
 {
-	p9_sysctl_unregister();
+	unregister_sysctl_table(p9_table_header);
 	p9_mux_global_exit();
 }
 
diff --git a/net/9p/sysctl.c b/net/9p/sysctl.c
deleted file mode 100644
index 8b61027..0000000
--- a/net/9p/sysctl.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- *  net/9p/sysctl.c
- *
- *  9P sysctl interface
- *
- *  Copyright (C) 2007 by Latchesar Ionkov <lucho@ionkov.net>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 2
- *  as published by the Free Software Foundation.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to:
- *  Free Software Foundation
- *  51 Franklin Street, Fifth Floor
- *  Boston, MA  02111-1301  USA
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/sysctl.h>
-#include <linux/init.h>
-#include <net/9p/9p.h>
-
-static struct ctl_table p9_table[] = {
-#ifdef CONFIG_NET_9P_DEBUG
-	{
-		.ctl_name       = CTL_UNNUMBERED,
-		.procname       = "debug",
-		.data           = &p9_debug_level,
-		.maxlen         = sizeof(int),
-		.mode           = 0644,
-		.proc_handler   = &proc_dointvec
-	},
-#endif
-	{},
-};
-
-static struct ctl_table p9_net_table[] = {
-	{
-		.ctl_name	= CTL_UNNUMBERED,
-		.procname	= "9p",
-		.maxlen		= 0,
-		.mode		= 0555,
-		.child		= p9_table,
-	},
-	{},
-};
-
-static struct ctl_table p9_ctl_table[] = {
-	{
-		.ctl_name	= CTL_NET,
-		.procname	= "net",
-		.maxlen		= 0,
-		.mode		= 0555,
-		.child		= p9_net_table,
-	},
-	{},
-};
-
-static struct ctl_table_header *p9_table_header;
-
-int __init p9_sysctl_register(void)
-{
-	p9_table_header = register_sysctl_table(p9_ctl_table);
-	if (!p9_table_header)
-		return -ENOMEM;
-
-	return 0;
-}
-
-void __exit p9_sysctl_unregister(void)
-{
-	 unregister_sysctl_table(p9_table_header);
-}
-- 
1.5.3



  reply	other threads:[~2007-09-20  7:22 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-18  8:05 [PATCH] 9p: fix compile error if !CONFIG_SYSCTL Andreas Herrmann
2007-09-18 18:53 ` roel
2007-09-18 20:15   ` Andreas Herrmann
2007-09-20  6:31 ` Andrew Morton
2007-09-20  7:23   ` Andreas Herrmann [this message]
2007-09-27 21:40   ` Nick Piggin
2007-09-28 14:34     ` Linus Torvalds
2007-09-28  0:05       ` Nick Piggin
2007-09-28 17:11         ` Arjan van de Ven
2007-09-28 17:12         ` Elyse M. Grasso
2007-10-01  7:27           ` A bit of kconfig rewrite (Re: [PATCH] 9p: fix compile error if !CONFIG_SYSCTL) Oleg Verych
2007-10-01  8:05             ` Sam Ravnborg
2007-10-01 12:53             ` Elyse M. Grasso
2007-10-05  2:35             ` [kbuild-devel] " Roman Zippel
2007-10-06 15:26               ` Oleg Verych
2007-10-06 16:03                 ` Linus Torvalds
2007-10-06 17:51                   ` Oleg Verych
2007-10-06 18:59                     ` Sam Ravnborg
2007-10-06 20:47                       ` Oleg Verych
2007-10-06 21:10                         ` Sam Ravnborg
2007-10-06 22:07                           ` Oleg Verych
2007-10-07  9:49                             ` Geert Uytterhoeven
2007-10-08 20:22                             ` Sam Ravnborg
2007-10-08 21:25                               ` Oleg Verych

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070920072328.GA5113@devil \
    --to=aherrman@arcor.de \
    --cc=akpm@linux-foundation.org \
    --cc=ericvh@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.