[LLC]: Use refcounting with struct llc_sap

Signed-off-by: Jochen Friedrich <jochen@scram.de>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
Arnaldo Carvalho de Melo
2005-09-22 04:43:05 -03:00
parent 04e4223f44
commit 6e2144b768
9 changed files with 56 additions and 48 deletions

View File

@@ -17,6 +17,8 @@
#include <linux/list.h>
#include <linux/spinlock.h>
#include <asm/atomic.h>
struct net_device;
struct packet_type;
struct sk_buff;
@@ -44,6 +46,7 @@ struct llc_sap {
unsigned char state;
unsigned char p_bit;
unsigned char f_bit;
atomic_t refcnt;
int (*rcv_func)(struct sk_buff *skb,
struct net_device *dev,
struct packet_type *pt,
@@ -81,7 +84,18 @@ extern struct llc_sap *llc_sap_open(unsigned char lsap,
struct net_device *dev,
struct packet_type *pt,
struct net_device *orig_dev));
extern void llc_sap_close(struct llc_sap *sap);
static inline void llc_sap_hold(struct llc_sap *sap)
{
atomic_inc(&sap->refcnt);
}
static inline void llc_sap_put(struct llc_sap *sap)
{
extern void llc_sap_close(struct llc_sap *sap);
if (atomic_dec_and_test(&sap->refcnt))
llc_sap_close(sap);
}
extern struct llc_sap *llc_sap_find(unsigned char sap_value);