Commit ca58c4b6 authored by Christoph Hellwig's avatar Christoph Hellwig

[PATCH] remove MOD_IN_USE

Another left-over from ancient module code, it was supposed to return
non-zero if the module has a use count, but currently it always
evaluates to 0.

There are a few users of different types:
(1)  ioctl that perform a while(MOD_IN_USE) MOD_DEC_USE_COUNT loop.
     Just rip them out, we now have forced module unloading.
(2)  printk's that moan if the use-count in not zero in the exitfunc.
     Just rip them out, this can't happen.
(3)  if(MOD_IN_USE) MOD_DEC_USE_COUNT constructs in ->close of a few
     serial drivers.  Just remove the conditional, we did a
     MOD_INC_USE_COUNT in ->open.
(4)  This one is interesting:  drivers/sbus/char/display7seg.c uses
     the module use count to track openers.  Replace this with an
     atomic_t.

In addition remove tons of stale comments in network driver that aren't
understandable for anyone who doesn't know ancient Linux module semantics.
parent cf34d923
......@@ -345,9 +345,6 @@ static void __exit nicstar_module_exit(void)
XPRINTK("nicstar: cleanup_module() called.\n");
if (MOD_IN_USE)
printk("nicstar: module in use, remove delayed.\n");
del_timer(&ns_timer);
for (i = 0; i < NS_MAX_CARDS; i++)
......
......@@ -2513,10 +2513,6 @@ int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg)
return get_stats(info,(struct mgsl_icount*)arg);
case MGSL_IOCWAITEVENT:
return wait_events(info,(int*)arg);
case MGSL_IOCCLRMODCOUNT:
while(MOD_IN_USE)
MOD_DEC_USE_COUNT;
return 0;
case TIOCMIWAIT:
return modem_input_wait(info,(int)arg);
case TIOCGICOUNT:
......@@ -2694,8 +2690,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
if (debug_level >= DEBUG_LEVEL_INFO)
printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
tty->driver.name, info->count);
if(MOD_IN_USE)
MOD_DEC_USE_COUNT;
MOD_DEC_USE_COUNT;
}
/* Wait until the transmitter is empty.
......@@ -3003,8 +2998,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
cleanup:
if (retval) {
if(MOD_IN_USE)
MOD_DEC_USE_COUNT;
MOD_DEC_USE_COUNT;
if(info->count)
info->count--;
}
......
......@@ -3119,11 +3119,6 @@ int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long
return mgsl_wait_event(info,(int*)arg);
case MGSL_IOCLOOPTXDONE:
return mgsl_loopmode_send_done(info);
case MGSL_IOCCLRMODCOUNT:
while(MOD_IN_USE)
MOD_DEC_USE_COUNT;
return 0;
/* Wait for modem input (DCD,RI,DSR,CTS) change
* as specified by mask in arg (TIOCM_RNG/DSR/CD/CTS)
*/
......@@ -3328,8 +3323,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
if (debug_level >= DEBUG_LEVEL_INFO)
printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
tty->driver.name, info->count);
if(MOD_IN_USE)
MOD_DEC_USE_COUNT;
MOD_DEC_USE_COUNT;
} /* end of mgsl_close() */
......@@ -3689,8 +3683,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
cleanup:
if (retval) {
if(MOD_IN_USE)
MOD_DEC_USE_COUNT;
MOD_DEC_USE_COUNT;
if(info->count)
info->count--;
}
......
......@@ -826,8 +826,7 @@ static int open(struct tty_struct *tty, struct file *filp)
cleanup:
if (retval) {
if(MOD_IN_USE)
MOD_DEC_USE_COUNT;
MOD_DEC_USE_COUNT;
if(info->count)
info->count--;
}
......@@ -926,8 +925,7 @@ static void close(struct tty_struct *tty, struct file *filp)
if (debug_level >= DEBUG_LEVEL_INFO)
printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
tty->driver.name, info->count);
if(MOD_IN_USE)
MOD_DEC_USE_COUNT;
MOD_DEC_USE_COUNT;
}
/* Called by tty_hangup() when a hangup is signaled.
......@@ -1415,10 +1413,6 @@ static int ioctl(struct tty_struct *tty, struct file *file,
return wait_mgsl_event(info,(int*)arg);
case MGSL_IOCLOOPTXDONE:
return 0; // TODO: Not supported, need to document
case MGSL_IOCCLRMODCOUNT:
while(MOD_IN_USE)
MOD_DEC_USE_COUNT;
return 0;
/* Wait for modem input (DCD,RI,DSR,CTS) change
* as specified by mask in arg (TIOCM_RNG/DSR/CD/CTS)
*/
......
......@@ -981,10 +981,6 @@ int init_module(void)
void cleanup_module(void)
{
/*
* No need to check MOD_IN_USE, as sys_delete_module() checks.
*/
unregister_netdev(&dev_3c501);
/*
......
......@@ -1558,7 +1558,6 @@ static void __exit el3_cleanup_module(void)
{
struct net_device *next_dev;
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
while (el3_root_dev) {
struct el3_private *lp = (struct el3_private *)el3_root_dev->priv;
......
......@@ -1666,7 +1666,6 @@ void cleanup_module(void)
{
struct net_device *next_dev;
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
while (root_corkscrew_dev) {
next_dev =
((struct corkscrew_private *) root_corkscrew_dev->
......
......@@ -1773,7 +1773,6 @@ void cleanup_module(void)
{
int slot;
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
unregister_netdev(&this_device);
/*
......
......@@ -1043,7 +1043,6 @@ int init_module(void)
void cleanup_module(void)
{
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
unregister_netdev(&cops0_dev);
kfree(cops0_dev.priv);
if(cops0_dev.irq)
......
......@@ -1960,7 +1960,6 @@ static void __devexit hamachi_remove_one (struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
if (dev) {
struct hamachi_private *hmp = dev->priv;
......
......@@ -659,7 +659,6 @@ int init_module(void)
void
cleanup_module(void)
{
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
unregister_netdev(&this_device);
/*
* If we don't do this, we can't re-insmod it later.
......
......@@ -1137,7 +1137,6 @@ static int __init myri_sbus_probe(void)
static void __exit myri_sbus_cleanup(void)
{
#ifdef MODULE
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
while (root_myri_dev) {
struct myri_eth *next = root_myri_dev->next_module;
......
......@@ -1737,7 +1737,6 @@ static void __exit pcnet32_cleanup_module(void)
{
struct net_device *next_dev;
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
while (pcnet32_dev) {
struct pcnet32_private *lp = pcnet32_dev->priv;
next_dev = lp->next;
......
......@@ -247,7 +247,6 @@ cleanup_module(void)
{
struct ptifddi *pp;
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
while (root_pti_dev) {
pp = root_pti_dev->next_module;
......
......@@ -733,10 +733,6 @@ int init_module(void)
void cleanup_module(void)
{
/*
* No need to check MOD_IN_USE, as sys_delete_module() checks.
*/
unregister_netdev(&dev_seeq);
/*
......
......@@ -1274,11 +1274,6 @@ void cleanup_module(void)
skmca_priv *priv;
int z;
if (MOD_IN_USE) {
printk("cannot unload, module in use\n");
return;
}
for (z = 0; z < DEVMAX; z++) {
dev = moddevs + z;
if (dev->priv != NULL) {
......
......@@ -1557,7 +1557,6 @@ int init_module(void)
void cleanup_module(void)
{
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
unregister_netdev(&devSMC9194);
free_irq(devSMC9194.irq, &devSMC9194);
......
......@@ -1734,7 +1734,6 @@ static void __devexit sundance_remove1 (struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
if (dev) {
struct netdev_private *np = dev->priv;
......
......@@ -1755,7 +1755,6 @@ static void __exit tc35815_cleanup_module(void)
{
struct net_device *next_dev;
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
while (root_tc35815_dev) {
struct net_device *dev = root_tc35815_dev;
next_dev = ((struct tc35815_local *)dev->priv)->next_module;
......
......@@ -1612,7 +1612,6 @@ static void __devexit w840_remove1 (struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
if (dev) {
unregister_netdev(dev);
pci_release_regions(pdev);
......
......@@ -1501,7 +1501,6 @@ cleanup_module( void )
struct net_device *dev;
int num;
/* No need to check MOD_IN_USE, as sys_delete_module( ) checks. */
for( num = 0; num < SBNI_MAX_NUM_CARDS; ++num )
if( (dev = sbni_cards[ num ]) != NULL ) {
unregister_netdev( dev );
......
......@@ -16,6 +16,7 @@
#include <linux/init.h>
#include <linux/miscdevice.h>
#include <linux/ioport.h> /* request_region, check_region */
#include <asm/atomic.h>
#include <asm/ebus.h> /* EBus device */
#include <asm/oplib.h> /* OpenProm Library */
#include <asm/uaccess.h> /* put_/get_user */
......@@ -86,27 +87,23 @@ static inline int d7s_obpflipped(void)
return ((-1 != prom_getintdefault(opt_node, "d7s-flipped?", -1)) ? 0 : 1);
}
static atomic_t d7s_users = ATOMIC_INIT(0);
static int d7s_open(struct inode *inode, struct file *f)
{
if (D7S_MINOR != minor(inode->i_rdev))
return -ENODEV;
MOD_INC_USE_COUNT;
atomic_inc(&d7s_users);
return 0;
}
static int d7s_release(struct inode *inode, struct file *f)
{
if (D7S_MINOR != minor(inode->i_rdev))
return -ENODEV;
MOD_DEC_USE_COUNT;
/* Reset flipped state to OBP default only if
* no other users have the device open and we
* are not operating in solaris-compat mode
*/
if (0 == MOD_IN_USE && 0 == sol_compat) {
if (atomic_dec_and_test(&d7s_users) && !sol_compat) {
int regval = 0;
regval = readb(d7s_regs);
......
......@@ -437,7 +437,6 @@ static inline void __deprecated _MOD_INC_USE_COUNT(struct module *module)
#endif
}
#define EXPORT_NO_SYMBOLS
#define MOD_IN_USE 0
#define __MODULE_STRING(x) __stringify(x)
/*
......
......@@ -1424,10 +1424,6 @@ void cleanup_module(void)
struct atm_mpoa_qos *qos, *nextqos;
struct lec_priv *priv;
if (MOD_IN_USE) {
printk("mpc.c: module in use\n");
return;
}
#ifdef CONFIG_PROC_FS
mpc_proc_clean();
#endif
......
......@@ -599,9 +599,6 @@ static void __exit oss_cleanup(void)
{
int i, j;
if (MOD_IN_USE)
return;
for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
devfs_remove("snd/%s", dev_list[i].name);
if (!dev_list[i].num)
......
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