mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: <linus.walleij@linaro.org>, <grant.likely@secretlab.ca>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH] allow gpiolib to be a module
Date: Mon, 10 Sep 2012 13:16:26 +0100	[thread overview]
Message-ID: <504DF63A020000780009A30B@nat28.tlf.novell.com> (raw)

Without ARCH_REQUIRE_GPIOLIB there's no reason to force this code, when
enabled, to always be built into the kernel, which requires only minor
Makefile and source code adjustments.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

---
 drivers/gpio/Kconfig       |    2 +-
 drivers/gpio/Makefile      |    3 ++-
 drivers/gpio/gpiolib.c     |   15 +++++++++++++++
 include/asm-generic/gpio.h |    3 ++-
 4 files changed, 20 insertions(+), 3 deletions(-)

--- 3.6-rc5/drivers/gpio/Kconfig
+++ 3.6-rc5-gpiolib-module/drivers/gpio/Kconfig
@@ -33,7 +33,7 @@ config ARCH_REQUIRE_GPIOLIB
 
 
 menuconfig GPIOLIB
-	bool "GPIO Support"
+	tristate "GPIO Support"
 	depends on ARCH_WANT_OPTIONAL_GPIOLIB || ARCH_REQUIRE_GPIOLIB
 	select GENERIC_GPIO
 	help
--- 3.6-rc5/drivers/gpio/Makefile
+++ 3.6-rc5-gpiolib-module/drivers/gpio/Makefile
@@ -2,7 +2,8 @@
 
 ccflags-$(CONFIG_DEBUG_GPIO)	+= -DDEBUG
 
-obj-$(CONFIG_GPIOLIB)		+= gpiolib.o devres.o
+gpio-lib-y			:= gpiolib.o devres.o
+obj-$(CONFIG_GPIOLIB)		+= gpio-lib.o
 obj-$(CONFIG_OF_GPIO)		+= gpiolib-of.o
 
 # Device drivers. Generally keep list sorted alphabetically
--- 3.6-rc5/drivers/gpio/gpiolib.c
+++ 3.6-rc5-gpiolib-module/drivers/gpio/gpiolib.c
@@ -1003,7 +1003,9 @@ static int __init gpiolib_sysfs_init(voi
 
 	return status;
 }
+#ifndef MODULE
 postcore_initcall(gpiolib_sysfs_init);
+#endif
 
 #else
 static inline int gpiochip_export(struct gpio_chip *chip)
@@ -1832,6 +1834,19 @@ static int __init gpiolib_debugfs_init(v
 				NULL, NULL, &gpiolib_operations);
 	return 0;
 }
+#ifndef MODULE
 subsys_initcall(gpiolib_debugfs_init);
+#endif
 
 #endif	/* DEBUG_FS */
+
+#ifdef MODULE
+int __init gpiolib_init(void)
+{
+	return gpiolib_sysfs_init() ?: gpiolib_debugfs_init();
+}
+module_init(gpiolib_init);
+
+MODULE_DESCRIPTION("GPIO library");
+MODULE_LICENSE("GPL");
+#endif
--- 3.6-rc5/include/asm-generic/gpio.h
+++ 3.6-rc5-gpiolib-module/include/asm-generic/gpio.h
@@ -4,9 +4,10 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/errno.h>
+#include <linux/kconfig.h>
 #include <linux/of.h>
 
-#ifdef CONFIG_GPIOLIB
+#if IS_ENABLED(CONFIG_GPIOLIB)
 
 #include <linux/compiler.h>
 




             reply	other threads:[~2012-09-10 12:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-10 12:16 Jan Beulich [this message]
2012-09-11  6:17 ` Ryan Mallon
2012-09-11  7:00   ` Jan Beulich
2012-09-11 17:38 ` Linus Walleij
2012-09-12  7:43   ` Jan Beulich
2012-09-12 15:53     ` Linus Walleij
2012-09-12 17:41     ` Randy Dunlap
2012-09-13  7:00       ` Jan Beulich

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=504DF63A020000780009A30B@nat28.tlf.novell.com \
    --to=jbeulich@suse.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®