From: Dan Streetman <ddstreet@ieee.org>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
linux-next@vger.kernel.org,
linux-kernel <linux-kernel@vger.kernel.org>,
Dan Streetman <ddstreet@ieee.org>
Subject: [PATCH] modules: only use mod->param_lock if CONFIG_MODULES
Date: Wed, 24 Jun 2015 14:31:17 -0400 [thread overview]
Message-ID: <1435170677-16492-1-git-send-email-ddstreet@ieee.org> (raw)
In-Reply-To: <CALZtONAqdXeV0=Enjsw6YzuWFC-4ZqpeWfwxcEgBa+1CasqbGA@mail.gmail.com>
Simplify params.c by replacing KPARAM_MUTEX() with an inline function
__param_lock(), and replacing KPARAM_IS_LOCKED() with direct calls to
mutex_is_locked(). Inside __param_lock(), only (conditionally) return
mod->param_lock #ifdef CONFIG_MODULES; if there are no modules just
return the built-in param_lock.
Since "struct module" isn't defined if !CONFIG_MODULES, we must leave
out the code that returns mod->param_lock if there are no modules.
Signed-off-by: Dan Streetman <ddstreet@ieee.org>
---
kernel/params.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/kernel/params.c b/kernel/params.c
index 8890d0b..9c955cd 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -29,8 +29,14 @@
static DEFINE_MUTEX(param_lock);
/* Use the module's mutex, or if built-in use the built-in mutex */
-#define KPARAM_MUTEX(mod) ((mod) ? &(mod)->param_lock : ¶m_lock)
-#define KPARAM_IS_LOCKED(mod) mutex_is_locked(KPARAM_MUTEX(mod))
+static inline struct mutex *__param_lock(struct module *mod)
+{
+#ifdef CONFIG_MODULES
+ return mod ? &mod->param_lock : ¶m_lock;
+#else
+ return ¶m_lock;
+#endif
+}
/* This just allows us to keep track of which parameters are kmalloced. */
struct kmalloced_param {
@@ -459,7 +465,7 @@ static int param_array(struct module *mod,
/* nul-terminate and parse */
save = val[len];
((char *)val)[len] = '\0';
- BUG_ON(!KPARAM_IS_LOCKED(mod));
+ BUG_ON(!mutex_is_locked(__param_lock(mod)));
ret = set(val, &kp);
if (ret != 0)
@@ -496,7 +502,7 @@ static int param_array_get(char *buffer, const struct kernel_param *kp)
if (i)
buffer[off++] = ',';
p.arg = arr->elem + arr->elemsize * i;
- BUG_ON(!KPARAM_IS_LOCKED(p.mod));
+ BUG_ON(!mutex_is_locked(__param_lock(p.mod)));
ret = arr->ops->get(buffer + off, &p);
if (ret < 0)
return ret;
@@ -618,12 +624,12 @@ static ssize_t param_attr_store(struct module_attribute *mattr,
void kernel_param_lock(struct module *mod)
{
- mutex_lock(KPARAM_MUTEX(mod));
+ mutex_lock(__param_lock(mod));
}
void kernel_param_unlock(struct module *mod)
{
- mutex_unlock(KPARAM_MUTEX(mod));
+ mutex_unlock(__param_lock(mod));
}
#ifdef CONFIG_SYSFS
--
2.1.0
next prev parent reply other threads:[~2015-06-24 18:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-24 1:37 linux-next: build failure after merge of the modules tree Stephen Rothwell
2015-06-24 18:18 ` Dan Streetman
2015-06-24 18:31 ` Dan Streetman [this message]
2015-06-24 22:57 ` Stephen Rothwell
2015-06-25 1:50 ` Stephen Rothwell
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=1435170677-16492-1-git-send-email-ddstreet@ieee.org \
--to=ddstreet@ieee.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=sfr@canb.auug.org.au \
/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).