From dd243df0dae4fa0072bf10e3df5a16196b792575 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Wed, 19 Nov 2008 14:17:41 -0800 Subject: [PATCH] --- yaml --- r: 119239 b: refs/heads/master c: 566521d63720ab47576afb85147e5652993bf1e6 h: refs/heads/master i: 119237: fc9ec8f90d5a8f45cfcddfbc618fd73c6d3d3a87 119235: 78952857be3b39146049d1af44cff5b259f348b7 119231: d6869e39de47da6665061a369e24bc74380eac97 v: v3 --- [refs] | 2 +- trunk/net/phonet/af_phonet.c | 52 +++++++++++++++++------------------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/[refs] b/[refs] index 8ae395c54d32..31f6fd0e98af 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 79aefa45b20940cbb9104464548ff74f80f2395e +refs/heads/master: 566521d63720ab47576afb85147e5652993bf1e6 diff --git a/trunk/net/phonet/af_phonet.c b/trunk/net/phonet/af_phonet.c index 7ab30f668b5a..9d211f12582b 100644 --- a/trunk/net/phonet/af_phonet.c +++ b/trunk/net/phonet/af_phonet.c @@ -33,9 +33,30 @@ #include #include -static struct net_proto_family phonet_proto_family; -static struct phonet_protocol *phonet_proto_get(int protocol); -static inline void phonet_proto_put(struct phonet_protocol *pp); +/* Transport protocol registration */ +static struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly; +static DEFINE_SPINLOCK(proto_tab_lock); + +static struct phonet_protocol *phonet_proto_get(int protocol) +{ + struct phonet_protocol *pp; + + if (protocol >= PHONET_NPROTO) + return NULL; + + spin_lock(&proto_tab_lock); + pp = proto_tab[protocol]; + if (pp && !try_module_get(pp->prot->owner)) + pp = NULL; + spin_unlock(&proto_tab_lock); + + return pp; +} + +static inline void phonet_proto_put(struct phonet_protocol *pp) +{ + module_put(pp->prot->owner); +} /* protocol family functions */ @@ -375,10 +396,6 @@ static struct packet_type phonet_packet_type = { .func = phonet_rcv, }; -/* Transport protocol registration */ -static struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly; -static DEFINE_SPINLOCK(proto_tab_lock); - int __init_or_module phonet_proto_register(int protocol, struct phonet_protocol *pp) { @@ -412,27 +429,6 @@ void phonet_proto_unregister(int protocol, struct phonet_protocol *pp) } EXPORT_SYMBOL(phonet_proto_unregister); -static struct phonet_protocol *phonet_proto_get(int protocol) -{ - struct phonet_protocol *pp; - - if (protocol >= PHONET_NPROTO) - return NULL; - - spin_lock(&proto_tab_lock); - pp = proto_tab[protocol]; - if (pp && !try_module_get(pp->prot->owner)) - pp = NULL; - spin_unlock(&proto_tab_lock); - - return pp; -} - -static inline void phonet_proto_put(struct phonet_protocol *pp) -{ - module_put(pp->prot->owner); -} - /* Module registration */ static int __init phonet_init(void) {