diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c index 9d757ce3f8eccfaf6878ad27378c422de6f01063..0ee467e1c48a6b75c38b6a03d3efb483efbfa6d8 100644 --- a/drivers/input/joystick/db9.c +++ b/drivers/input/joystick/db9.c @@ -531,9 +531,7 @@ static struct db9 __init *db9_probe(int *config) return NULL; } - for (pp = parport_enumerate(); pp && (config[0] > 0); pp = pp->next) - config[0]--; - + pp = parport_find_number(config[0]); if (!pp) { printk(KERN_ERR "db9.c: no such parport\n"); return NULL; @@ -542,12 +540,15 @@ static struct db9 __init *db9_probe(int *config) if (db9_bidirectional[config[1]]) { if (!(pp->modes & PARPORT_MODE_TRISTATE)) { printk(KERN_ERR "db9.c: specified parport is not bidirectional\n"); + parport_put_port(pp); return NULL; } } - if (!(db9 = kmalloc(sizeof(struct db9), GFP_KERNEL))) + if (!(db9 = kmalloc(sizeof(struct db9), GFP_KERNEL))) { + parport_put_port(pp); return NULL; + } memset(db9, 0, sizeof(struct db9)); db9->mode = config[1]; @@ -556,6 +557,7 @@ static struct db9 __init *db9_probe(int *config) db9->timer.function = db9_timer; db9->pd = parport_register_device(pp, "db9", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); + parport_put_port(pp); if (!db9->pd) { printk(KERN_ERR "db9.c: parport busy already - lp.o loaded?\n"); diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c index ec5ece71ab62ae0464165bd2728c4478ba0a8a46..ae94ab8141d914ab5fed2f12f2e2542cfdef3b62 100644 --- a/drivers/input/joystick/gamecon.c +++ b/drivers/input/joystick/gamecon.c @@ -478,20 +478,23 @@ static struct gc __init *gc_probe(int *config) if (config[0] < 0) return NULL; - for (pp = parport_enumerate(); pp && (config[0] > 0); pp = pp->next) - config[0]--; + pp = parport_find_number(config[0]); if (!pp) { printk(KERN_ERR "gamecon.c: no such parport\n"); return NULL; } - if (!(gc = kmalloc(sizeof(struct gc), GFP_KERNEL))) + if (!(gc = kmalloc(sizeof(struct gc), GFP_KERNEL))) { + parport_put_port(pp); return NULL; + } memset(gc, 0, sizeof(struct gc)); gc->pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); + parport_put_port(pp); + if (!gc->pd) { printk(KERN_ERR "gamecon.c: parport busy already - lp.o loaded?\n"); kfree(gc); diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c index 5ad4f8e44f8ca91cafb338d3bcc2f31a1ad605c5..718e8f706a9d3087940cc64f95b442a3be623eb1 100644 --- a/drivers/input/joystick/turbografx.c +++ b/drivers/input/joystick/turbografx.c @@ -142,19 +142,22 @@ static struct tgfx __init *tgfx_probe(int *config) if (config[0] < 0) return NULL; - for (pp = parport_enumerate(); pp && (config[0] > 0); pp = pp->next) - config[0]--; + pp = parport_find_number(config[0]); if (!pp) { printk(KERN_ERR "turbografx.c: no such parport\n"); return NULL; } - if (!(tgfx = kmalloc(sizeof(struct tgfx), GFP_KERNEL))) + if (!(tgfx = kmalloc(sizeof(struct tgfx), GFP_KERNEL))) { + parport_put_port(pp); return NULL; + } memset(tgfx, 0, sizeof(struct tgfx)); tgfx->pd = parport_register_device(pp, "turbografx", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); + + parport_put_port(pp); if (!tgfx->pd) { printk(KERN_ERR "turbografx.c: parport busy already - lp.o loaded?\n"); diff --git a/drivers/input/serio/parkbd.c b/drivers/input/serio/parkbd.c index 1ee9e623151d676bd4aa8d0a48f0651cdc062062..1df2dd1d275eb044f15b40957861d867c8fe079b 100644 --- a/drivers/input/serio/parkbd.c +++ b/drivers/input/serio/parkbd.c @@ -151,7 +151,7 @@ static int parkbd_getport(void) return -ENODEV; } - for (pp = parport_enumerate(); pp != NULL && (parkbd > 0); pp = pp->next) parkbd--; + pp = parport_find_number(parkbd); if (pp == NULL) { printk(KERN_ERR "parkbd: no such parport\n"); @@ -159,6 +159,7 @@ static int parkbd_getport(void) } parkbd_dev = parport_register_device(pp, "parkbd", NULL, NULL, parkbd_interrupt, PARPORT_DEV_EXCL, NULL); + parport_put_port(pp); if (!parkbd_dev) return -ENODEV; diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c index 7cbeb3407b246bbbd648ebcbfeafc58224c5aa00..5c688177fef7e7aacaa8103a61178f48f42a22cf 100644 --- a/drivers/net/hamradio/baycom_epp.c +++ b/drivers/net/hamradio/baycom_epp.c @@ -991,9 +991,7 @@ static int epp_open(struct net_device *dev) baycom_paranoia_check(dev, "epp_open", -ENXIO); bc = (struct baycom_state *)dev->priv; - pp = parport_enumerate(); - while (pp && pp->base != dev->base_addr) - pp = pp->next; + pp = parport_find_base(dev->base_addr); if (!pp) { printk(KERN_ERR "%s: parport at 0x%lx unknown\n", bc_drvname, dev->base_addr); return -ENXIO; @@ -1001,17 +999,21 @@ static int epp_open(struct net_device *dev) #if 0 if (pp->irq < 0) { printk(KERN_ERR "%s: parport at 0x%lx has no irq\n", bc_drvname, pp->base); + parport_put_port(pp); return -ENXIO; } #endif if ((~pp->modes) & (PARPORT_MODE_TRISTATE | PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT)) { printk(KERN_ERR "%s: parport at 0x%lx cannot be used\n", bc_drvname, pp->base); + parport_put_port(pp); return -EIO; } memset(&bc->modem, 0, sizeof(bc->modem)); - if (!(bc->pdev = parport_register_device(pp, dev->name, NULL, epp_wakeup, - epp_interrupt, PARPORT_DEV_EXCL, dev))) { + bc->pdev = parport_register_device(pp, dev->name, NULL, epp_wakeup, + epp_interrupt, PARPORT_DEV_EXCL, dev); + parport_put_port(pp); + if (!bc->pdev) { printk(KERN_ERR "%s: cannot register parport at 0x%lx\n", bc_drvname, pp->base); return -ENXIO; } diff --git a/drivers/net/hamradio/baycom_par.c b/drivers/net/hamradio/baycom_par.c index 40d96a51dce67cd0402920ba3b75c3af56077851..fa910d9229d52ef5169415ff0efd745d7d89484f 100644 --- a/drivers/net/hamradio/baycom_par.c +++ b/drivers/net/hamradio/baycom_par.c @@ -314,29 +314,32 @@ static void par96_wakeup(void *handle) static int par96_open(struct net_device *dev) { struct baycom_state *bc = (struct baycom_state *)dev->priv; - struct parport *pp = parport_enumerate(); + struct parport *pp; if (!dev || !bc) return -ENXIO; - while (pp && pp->base != dev->base_addr) - pp = pp->next; + pp = parport_find_base(dev->base_addr); if (!pp) { printk(KERN_ERR "baycom_par: parport at 0x%lx unknown\n", dev->base_addr); return -ENXIO; } if (pp->irq < 0) { printk(KERN_ERR "baycom_par: parport at 0x%lx has no irq\n", pp->base); + parport_put_port(pp); return -ENXIO; } if ((~pp->modes) & (PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT)) { printk(KERN_ERR "baycom_par: parport at 0x%lx cannot be used\n", pp->base); + parport_put_port(pp); return -ENXIO; } memset(&bc->modem, 0, sizeof(bc->modem)); bc->hdrv.par.bitrate = 9600; - if (!(bc->pdev = parport_register_device(pp, dev->name, NULL, par96_wakeup, - par96_interrupt, PARPORT_DEV_EXCL, dev))) { - printk(KERN_ERR "baycom_par: cannot register parport at 0x%lx\n", pp->base); + bc->pdev = parport_register_device(pp, dev->name, NULL, par96_wakeup, + par96_interrupt, PARPORT_DEV_EXCL, dev); + parport_put_port(pp); + if (!bc->pdev) { + printk(KERN_ERR "baycom_par: cannot register parport at 0x%lx\n", dev->base_addr); return -ENXIO; } if (parport_claim(bc->pdev)) {