Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 119239
b: refs/heads/master
c: 566521d
h: refs/heads/master
i:
  119237: fc9ec8f
  119235: 7895285
  119231: d6869e3
v: v3
  • Loading branch information
Alexey Dobriyan authored and David S. Miller committed Nov 19, 2008
1 parent e26fc31 commit dd243df
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 79aefa45b20940cbb9104464548ff74f80f2395e
refs/heads/master: 566521d63720ab47576afb85147e5652993bf1e6
52 changes: 24 additions & 28 deletions trunk/net/phonet/af_phonet.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,30 @@
#include <net/phonet/phonet.h>
#include <net/phonet/pn_dev.h>

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 */

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit dd243df

Please sign in to comment.