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