[Fault-injection-developer] RE: [BUG] [2.5.49] symbol_get doesn't work
Status: Alpha
Brought to you by:
rustyl
From: Wang, S. <sta...@in...> - 2002-11-29 02:26:09
|
Hi, Rusty I get it now :) Thanks, Stanley > -----Original Message----- > From: Rusty Russell [mailto:ru...@ru...] > Sent: 2002=E5=B9=B411=E6=9C=8829=E6=97=A5 8:02 > To: Wang, Stanley > Cc: 'lin...@vg...'; dw...@tw... > Subject: Re: [BUG] [2.5.49] symbol_get doesn't work=20 >=20 >=20 > In message=20 > <957...@pd...> you > write: > > Hi, Rusty > > Thanks for your respondence. > > You means that the purpose of using symbols_get() is just adding = =3D > > module's > > reference count, right? > > If so, I think we don't need a pointer to be returned by=20 > symbol_get(). =3D > > We > > could use the symbols desired > > directly after we called symbol_get().=3D20 > > How do you think about it ? >=20 > Hi Wang, >=20 > 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. >=20 > 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): >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > typedef struct mtd_info *cfi_cmdset_fn_t(struct map_info *, int); > =20 > static struct mtd_info *unknown_cmdset(struct map_info *map,=20 > int primary) > { > struct cfi_private *cfi =3D map->fldrv_priv; > __u16 type =3D primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID; >=20 > printk(KERN_NOTICE "Support for command set %04X not present\n", > type); > return NULL; > } >=20 > /* when we are built without module support, so we still link */ > cfi_cmdset_fn_t cfi_cmdset_0001 __attribute__((weak,=20 > alias("unknown_cmdset"))); > cfi_cmdset_fn_t cfi_cmdset_0002 __attribute__((weak,=20 > alias("unknown_cmdset"))); > cfi_cmdset_fn_t cfi_cmdset_0003 __attribute__((weak,=20 > alias("unknown_cmdset"))); >=20 > static inline struct mtd_info *cfi_cmdset_unknown(struct=20 > map_info *map,=20 > int primary) > { > struct cfi_private *cfi =3D map->fldrv_priv; > __u16 type =3D primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID; > cfi_cmdset_fn_t *probe_function =3D NULL; >=20 > switch (type) { > case 1: > probe_function =3D symbol_get(cfi_cmdset_0001); > break; > case 2: > probe_function =3D symbol_get(cfi_cmdset_0002); > break; > case 3: > probe_function =3D symbol_get(cfi_cmdset_0003); > break; > } > if (probe_function) { > struct mtd_info *mtd; > =20 > mtd =3D (*probe_function)(map, primary); > return mtd; > } > return unknown_cmdset(map, primary); > } > =20 > -- > Anyone who quotes me in their sig is an idiot. -- Rusty Russell. >=20 |