mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Extract common MODULE_INFO content into new moduleinfo.h.
@ 2007-05-20  7:57 Robert P. J. Day
  2007-05-20  8:47 ` David Rientjes
  0 siblings, 1 reply; 5+ messages in thread
From: Robert P. J. Day @ 2007-05-20  7:57 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Andrew Morton


Extract the common MODULE_INFO content found in both module.h and
moduleparam.h into a new header file moduleinfo.h, which at least
makes it possible for source files to someday stop including the
content from moduleparam.h when they don't need it.

Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>

---

  compile-tested with "make allmodconfig" on x86.

 include/linux/module.h      |   12 +++---------
 include/linux/moduleinfo.h  |   18 ++++++++++++++++++
 include/linux/moduleparam.h |   16 +++++-----------
 3 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/include/linux/module.h b/include/linux/module.h
index e6e0f86..d9a9a13 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -15,7 +15,8 @@
 #include <linux/elf.h>
 #include <linux/stringify.h>
 #include <linux/kobject.h>
-#include <linux/moduleparam.h>
+#include <linux/moduleparam.h>	/* Ideally, this shouldn't be necessary. */
+#include <linux/moduleinfo.h>
 #include <asm/local.h>

 #include <asm/module.h>
@@ -88,9 +89,6 @@ extern struct module __this_module;
 #define THIS_MODULE ((struct module *)0)
 #endif

-/* Generic info of form tag = "info" */
-#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
-
 /* For userspace: you can also call me... */
 #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)

@@ -130,11 +128,6 @@ extern struct module __this_module;
 /* What your module does. */
 #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)

-/* One for each parameter, describing how to use it.  Some files do
-   multiple of these per line, so can't just use MODULE_INFO. */
-#define MODULE_PARM_DESC(_parm, desc) \
-	__MODULE_INFO(parm, _parm, #_parm ":" desc)
-
 #define MODULE_DEVICE_TABLE(type,name)		\
   MODULE_GENERIC_TABLE(type##_device,name)

@@ -576,6 +569,7 @@ struct device_driver;
 struct module;

 extern struct kset module_subsys;
+struct kernel_param;

 int mod_sysfs_init(struct module *mod);
 int mod_sysfs_setup(struct module *mod,
diff --git a/include/linux/moduleinfo.h b/include/linux/moduleinfo.h
new file mode 100644
index 0000000..cee86a9
--- /dev/null
+++ b/include/linux/moduleinfo.h
@@ -0,0 +1,18 @@
+#ifndef _LINUX_MODULEINFO_H
+#define _LINUX_MODULEINFO_H
+
+#ifdef MODULE
+#include <linux/stringify.h>
+#define ___module_cat(a,b) __mod_ ## a ## b
+#define __module_cat(a,b) ___module_cat(a,b)
+#define __MODULE_INFO(tag, name, info)				\
+static const char __module_cat(name,__LINE__)[]			\
+  __attribute_used__						\
+  __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info
+#else  /* !MODULE */
+#define __MODULE_INFO(tag, name, info)
+#endif
+
+#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
+
+#endif // _LINUX_MODULEINFO_H
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index c83588c..650328d 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -4,6 +4,7 @@
 #include <linux/init.h>
 #include <linux/stringify.h>
 #include <linux/kernel.h>
+#include <linux/moduleinfo.h>

 /* You can override this manually, but generally this should match the
    module name. */
@@ -13,19 +14,12 @@
 #define MODULE_PARAM_PREFIX KBUILD_MODNAME "."
 #endif

-#ifdef MODULE
-#define ___module_cat(a,b) __mod_ ## a ## b
-#define __module_cat(a,b) ___module_cat(a,b)
-#define __MODULE_INFO(tag, name, info)					  \
-static const char __module_cat(name,__LINE__)[]				  \
-  __attribute_used__							  \
-  __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info
-#else  /* !MODULE */
-#define __MODULE_INFO(tag, name, info)
-#endif
-#define __MODULE_PARM_TYPE(name, _type)					  \
+#define __MODULE_PARM_TYPE(name, _type)					\
   __MODULE_INFO(parmtype, name##type, #name ":" _type)

+#define MODULE_PARM_DESC(_parm, desc)					\
+  __MODULE_INFO(parm, _parm, #_parm ":" desc)
+
 struct kernel_param;

 /* Returns 0, or -errno.  arg is in kp->arg. */
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Extract common MODULE_INFO content into new moduleinfo.h.
  2007-05-20  7:57 [PATCH] Extract common MODULE_INFO content into new moduleinfo.h Robert P. J. Day
@ 2007-05-20  8:47 ` David Rientjes
  2007-05-20 10:28   ` Robert P. J. Day
  0 siblings, 1 reply; 5+ messages in thread
From: David Rientjes @ 2007-05-20  8:47 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Linux Kernel Mailing List, Andrew Morton

On Sun, 20 May 2007, Robert P. J. Day wrote:

> diff --git a/include/linux/moduleinfo.h b/include/linux/moduleinfo.h
> new file mode 100644
> index 0000000..cee86a9
> --- /dev/null
> +++ b/include/linux/moduleinfo.h
> @@ -0,0 +1,18 @@
> +#ifndef _LINUX_MODULEINFO_H
> +#define _LINUX_MODULEINFO_H
> +
> +#ifdef MODULE
> +#include <linux/stringify.h>
> +#define ___module_cat(a,b) __mod_ ## a ## b
> +#define __module_cat(a,b) ___module_cat(a,b)
> +#define __MODULE_INFO(tag, name, info)				\
> +static const char __module_cat(name,__LINE__)[]			\
> +  __attribute_used__						\
> +  __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info

This isn't a function definition so __attribute_used__ (which is 
deprecated anyway) doesn't mean anything.  Please simply use 
__maybe_unused and remove "unused" from the second attribute.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Extract common MODULE_INFO content into new moduleinfo.h.
  2007-05-20  8:47 ` David Rientjes
