mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC][PATCH 2.6.11-rc2] vmlinux: add SETUP_DESC() to describe __setup() options
@ 2005-01-31 23:50 Matt Domsch
  2005-02-01  1:10 ` Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Domsch @ 2005-01-31 23:50 UTC (permalink / raw)
  To: rusty, linux-kernel

__setup() options are traditionally documented in
Documentation/kernel-parameters.txt.  However, it would be nice if
they could be documented alongside the implementation, similar to
MODULE_PARM_DESC() fields for modules, and if 'modinfo vmlinux' could
report such.

Patch below adds a new macro, SETUP_DESC(), which can be used to
document the use cases of __setup() options.  A usage example in
kernel/audit.c is provided as well.

$ modinfo vmlinux | grep setup_param
setup_param:    audit:0 = disable, 1 = enable (kernel/audit.c)

Feedback requested.

Thanks,
Matt

-- 
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

===== include/linux/init.h 1.35 vs edited =====
--- 1.35/include/linux/init.h	2005-01-04 20:48:02 -06:00
+++ edited/include/linux/init.h	2005-01-31 17:22:41 -06:00
@@ -127,6 +127,15 @@
 		__attribute__((aligned((sizeof(long)))))	\
 		= { __setup_str_##unique_id, fn, early }
 
+#define __setup_cat(a) __setup_str_ ## a
+#define __SETUP_INFO(tag, name, info)					  \
+static const char __setup_cat(name)[]				          \
+  __attribute_used__							  \
+  __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info " (" __FILE__ ")"
+
+#define SETUP_DESC(_parm, desc) \
+        __SETUP_INFO(setup_param, _parm, #_parm ":" desc)
+
 #define __setup_null_param(str, unique_id)			\
 	__setup_param(str, unique_id, NULL, 0)
 
@@ -202,6 +211,7 @@
 #define __setup_null_param(str, unique_id) 	/* nothing */
 #define __setup(str, func) 			/* nothing */
 #define __obsolete_setup(str) 			/* nothing */
+#define SETUP_DESC(_parm, desc)		        /* nothing */
 #endif
 
 /* Data marked not to be saved by software_suspend() */



===== kernel/audit.c 1.6 vs edited =====
--- 1.6/kernel/audit.c	2005-01-20 22:56:04 -06:00
+++ edited/kernel/audit.c	2005-01-31 15:55:43 -06:00
@@ -617,7 +617,7 @@
 }
 
 __setup("audit=", audit_enable);
-
+SETUP_DESC(audit, "0 = disable, 1 = enable");
 
 /* Obtain an audit buffer.  This routine does locking to obtain the
  * audit buffer, but then no locking is required for calls to

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

* Re: [RFC][PATCH 2.6.11-rc2] vmlinux: add SETUP_DESC() to describe __setup() options
  2005-01-31 23:50 [RFC][PATCH 2.6.11-rc2] vmlinux: add SETUP_DESC() to describe __setup() options Matt Domsch
@ 2005-02-01  1:10 ` Rusty Russell
  0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2005-02-01  1:10 UTC (permalink / raw)
  To: Matt Domsch; +Cc: lkml - Kernel Mailing List

On Mon, 2005-01-31 at 17:50 -0600, Matt Domsch wrote:
> __setup() options are traditionally documented in
> Documentation/kernel-parameters.txt.  However, it would be nice if
> they could be documented alongside the implementation, similar to
> MODULE_PARM_DESC() fields for modules, and if 'modinfo vmlinux' could
> report such.
> 
> Patch below adds a new macro, SETUP_DESC(), which can be used to
> document the use cases of __setup() options.  A usage example in
> kernel/audit.c is provided as well.

I don't want to encourage the proliferation of __setup, and prefer
module_parm() for new code.  __setup() is good for certain fundamentals,
but the namespace and parsing help given by module_parm() usually makes
it a better choice.

That said, I don't have a particular issue with this.
Rusty.
-- 
A bad analogy is like a leaky screwdriver -- Richard Braakman


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

end of thread, other threads:[~2005-02-01  1:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-31 23:50 [RFC][PATCH 2.6.11-rc2] vmlinux: add SETUP_DESC() to describe __setup() options Matt Domsch
2005-02-01  1:10 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome