Commit b3eade62 authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Linus Torvalds

[PATCH] pcmcia: BUG on dev_list != NULL

All in-kernel PCMCIA devices do unregister their client in their respective
->detach() function after a REMOVAL event.  So, AFAICS, the dev_list iteration
should always be false.
Signed-off-by: default avatarDominik Brodowski <linux@brodo.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 50d26851
......@@ -1117,10 +1117,7 @@ static int __init init_bluecard_cs(void)
static void __exit exit_bluecard_cs(void)
{
pcmcia_unregister_driver(&bluecard_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL)
bluecard_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_bluecard_cs);
......
......@@ -967,10 +967,7 @@ static int __init init_bt3c_cs(void)
static void __exit exit_bt3c_cs(void)
{
pcmcia_unregister_driver(&bt3c_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL)
bt3c_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_bt3c_cs);
......
......@@ -887,10 +887,7 @@ static int __init init_btuart_cs(void)
static void __exit exit_btuart_cs(void)
{
pcmcia_unregister_driver(&btuart_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL)
btuart_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_btuart_cs);
......
......@@ -839,10 +839,7 @@ static int __init init_dtl1_cs(void)
static void __exit exit_dtl1_cs(void)
{
pcmcia_unregister_driver(&dtl1_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL)
dtl1_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_dtl1_cs);
......
......@@ -3147,13 +3147,7 @@ static void synclink_cs_cleanup(void)
}
pcmcia_unregister_driver(&mgslpc_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL) {
if (dev_list->state & DEV_CONFIG)
mgslpc_release((u_long)dev_list);
mgslpc_detach(dev_list);
}
BUG_ON(dev_list != NULL);
}
static int __init synclink_cs_init(void)
......
......@@ -485,8 +485,7 @@ static int __init init_ide_cs(void)
static void __exit exit_ide_cs(void)
{
pcmcia_unregister_driver(&ide_cs_driver);
while (dev_list != NULL)
ide_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_ide_cs);
......
......@@ -521,13 +521,7 @@ static int __init avmcs_init(void)
static void __exit avmcs_exit(void)
{
pcmcia_unregister_driver(&avmcs_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL) {
if (dev_list->state & DEV_CONFIG)
avmcs_release(dev_list);
avmcs_detach(dev_list);
}
BUG_ON(dev_list != NULL);
}
module_init(avmcs_init);
......
......@@ -531,13 +531,7 @@ static int __init init_avma1_cs(void)
static void __exit exit_avma1_cs(void)
{
pcmcia_unregister_driver(&avma1cs_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL) {
if (dev_list->state & DEV_CONFIG)
avma1cs_release(dev_list);
avma1cs_detach(dev_list);
}
BUG_ON(dev_list != NULL);
}
module_init(init_avma1_cs);
......
......@@ -541,10 +541,7 @@ static int __init init_elsa_cs(void)
static void __exit exit_elsa_cs(void)
{
pcmcia_unregister_driver(&elsa_cs_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL)
elsa_cs_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_elsa_cs);
......
......@@ -648,13 +648,7 @@ static int __init init_sedlbauer_cs(void)
static void __exit exit_sedlbauer_cs(void)
{
pcmcia_unregister_driver(&sedlbauer_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL) {
if (dev_list->state & DEV_CONFIG)
sedlbauer_release(dev_list);
sedlbauer_detach(dev_list);
}
BUG_ON(dev_list != NULL);
}
module_init(init_sedlbauer_cs);
......
......@@ -522,10 +522,7 @@ static int __init init_teles_cs(void)
static void __exit exit_teles_cs(void)
{
pcmcia_unregister_driver(&teles_cs_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL)
teles_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_teles_cs);
......
......@@ -854,35 +854,7 @@ static void __exit exit_pcmciamtd(void)
{
DEBUG(1, DRIVER_DESC " unloading");
pcmcia_unregister_driver(&pcmciamtd_driver);
while(dev_list) {
dev_link_t *link = dev_list;
dev_list = link->next;
if (link) {
struct pcmciamtd_dev *dev = link->priv;
if(dev) {
if(link->state & DEV_PRESENT) {
if (!(link->state & DEV_STALE_LINK)) {
pcmciamtd_detach(link);
}
link->state &= ~DEV_PRESENT;
if(dev->mtd_info) {
del_mtd_device(dev->mtd_info);
info("mtd%d: Removed",
dev->mtd_info->index);
}
}
if(dev->mtd_info) {
DEBUG(2, "Destroying map for mtd%d",
dev->mtd_info->index);
map_destroy(dev->mtd_info);
}
kfree(dev);
}
}
}
BUG_ON(dev_list != NULL);
}
module_init(init_pcmciamtd);
......
......@@ -1308,8 +1308,7 @@ static int __init init_tc574(void)
static void __exit exit_tc574(void)
{
pcmcia_unregister_driver(&tc574_driver);
while (dev_list != NULL)
tc574_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_tc574);
......
......@@ -1083,8 +1083,7 @@ static int __init init_tc589(void)
static void __exit exit_tc589(void)
{
pcmcia_unregister_driver(&tc589_driver);
while (dev_list != NULL)
tc589_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_tc589);
......
......@@ -877,8 +877,7 @@ static int __init init_axnet_cs(void)
static void __exit exit_axnet_cs(void)
{
pcmcia_unregister_driver(&axnet_cs_driver);
while (dev_list != NULL)
axnet_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_axnet_cs);
......
......@@ -513,8 +513,7 @@ static int __init init_com20020_cs(void)
static void __exit exit_com20020_cs(void)
{
pcmcia_unregister_driver(&com20020_cs_driver);
while (dev_list != NULL)
com20020_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_com20020_cs);
......
......@@ -792,8 +792,7 @@ static int __init init_fmvj18x_cs(void)
static void __exit exit_fmvj18x_cs(void)
{
pcmcia_unregister_driver(&fmvj18x_cs_driver);
while (dev_list != NULL)
fmvj18x_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_fmvj18x_cs);
......
......@@ -538,8 +538,7 @@ static int __init init_ibmtr_cs(void)
static void __exit exit_ibmtr_cs(void)
{
pcmcia_unregister_driver(&ibmtr_cs_driver);
while (dev_list != NULL)
ibmtr_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_ibmtr_cs);
......
......@@ -1702,8 +1702,7 @@ static int __init init_nmclan_cs(void)
static void __exit exit_nmclan_cs(void)
{
pcmcia_unregister_driver(&nmclan_cs_driver);
while (dev_list != NULL)
nmclan_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_nmclan_cs);
......
......@@ -1662,8 +1662,7 @@ static void __exit exit_pcnet_cs(void)
{
DEBUG(0, "pcnet_cs: unloading\n");
pcmcia_unregister_driver(&pcnet_driver);
while (dev_list != NULL)
pcnet_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_pcnet_cs);
......
......@@ -2263,8 +2263,7 @@ static int __init init_smc91c92_cs(void)
static void __exit exit_smc91c92_cs(void)
{
pcmcia_unregister_driver(&smc91c92_cs_driver);
while (dev_list != NULL)
smc91c92_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_smc91c92_cs);
......
......@@ -2016,9 +2016,7 @@ static void __exit
exit_xirc2ps_cs(void)
{
pcmcia_unregister_driver(&xirc2ps_cs_driver);
while (dev_list)
xirc2ps_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_xirc2ps_cs);
......
......@@ -592,13 +592,7 @@ static int airo_cs_init(void)
static void airo_cs_cleanup(void)
{
pcmcia_unregister_driver(&airo_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL) {
if (dev_list->state & DEV_CONFIG)
airo_release(dev_list);
airo_detach(dev_list);
}
BUG_ON(dev_list != NULL);
}
/*
......
......@@ -693,13 +693,7 @@ static int atmel_cs_init(void)
static void atmel_cs_cleanup(void)
{
pcmcia_unregister_driver(&atmel_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL) {
if (dev_list->state & DEV_CONFIG)
atmel_release(dev_list);
atmel_detach(dev_list);
}
BUG_ON(dev_list != NULL);
}
/*
......
......@@ -1696,9 +1696,7 @@ static int __init init_netwave_cs(void)
static void __exit exit_netwave_cs(void)
{
pcmcia_unregister_driver(&netwave_driver);
if (dev_list != NULL) /* Critical situation */
printk("netwave_cs: devices remaining when removing module\n");
BUG_ON(dev_list != NULL);
}
module_init(init_netwave_cs);
......
......@@ -653,14 +653,7 @@ static void __exit
exit_orinoco_cs(void)
{
pcmcia_unregister_driver(&orinoco_driver);
if (dev_list)
DEBUG(0, PFX "Removing leftover devices.\n");
while (dev_list != NULL) {
if (dev_list->state & DEV_CONFIG)
orinoco_cs_release(dev_list);
orinoco_cs_detach(dev_list);
}
BUG_ON(dev_list != NULL);
}
module_init(init_orinoco_cs);
......
......@@ -2952,8 +2952,7 @@ static void __exit exit_ray_cs(void)
#endif
pcmcia_unregister_driver(&ray_driver);
while (dev_list != NULL)
ray_detach(dev_list);
BUG_ON(dev_list != NULL);
} /* exit_ray_cs */
module_init(init_ray_cs);
......
......@@ -2267,13 +2267,7 @@ static void __exit wl3501_exit_module(void)
{
dprintk(0, ": unloading");
pcmcia_unregister_driver(&wl3501_driver);
while (wl3501_dev_list) {
/* Mark the device as non-existing to minimize calls to card */
wl3501_dev_list->state &= ~DEV_PRESENT;
if (wl3501_dev_list->state & DEV_CONFIG)
wl3501_release(wl3501_dev_list);
wl3501_detach(wl3501_dev_list);
}
BUG_ON(wl3501_dev_list != NULL);
}
module_init(wl3501_init_module);
......
......@@ -401,10 +401,7 @@ static int __init init_parport_cs(void)
static void __exit exit_parport_cs(void)
{
pcmcia_unregister_driver(&parport_cs_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL)
parport_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_parport_cs);
......
......@@ -347,10 +347,7 @@ static int __init init_aha152x_cs(void)
static void __exit exit_aha152x_cs(void)
{
pcmcia_unregister_driver(&aha152x_cs_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL)
aha152x_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_aha152x_cs);
......
......@@ -328,10 +328,7 @@ static int __init init_fdomain_cs(void)
static void __exit exit_fdomain_cs(void)
{
pcmcia_unregister_driver(&fdomain_cs_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL)
fdomain_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_fdomain_cs);
......
......@@ -2194,10 +2194,9 @@ static void __exit nsp_cs_exit(void)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,68))
pcmcia_unregister_driver(&nsp_driver);
BUG_ON(dev_list != NULL);
#else
unregister_pcmcia_driver(&dev_info);
#endif
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL) {
if (dev_list->state & DEV_CONFIG) {
......@@ -2205,6 +2204,7 @@ static void __exit nsp_cs_exit(void)
}
nsp_cs_detach(dev_list);
}
#endif
}
......
......@@ -432,10 +432,7 @@ static int __init init_qlogic_cs(void)
static void __exit exit_qlogic_cs(void)
{
pcmcia_unregister_driver(&qlogic_cs_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL)
qlogic_detach(dev_list);
BUG_ON(dev_list != NULL);
}
MODULE_AUTHOR("Tom Zerucha, Michael Griffith");
......
......@@ -749,10 +749,7 @@ static int __init init_serial_cs(void)
static void __exit exit_serial_cs(void)
{
pcmcia_unregister_driver(&serial_cs_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL)
serial_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(init_serial_cs);
......
......@@ -313,10 +313,7 @@ static int __init ixj_pcmcia_init(void)
static void ixj_pcmcia_exit(void)
{
pcmcia_unregister_driver(&ixj_driver);
/* XXX: this really needs to move into generic code.. */
while (dev_list != NULL)
ixj_detach(dev_list);
BUG_ON(dev_list != NULL);
}
module_init(ixj_pcmcia_init);
......
......@@ -273,15 +273,6 @@ static void snd_pdacf_detach(dev_link_t *link)
snd_card_free_in_thread(chip->card);
}
/*
* snd_pdacf_detach_all - detach all instances linked to the hw
*/
static void snd_pdacf_detach_all(void)
{
while (dev_list != NULL)
snd_pdacf_detach(dev_list);
}
/*
* configuration callback
*/
......@@ -413,7 +404,7 @@ static int __init init_pdacf(void)
static void __exit exit_pdacf(void)
{
pcmcia_unregister_driver(&pdacf_cs_driver);
snd_pdacf_detach_all();
BUG_ON(dev_list != NULL);
}
module_init(init_pdacf);
......
......@@ -265,15 +265,6 @@ void snd_vxpocket_detach(struct snd_vxp_entry *hw, dev_link_t *link)
snd_card_free_in_thread(chip->card);
}
/*
* snd_vxpocket_detach_all - detach all instances linked to the hw
*/
void snd_vxpocket_detach_all(struct snd_vxp_entry *hw)
{
while (hw->dev_list != NULL)
snd_vxpocket_detach(hw, hw->dev_list);
}
/*
* configuration callback
*/
......@@ -397,4 +388,3 @@ static int vxpocket_event(event_t event, int priority, event_callback_args_t *ar
EXPORT_SYMBOL(snd_vxpocket_ops);
EXPORT_SYMBOL(snd_vxpocket_attach);
EXPORT_SYMBOL(snd_vxpocket_detach);
EXPORT_SYMBOL(snd_vxpocket_detach_all);
......@@ -165,7 +165,7 @@ static int __init init_vxpocket(void)
static void __exit exit_vxpocket(void)
{
pcmcia_unregister_driver(&vxp_cs_driver);
snd_vxpocket_detach_all(&hw_entry);
BUG_ON(hw_entry.dev_list != NULL);
}
module_init(init_vxpocket);
......
......@@ -77,7 +77,6 @@ void vx_set_mic_level(vx_core_t *chip, int level);
*/
dev_link_t *snd_vxpocket_attach(struct snd_vxp_entry *hw);
void snd_vxpocket_detach(struct snd_vxp_entry *hw, dev_link_t *link);
void snd_vxpocket_detach_all(struct snd_vxp_entry *hw);
int vxp_add_mic_controls(vx_core_t *chip);
......
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