@ 2007-05-20 10:28   ` Robert P. J. Day
  2007-05-20 16:38     ` David Rientjes
  0 siblings, 1 reply; 5+ messages in thread
From: Robert P. J. Day @ 2007-05-20 10:28 UTC (permalink / raw)
  To: David Rientjes; +Cc: Linux Kernel Mailing List, Andrew Morton

On Sun, 20 May 2007, David Rientjes wrote:

> On Sun, 20 May 2007, Robert P. J. Day wrote:
>
> > diff --git a/include/linux/moduleinfo.h b/include/linux/moduleinfo.h
> > new file mode 100644
> > index 0000000..cee86a9
> > --- /dev/null
> > +++ b/include/linux/moduleinfo.h
> > @@ -0,0 +1,18 @@
> > +#ifndef _LINUX_MODULEINFO_H
> > +#define _LINUX_MODULEINFO_H
> > +
> > +#ifdef MODULE
> > +#include <linux/stringify.h>
> > +#define ___module_cat(a,b) __mod_ ## a ## b
> > +#define __module_cat(a,b) ___module_cat(a,b)
> > +#define __MODULE_INFO(tag, name, info)				\
> > +static const char __module_cat(name,__LINE__)[]			\
> > +  __attribute_used__						\
> > +  __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info
>
> This isn't a function definition so __attribute_used__ (which is
> deprecated anyway) doesn't mean anything.  Please simply use
> __maybe_unused and remove "unused" from the second attribute.

i can do that as long as there's no way that those changes can (even
theoretically) make a difference in the build.  in order to make sure
this patch didn't break anything, i went with a straight cut-and-paste
of the content to go into the new moduleinfo.h.

so while i agree that those changes shouldn't hurt, personally, i'd
prefer to just put this patch through as is and come back later to do
any tidying related to attribute rewording.

rday
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Extract common MODULE_INFO content into new moduleinfo.h.
  2007-05-20 10:28   ` Robert P. J. Day
@ 2007-05-20 16:38     ` David Rientjes
  2007-05-20 17:15       ` Robert P. J. Day
  0 siblings, 1 reply; 5+ messages in thread
From: David Rientjes @ 2007-05-20 16:38 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Linux Kernel Mailing List, Andrew Morton

On Sun, 20 May 2007, Robert P. J. Day wrote:

> i can do that as long as there's no way that those changes can (even
> theoretically) make a difference in the build.  in order to make sure
> this patch didn't break anything, i went with a straight cut-and-paste
> of the content to go into the new moduleinfo.h.
> 

__attribute_used__ is pointless outside of function definitions so the way 
it is currently written is incorrect.

> so while i agree that those changes shouldn't hurt, personally, i'd
> prefer to just put this patch through as is and come back later to do
> any tidying related to attribute rewording.
> 

__attribute_used__ is deprecated so it would be helpful to change it now 
instead of requiring a second patch.  It's better if new patches no longer 
use a deprecated attribute.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Extract common MODULE_INFO content into new moduleinfo.h.
  2007-05-20 16:38     ` David Rientjes
@ 2007-05-20 17:15       ` Robert P. J. Day
  0 siblings, 0 replies; 5+ messages in thread
From: Robert P. J. Day @ 2007-05-20 17:15 UTC (permalink / raw)
  To: David Rientjes; +Cc: Linux Kernel Mailing List, Andrew Morton

On Sun, 20 May 2007, David Rientjes wrote:

> On Sun, 20 May 2007, Robert P. J. Day wrote:
>
> > i can do that as long as there's no way that those changes can
> > (even theoretically) make a difference in the build.  in order to
> > make sure this patch didn't break anything, i went with a straight
> > cut-and-paste of the content to go into the new moduleinfo.h.
>
> __attribute_used__ is pointless outside of function definitions so
> the way it is currently written is incorrect.
>
> > so while i agree that those changes shouldn't hurt, personally,
> > i'd prefer to just put this patch through as is and come back
> > later to do any tidying related to attribute rewording.
>
> __attribute_used__ is deprecated so it would be helpful to change it
> now instead of requiring a second patch.  It's better if new patches
> no longer use a deprecated attribute.

fair enough.  i'll submit a revised patch shortly.

rday

p.s.  um ... just off-hand, i'm hoping that people understand the
rationale behind this patch.

-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-05-20 17:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-20  7:57 [PATCH] Extract common MODULE_INFO content into new moduleinfo.h Robert P. J. Day
2007-05-20  8:47 ` David Rientjes
2007-05-20 10:28   ` Robert P. J. Day
2007-05-20 16:38     ` David Rientjes
2007-05-20 17:15       ` Robert P. J. Day

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®