aboutsummaryrefslogtreecommitdiffstats
path: root/net/phonet
diff options
context:
space:
mode:
Diffstat (limited to 'net/phonet')
-rw-r--r--net/phonet/af_phonet.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
index 62af1d8a8dd2..9d211f12582b 100644
--- a/net/phonet/af_phonet.c
+++ b/net/phonet/af_phonet.c
@@ -33,8 +33,25 @@
33#include <net/phonet/phonet.h> 33#include <net/phonet/phonet.h>
34#include <net/phonet/pn_dev.h> 34#include <net/phonet/pn_dev.h>
35 35
36static struct net_proto_family phonet_proto_family; 36/* Transport protocol registration */
37static struct phonet_protocol *phonet_proto_get(int protocol); 37static struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly;
38static DEFINE_SPINLOCK(proto_tab_lock);
39
40static struct phonet_protocol *phonet_proto_get(int protocol)
41{
42 struct phonet_protocol *pp;
43
44 if (protocol >= PHONET_NPROTO)
45 return NULL;
46
47 spin_lock(&proto_tab_lock);
48 pp = proto_tab[protocol];
49 if (pp && !try_module_get(pp->prot->owner))
50 pp = NULL;
51 spin_unlock(&proto_tab_lock);
52
53 return pp;
54}
38 55
39static inline void phonet_proto_put(struct phonet_protocol *pp) 56static inline void phonet_proto_put(struct phonet_protocol *pp)
40{ 57{
@@ -379,10 +396,6 @@ static struct packet_type phonet_packet_type = {
379 .func = phonet_rcv, 396 .func = phonet_rcv,
380}; 397};
381 398
382/* Transport protocol registration */
383static struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly;
384static DEFINE_SPINLOCK(proto_tab_lock);
385
386int __init_or_module phonet_proto_register(int protocol, 399int __init_or_module phonet_proto_register(int protocol,
387 struct phonet_protocol *pp) 400 struct phonet_protocol *pp)
388{ 401{
@@ -416,22 +429,6 @@ void phonet_proto_unregister(int protocol, struct phonet_protocol *pp)
416} 429}
417EXPORT_SYMBOL(phonet_proto_unregister); 430EXPORT_SYMBOL(phonet_proto_unregister);
418 431
419static struct phonet_protocol *phonet_proto_get(int protocol)
420{
421 struct phonet_protocol *pp;
422
423 if (protocol >= PHONET_NPROTO)
424 return NULL;
425
426 spin_lock(&proto_tab_lock);
427 pp = proto_tab[protocol];
428 if (pp && !try_module_get(pp->prot->owner))
429 pp = NULL;
430 spin_unlock(&proto_tab_lock);
431
432 return pp;
433}
434
435/* Module registration */ 432/* Module registration */
436static int __init phonet_init(void) 433static int __init phonet_init(void)
437{ 434{