diff options
| author | Arnaldo Carvalho de Melo <acme@conectiva.com.br> | 2003-05-15 15:45:44 -0300 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@conectiva.com.br> | 2003-05-15 15:45:44 -0300 |
| commit | 706245bbc5a41fd887c3da129ca33f5446f79d21 (patch) | |
| tree | 56f4459718d9fe134c6655ebd57333c35b152852 | |
| parent | 652fb4118862e26bb820ddd08de8fcf7fd2a974f (diff) | |
o wan/cycx: fix module refcounting, removing MOD_{INC,DEC}_USE_COUNT
| -rw-r--r-- | drivers/net/wan/cycx_main.c | 24 | ||||
| -rw-r--r-- | drivers/net/wan/cycx_x25.c | 26 | ||||
| -rw-r--r-- | include/linux/cyclomx.h | 7 |
3 files changed, 13 insertions, 44 deletions
diff --git a/drivers/net/wan/cycx_main.c b/drivers/net/wan/cycx_main.c index b945dccb1578..9731a6e74b17 100644 --- a/drivers/net/wan/cycx_main.c +++ b/drivers/net/wan/cycx_main.c @@ -335,30 +335,6 @@ static irqreturn_t cycx_isr (int irq, void *dev_id, struct pt_regs *regs) out: return IRQ_NONE; } -/* - * This routine is called by the protocol-specific modules when network - * interface is being open. The only reason we need this, is because we - * have to call MOD_INC_USE_COUNT, but cannot include 'module.h' where it's - * defined more than once into the same kernel module. - */ -void cyclomx_mod_inc_use_count(struct cycx_device *card) -{ - ++card->open_cnt; - MOD_INC_USE_COUNT; -} - -/* - * This routine is called by the protocol-specific modules when network - * interface is being closed. The only reason we need this, is because we - * have to call MOD_DEC_USE_COUNT, but cannot include 'module.h' where it's - * defined more than once into the same kernel module. - */ -void cyclomx_mod_dec_use_count(struct cycx_device *card) -{ - --card->open_cnt; - MOD_DEC_USE_COUNT; -} - /* Set WAN device state. */ void cyclomx_set_state(struct cycx_device *card, int state) { diff --git a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c index 090c417c0f7f..57e84b3e1edf 100644 --- a/drivers/net/wan/cycx_x25.c +++ b/drivers/net/wan/cycx_x25.c @@ -79,14 +79,17 @@ #define CYCLOMX_X25_DEBUG 1 #include <linux/version.h> -#include <linux/kernel.h> /* printk(), and other useful stuff */ -#include <linux/stddef.h> /* offsetof(), etc. */ #include <linux/errno.h> /* return codes */ +#include <linux/if_arp.h> /* ARPHRD_HWX25 */ +#include <linux/kernel.h> /* printk(), and other useful stuff */ +#include <linux/module.h> /* SET_MODULE_OWNER */ #include <linux/string.h> /* inline memset(), etc. */ -#include <linux/slab.h> /* kmalloc(), kfree() */ +#include <linux/slab.h> /* kmalloc(), kfree() */ +#include <linux/stddef.h> /* offsetof(), etc. */ #include <linux/wanrouter.h> /* WAN router definitions */ + #include <asm/byteorder.h> /* htons(), etc. */ -#include <linux/if_arp.h> /* ARPHRD_HWX25 */ + #include <linux/cyclomx.h> /* Cyclom 2X common user API definitions */ #include <linux/cycx_x25.h> /* X.25 firmware API definitions */ @@ -458,7 +461,7 @@ static int del_if(struct wan_device *wandev, struct net_device *dev) * This routine is called only once for each interface, during Linux network * interface registration. Returning anything but zero will fail interface * registration. */ -static int if_init (struct net_device *dev) +static int if_init(struct net_device *dev) { x25_channel_t *chan = dev->priv; struct cycx_device *card = chan->card; @@ -491,6 +494,7 @@ static int if_init (struct net_device *dev) /* Set transmit buffer queue length */ dev->tx_queue_len = 10; + SET_MODULE_OWNER(dev); /* Initialize socket buffers */ set_chan_state(dev, WAN_DISCONNECTED); @@ -503,35 +507,27 @@ static int if_init (struct net_device *dev) * o if link is disconnected then initiate connection * * Return 0 if O.k. or errno. */ -static int if_open (struct net_device *dev) +static int if_open(struct net_device *dev) { - x25_channel_t *chan = dev->priv; - struct cycx_device *card = chan->card; - if (netif_running(dev)) return -EBUSY; /* only one open is allowed */ netif_start_queue(dev); - cyclomx_mod_inc_use_count(card); - return 0; } /* Close network interface. * o reset flags. * o if there's no more open channels then disconnect physical link. */ -static int if_close (struct net_device *dev) +static int if_close(struct net_device *dev) { x25_channel_t *chan = dev->priv; - struct cycx_device *card = chan->card; netif_stop_queue(dev); if (chan->state == WAN_CONNECTED || chan->state == WAN_CONNECTING) chan_disconnect(dev); - cyclomx_mod_dec_use_count(card); - return 0; } diff --git a/include/linux/cyclomx.h b/include/linux/cyclomx.h index 6e09c3670de0..a19aeebe7192 100644 --- a/include/linux/cyclomx.h +++ b/include/linux/cyclomx.h @@ -1,3 +1,5 @@ +#ifndef _CYCLOMX_H +#define _CYCLOMX_H /* * cyclomx.h Cyclom 2X WAN Link Driver. * User-level API definitions. @@ -21,8 +23,6 @@ * 1998/12/27 acme cleanup: PACKED not needed * 1998/08/08 acme Version 0.0.1 */ -#ifndef _CYCLOMX_H -#define _CYCLOMX_H #include <linux/config.h> #include <linux/wanrouter.h> @@ -47,7 +47,6 @@ struct cycx_device { char devname[WAN_DRVNAME_SZ+1]; /* card name */ cycxhw_t hw; /* hardware configuration */ struct wan_device wandev; /* WAN device data space */ - u32 open_cnt; /* number of open interfaces */ u32 state_tick; /* link state timestamp */ spinlock_t lock; char in_isr; /* interrupt-in-service flag */ @@ -72,8 +71,6 @@ struct cycx_device { }; /* Public Functions */ -void cyclomx_mod_inc_use_count(struct cycx_device *card); -void cyclomx_mod_dec_use_count(struct cycx_device *card); void cyclomx_set_state(struct cycx_device *card, int state); #ifdef CONFIG_CYCLOMX_X25 |
