The patch titled Char: istallion, convert to pci probing has been added to the -mm tree. Its filename is char-istallion-convert-to-pci-probing.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: Char: istallion, convert to pci probing From: Jiri Slaby <jirislaby@xxxxxxxxx> Use probing for pci devices. Change some __inits to __devinits to use these functions in probe function. Create stli_cleanup_ports and move there cleanup code from module_exit() code to not have duplicite cleanup code. Signed-off-by: Jiri Slaby <jirislaby@xxxxxxxxx> Cc: Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- drivers/char/istallion.c | 114 +++++++++++++++++++++---------------- 1 files changed, 66 insertions(+), 48 deletions(-) diff -puN drivers/char/istallion.c~char-istallion-convert-to-pci-probing drivers/char/istallion.c --- a/drivers/char/istallion.c~char-istallion-convert-to-pci-probing +++ a/drivers/char/istallion.c @@ -402,7 +402,6 @@ static int stli_eisamempsize = ARRAY_SIZ /* * Define the Stallion PCI vendor and device IDs. */ -#ifdef CONFIG_PCI #ifndef PCI_VENDOR_ID_STALLION #define PCI_VENDOR_ID_STALLION 0x124d #endif @@ -416,7 +415,7 @@ static struct pci_device_id istallion_pc }; MODULE_DEVICE_TABLE(pci, istallion_pci_tbl); -#endif /* CONFIG_PCI */ +static struct pci_driver stli_pcidriver; /*****************************************************************************/ @@ -728,10 +727,6 @@ static int stli_initonb(stlibrd_t *brdp) static int stli_eisamemprobe(stlibrd_t *brdp); static int stli_initports(stlibrd_t *brdp); -#ifdef CONFIG_PCI -static int stli_initpcibrd(int brdtype, struct pci_dev *devp); -#endif - /*****************************************************************************/ /* @@ -768,6 +763,21 @@ static int stli_timeron; static struct class *istallion_class; +static void stli_cleanup_ports(stlibrd_t *brdp) +{ + stliport_t *portp; + unsigned int j; + + for (j = 0; j < STL_MAXPORTS; j++) { + portp = brdp->ports[j]; + if (portp != NULL) { + if (portp->tty != NULL) + tty_hangup(portp->tty); + kfree(portp); + } + } +} + /* * Loadable module initialization stuff. */ @@ -783,12 +793,12 @@ static int __init istallion_module_init( static void __exit istallion_module_exit(void) { stlibrd_t *brdp; - stliport_t *portp; - int i, j; + int i; printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle, stli_drvversion); + pci_unregister_driver(&stli_pcidriver); /* * Free up all allocated resources used by the ports. This includes * memory and interrupts. @@ -817,14 +827,8 @@ static void __exit istallion_module_exit for (i = 0; (i < stli_nrbrds); i++) { if ((brdp = stli_brds[i]) == NULL) continue; - for (j = 0; (j < STL_MAXPORTS); j++) { - portp = brdp->ports[j]; - if (portp != NULL) { - if (portp->tty != NULL) - tty_hangup(portp->tty); - kfree(portp); - } - } + + stli_cleanup_ports(brdp); iounmap(brdp->membase); if (brdp->iosize > 0) @@ -3777,7 +3781,7 @@ stli_donestartup: * Probe and initialize the specified board. */ -static int __init stli_brdinit(stlibrd_t *brdp) +static int __devinit stli_brdinit(stlibrd_t *brdp) { stli_brds[brdp->brdnr] = brdp; @@ -4019,58 +4023,72 @@ static int stli_findeisabrds(void) /*****************************************************************************/ -#ifdef CONFIG_PCI - /* * We have a Stallion board. Allocate a board structure and * initialize it. Read its IO and MEMORY resources from PCI * configuration space. */ -static int stli_initpcibrd(int brdtype, struct pci_dev *devp) +static int __devinit stli_pciprobe(struct pci_dev *pdev, + const struct pci_device_id *ent) { stlibrd_t *brdp; + int retval = -EIO; - if (pci_enable_device(devp)) - return -EIO; - if ((brdp = stli_allocbrd()) == NULL) - return -ENOMEM; - if ((brdp->brdnr = stli_getbrdnr()) < 0) { + retval = pci_enable_device(pdev); + if (retval) + goto err; + brdp = stli_allocbrd(); + if (brdp == NULL) { + retval = -ENOMEM; + goto err; + } + if ((brdp->brdnr = stli_getbrdnr()) < 0) { /* TODO: locking */ printk(KERN_INFO "STALLION: too many boards found, " "maximum supported %d\n", STL_MAXBRDS); - return 0; + retval = -EIO; + goto err_fr; } - brdp->brdtype = brdtype; + brdp->brdtype = BRD_ECPPCI; /* * We have all resources from the board, so lets setup the actual * board structure now. */ - brdp->iobase = pci_resource_start(devp, 3); - brdp->memaddr = pci_resource_start(devp, 2); - stli_brdinit(brdp); + brdp->iobase = pci_resource_start(pdev, 3); + brdp->memaddr = pci_resource_start(pdev, 2); + retval = stli_brdinit(brdp); + if (retval) + goto err_fr; + + pci_set_drvdata(pdev, brdp); return 0; +err_fr: + kfree(brdp); +err: + return retval; } -/*****************************************************************************/ +static void stli_pciremove(struct pci_dev *pdev) +{ + stlibrd_t *brdp = pci_get_drvdata(pdev); -/* - * Find all Stallion PCI boards that might be installed. Initialize each - * one as it is found. - */ + stli_cleanup_ports(brdp); -static int stli_findpcibrds(void) -{ - struct pci_dev *dev = NULL; + iounmap(brdp->membase); + if (brdp->iosize > 0) + release_region(brdp->iobase, brdp->iosize); - while ((dev = pci_get_device(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, dev))) { - stli_initpcibrd(BRD_ECPPCI, dev); - } - return 0; + stli_brds[brdp->brdnr] = NULL; + kfree(brdp); } -#endif - +static struct pci_driver stli_pcidriver = { + .name = "istallion", + .id_table = istallion_pci_tbl, + .probe = stli_pciprobe, + .remove = __devexit_p(stli_pciremove) +}; /*****************************************************************************/ /* @@ -4102,7 +4120,7 @@ static int stli_initbrds(void) { stlibrd_t *brdp, *nxtbrdp; stlconf_t *confp; - int i, j; + int i, j, retval; if (stli_nrbrds > STL_MAXBRDS) { printk(KERN_INFO "STALLION: too many boards in configuration " @@ -4134,9 +4152,9 @@ static int stli_initbrds(void) stli_argbrds(); if (STLI_EISAPROBE) stli_findeisabrds(); -#ifdef CONFIG_PCI - stli_findpcibrds(); -#endif + + retval = pci_register_driver(&stli_pcidriver); + /* TODO: check retval and do something */ /* * All found boards are initialized. Now for a little optimization, if _ Patches currently in -mm which might be from jirislaby@xxxxxxxxx are mxser-correct-tty-driver-name.patch pci-mxser-pci-refcounts.patch mxser-make-an-experimental-clone.patch char-mxser_new-correct-include-file.patch char-mxser_new-upgrade-to-191.patch char-mxser_new-rework-to-allow-dynamic-structs.patch char-mxser_new-use-__devinit-macros.patch char-mxser_new-pci_request_region-for-pci-regions.patch char-mxser_new-check-request_region-retvals.patch char-mxser_new-kill-unneeded-memsets.patch char-mxser_new-revert-spin_lock-changes.patch char-mxser_new-remove-request-for-testers-line.patch char-mxser_new-debug-printk-dependent-on-debug.patch char-mxser_new-alter-license-terms.patch char-mxser_new-code-upside-down.patch char-mxser_new-cmspar-is-defined.patch char-remove-unneded-termbits-redefinitions-mxser_new.patch char-mxser_new-eliminate-tty-ldisc-deref.patch char-mxser_new-testbit-for-bit-testing.patch char-mxser_new-correct-fail-paths.patch char-mxser_new-dont-check-tty_unregister-retval.patch char-mxser_new-compress-isa-finding.patch char-mxser_new-register-tty-devices-on-the-fly.patch char-mxser_new-compact-structures-round2.patch char-mxser_new-reverse-if-else-paths-patch.patch char-mxser_new-comments-cleanup.patch char-mxser_new-correct-intr-handler-proto.patch char-mxser_new-delete-ttys-and-termios.patch char-mxser_new-pci-probing.patch char-mxser_new-clean-macros.patch maintainers-add-me-to-isicom-mxser.patch mxser_new-correct-tty-driver-name.patch char-stallion-use-pr_debug-macro.patch char-stallion-remove-unneeded-casts.patch char-stallion-kill-typedefs.patch char-stallion-move-init-deinit.patch char-stallion-uninline-functions.patch char-stallion-mark-functions-as-init.patch char-stallion-remove-many-prototypes.patch char-isicom-expand-function.patch char-isicom-rename-init-function.patch char-isicom-remove-isa-code.patch char-isicom-remove-unneeded-memset.patch char-isicom-move-to-tty_register_device.patch char-isicom-use-pci_request_region.patch char-isicom-check-kmalloc-retval.patch char-isicom-use-completion.patch char-isicom-simplify-timer.patch char-isicom-remove-cvs-stuff.patch char-isicom-fix-tty-index-check.patch char-sx-convert-to-pci-probing.patch char-sx-use-kcalloc.patch char-sx-mark-functions-as-devinit.patch char-sx-use-eisa-probing.patch char-sx-ifdef-isa-code.patch char-sx-lock-boards-struct.patch char-sx-remove-duplicite-code.patch char-sx-whitespace-cleanup.patch char-sx-simplify-timer-logic.patch char-sx-fix-return-in-module-init.patch char-sx-use-pci_iomap.patch char-sx-request-regions.patch char-stallion-convert-to-pci-probing.patch char-stallion-prints-cleanup.patch char-stallion-implement-fail-paths.patch char-stallion-correct-__init-macros.patch char-stallion-functions-cleanup.patch char-stallion-fix-fail-paths.patch char-stallion-brd-struct-locking.patch char-stallion-remove-syntactic-sugar.patch char-stallion-variables-cleanup.patch char-stallion-use-dynamic-dev.patch char-istallion-convert-to-pci-probing.patch char-istallion-remove-the-mess.patch char-istallion-eliminate-typedefs.patch char-istallion-variables-cleanup.patch char-istallion-ifdef-eisa-code.patch char-istallion-brdnr-locking.patch char-istallion-free-only-isa.patch char-istallion-correct-fail-paths.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html