From: Shreyansh Jain <shreyansh.jain@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: try_module_get code understanding
Date: Thu, 27 Sep 2007 06:26:15 +0000 (UTC) [thread overview]
Message-ID: <loom.20070927T061840-329@post.gmane.org> (raw)
In-Reply-To: <20070927061304.GA7966@osiris.boeblingen.de.ibm.com>
Thanks for you reply, please see inline.
Heiko Carstens <heiko.carstens <at> de.ibm.com> writes:
>
[snip]
> > static inline int try_module_get(struct module *module){
> > int ret = 1; <--- error case when !module
> > if (module) {
> > unsigned int cpu = get_cpu();
> > if (likely(module_is_live(module)))
> > local_inc(&module->ref[cpu].count);
> > else
> > ret = 0; <--- error case
> > put_cpu();
> > }
> > return ret; <----
> > }
> > ----
[snip]
> Somewhere in module.h you have:
>
> #ifdef MODULE
> #define THIS_MODULE (&__this_module)
> #else /* !MODULE */
> #define THIS_MODULE ((struct module *)0)
> #endif
>
> So this just means, that THIS_MODULE is NULL for compiled in modules
> and therefore try_module_get(NULL) succeeds. It's not an error case.
Agreed.
Then what is return value if my module tries to 'get' a module which does not
exist (and is a module, not in-built)? . Is it '1' ?
Or am I imagining a hypothetical scenario which would not exist?
Thanks again for your fast response.
Shreyansh
next prev parent reply other threads:[~2007-09-27 6:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-27 5:19 Shreyansh Jain
2007-09-27 6:13 ` Heiko Carstens
2007-09-27 6:26 ` Shreyansh Jain [this message]
2007-09-27 7:11 ` Heiko Carstens
2007-09-27 6:14 ` Valdis.Kletnieks
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=loom.20070927T061840-329@post.gmane.org \
--to=shreyansh.jain@gmail.com \
--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®