mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: "Wang, Stanley" <stanley.wang@intel.com>
Cc: "'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>,
	dwmw2@twiddle.net
Subject: Re: [BUG] [2.5.49] symbol_get doesn't work
Date: Fri, 29 Nov 2002 11:01:50 +1100	[thread overview]
Message-ID: <20021129013010.5DEAF2C2EE@lists.samba.org> (raw)
In-Reply-To: Your message of "Thu, 28 Nov 2002 09:15:43 +0800." <957BD1C2BF3CD411B6C500A0C944CA2601F116A1@pdsmsx32.pd.intel.com>

In message <957BD1C2BF3CD411B6C500A0C944CA2601F116A1@pdsmsx32.pd.intel.com> you
 write:
> Hi, Rusty
> Thanks for your respondence.
> You means that the purpose of using symbols_get() is just adding =
> module's
> reference count, right?
> If so, I think we don't need a pointer to be returned by symbol_get(). =
> We
> could use the symbols desired
> directly after we called symbol_get().=20
> How do you think about it ?

Hi Wang,

	No, you do *not* normally need to use symbol_get(): you just
use the symbol like normal and the loader will make sure reference
counts are adjusted etc.

	Here's an example of use, from my (completely untested) "make
mtd use symbol_get()" patch, which allows mtd to look for support for
a given command set at runtime (rather than forcing all command set
modules to be present to load at all):

================
typedef struct mtd_info *cfi_cmdset_fn_t(struct map_info *, int);
 
static struct mtd_info *unknown_cmdset(struct map_info *map, int primary)
{
	struct cfi_private *cfi = map->fldrv_priv;
	__u16 type = primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID;

	printk(KERN_NOTICE "Support for command set %04X not present\n",
	       type);
	return NULL;
}

/* when we are built without module support, so we still link */
cfi_cmdset_fn_t cfi_cmdset_0001 __attribute__((weak, alias("unknown_cmdset")));
cfi_cmdset_fn_t cfi_cmdset_0002 __attribute__((weak, alias("unknown_cmdset")));
cfi_cmdset_fn_t cfi_cmdset_0003 __attribute__((weak, alias("unknown_cmdset")));

static inline struct mtd_info *cfi_cmdset_unknown(struct map_info *map, 
						  int primary)
{
	struct cfi_private *cfi = map->fldrv_priv;
	__u16 type = primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID;
	cfi_cmdset_fn_t *probe_function = NULL;

	switch (type) {
	case 1:
		probe_function = symbol_get(cfi_cmdset_0001);
		break;
	case 2:
		probe_function = symbol_get(cfi_cmdset_0002);
		break;
	case 3:
		probe_function = symbol_get(cfi_cmdset_0003);
		break;
	}
	if (probe_function) {
 		struct mtd_info *mtd;
 
 		mtd = (*probe_function)(map, primary);
 		return mtd;
 	}
	return unknown_cmdset(map, primary);
 }
 
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

       reply	other threads:[~2002-11-29  1:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <957BD1C2BF3CD411B6C500A0C944CA2601F116A1@pdsmsx32.pd.intel.com>
2002-11-29  0:01 ` Rusty Russell [this message]
2002-11-27  1:30 Wang, Stanley
2002-11-28  3:01 ` Rusty Russell
  -- strict thread matches above, loose matches on Subject: below --
2002-11-26  8:14 Wang, Stanley
2002-11-26 23:27 ` Rusty Russell
2002-11-27 23:19   ` Rusty Lynch
2002-11-28 23:42     ` Rusty Russell
2002-11-29  1:31       ` Miles Bader
2002-11-29  2:02         ` Sean Neakums
2002-11-29  2:11           ` Miles Bader
2002-11-29  3:29         ` Rusty Russell

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=20021129013010.5DEAF2C2EE@lists.samba.org \
    --to=rusty@rustcorp.com.au \
    --cc=dwmw2@twiddle.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stanley.wang@intel.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

Powered by JetHome