o wan/cycx: fix module refcounting, removing MOD_{INC,DEC}_USE_COUNT

parent 652fb411
......@@ -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)
{
......
......@@ -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/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;
}
......
#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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment