linux-embedded.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Iulia Manda <iulia.manda21@gmail.com>
To: josh@joshtriplett.org
Cc: linux-embedded@vger.kernel.org, tim.bird@sonymobile.com,
	paulmck@linux.vnet.ibm.com, dvhart@linux.intel.com,
	peterz@infradead.org, mihai.caraman@freescale.com
Subject: [PATCH 2/3] linux: Add macros that define and declare a core_param variable
Date: Wed,  1 Apr 2015 17:34:52 +0300	[thread overview]
Message-ID: <1427898893-8257-2-git-send-email-iulia.manda21@gmail.com> (raw)
In-Reply-To: <1427898893-8257-1-git-send-email-iulia.manda21@gmail.com>

This patch introduces two macros for kernel command line arguments subsequently
defined as core parameters:
* DECLARE_CORE_PARAM - declares an extern variable in case CMDLINE_PARSE is
set. In the other case it will make the variable a static constant asigned with
a default value to enable constant folding;
* DEFINE_CORE_PARAM - defines a core_param variable if CMDLINE_PARSE is set. In
the other case it leaves the definition to be handled by DECLARE_CORE_PARAM
macro.

Introducing a new header file for the declaration of kernel parameters seemed
to be the best option, because it solves the circular includes problem. Any
other proposal that would be fit for this case is welcomed.

Signed-off-by: Iulia Manda <iulia.manda21@gmail.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
---
 include/linux/moduleparam.h |  9 +++++++++
 include/linux/params.h      | 12 ++++++++++++
 2 files changed, 21 insertions(+)
 create mode 100644 include/linux/params.h

diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index f97397c..17efa97 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -310,6 +310,15 @@ static inline void __kernel_param_unlock(void)
 #define core_param(name, var, type, perm)				\
 	param_check_##type(name, &(var));				\
 	__module_param_call("", name, &param_ops_##type, &var, perm, -1, 0)
+
+#ifdef CONFIG_CMDLINE_PARSE
+#define DEFINE_CORE_PARAM(name, var, val, type, perm)			\
+        type var = val;                                                 \
+        core_param(name, var, type, perm)
+#else
+#define DEFINE_CORE_PARAM(name, var, val, type, perm)
+#endif
+
 #endif /* !MODULE */
 
 /**
diff --git a/include/linux/params.h b/include/linux/params.h
new file mode 100644
index 0000000..c1ee6ff
--- /dev/null
+++ b/include/linux/params.h
@@ -0,0 +1,12 @@
+#ifndef _LINUX_PARAMS_H
+#define _LINUX_PARAMS_H
+
+#ifdef CONFIG_CMDLINE_PARSE
+#define DECLARE_CORE_PARAM(var, val, type)                              \
+        extern type var
+#else
+#define DECLARE_CORE_PARAM(var, val, type)                              \
+        static const type var = val
+#endif
+
+#endif /* _LINUX_PARAMS_H */
-- 
1.9.1

  reply	other threads:[~2015-04-01 14:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-01 14:34 [PATCH 1/3] kernel: Add a new config option to remove command line parsing Iulia Manda
2015-04-01 14:34 ` Iulia Manda [this message]
2015-04-01 14:34 ` [PATCH 3/3] init: Set initcall_debug to a default value Iulia Manda
2015-04-09 14:44 ` [PATCH 1/3] kernel: Add a new config option to remove command line parsing Tim Bird

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=1427898893-8257-2-git-send-email-iulia.manda21@gmail.com \
    --to=iulia.manda21@gmail.com \
    --cc=dvhart@linux.intel.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-embedded@vger.kernel.org \
    --cc=mihai.caraman@freescale.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tim.bird@sonymobile.com \
    /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;
as well as URLs for NNTP newsgroup(s).