Commit aeaccfe42510d2c009a2c36452d220a5f4a0363e
Committed by
Linus Torvalds
1 parent
6b2c9457bb
Exists in
master
and in
39 other branches
[PATCH] Char: stallion, use dynamic dev
Use dynamic tty device registering depending on board's port count. (i -> retval change is relevant, since gcc complains about signedness of i) Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 27 additions and 6 deletions Side-by-side Diff
drivers/char/stallion.c
... | ... | @@ -2348,7 +2348,7 @@ |
2348 | 2348 | const struct pci_device_id *ent) |
2349 | 2349 | { |
2350 | 2350 | struct stlbrd *brdp; |
2351 | - unsigned int brdtype = ent->driver_data; | |
2351 | + unsigned int i, brdtype = ent->driver_data; | |
2352 | 2352 | int brdnr, retval = -ENODEV; |
2353 | 2353 | |
2354 | 2354 | if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) |
... | ... | @@ -2409,6 +2409,10 @@ |
2409 | 2409 | |
2410 | 2410 | pci_set_drvdata(pdev, brdp); |
2411 | 2411 | |
2412 | + for (i = 0; i < brdp->nrports; i++) | |
2413 | + tty_register_device(stl_serial, | |
2414 | + brdp->brdnr * STL_MAXPORTS + i, &pdev->dev); | |
2415 | + | |
2412 | 2416 | return 0; |
2413 | 2417 | err_null: |
2414 | 2418 | stl_brds[brdp->brdnr] = NULL; |
... | ... | @@ -2421,6 +2425,7 @@ |
2421 | 2425 | static void __devexit stl_pciremove(struct pci_dev *pdev) |
2422 | 2426 | { |
2423 | 2427 | struct stlbrd *brdp = pci_get_drvdata(pdev); |
2428 | + unsigned int i; | |
2424 | 2429 | |
2425 | 2430 | free_irq(brdp->irq, brdp); |
2426 | 2431 | |
... | ... | @@ -2430,6 +2435,10 @@ |
2430 | 2435 | if (brdp->iosize2 > 0) |
2431 | 2436 | release_region(brdp->ioaddr2, brdp->iosize2); |
2432 | 2437 | |
2438 | + for (i = 0; i < brdp->nrports; i++) | |
2439 | + tty_unregister_device(stl_serial, | |
2440 | + brdp->brdnr * STL_MAXPORTS + i); | |
2441 | + | |
2433 | 2442 | stl_brds[brdp->brdnr] = NULL; |
2434 | 2443 | kfree(brdp); |
2435 | 2444 | } |
... | ... | @@ -4693,7 +4702,7 @@ |
4693 | 4702 | { |
4694 | 4703 | struct stlbrd *brdp; |
4695 | 4704 | struct stlconf conf; |
4696 | - unsigned int i; | |
4705 | + unsigned int i, j; | |
4697 | 4706 | int retval; |
4698 | 4707 | |
4699 | 4708 | printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion); |
... | ... | @@ -4720,6 +4729,9 @@ |
4720 | 4729 | if (stl_brdinit(brdp)) |
4721 | 4730 | kfree(brdp); |
4722 | 4731 | else { |
4732 | + for (j = 0; j < brdp->nrports; j++) | |
4733 | + tty_register_device(stl_serial, | |
4734 | + brdp->brdnr * STL_MAXPORTS + j, NULL); | |
4723 | 4735 | stl_brds[brdp->brdnr] = brdp; |
4724 | 4736 | stl_nrbrds = i + 1; |
4725 | 4737 | } |
... | ... | @@ -4761,7 +4773,7 @@ |
4761 | 4773 | stl_serial->type = TTY_DRIVER_TYPE_SERIAL; |
4762 | 4774 | stl_serial->subtype = SERIAL_TYPE_NORMAL; |
4763 | 4775 | stl_serial->init_termios = stl_deftermios; |
4764 | - stl_serial->flags = TTY_DRIVER_REAL_RAW; | |
4776 | + stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; | |
4765 | 4777 | tty_set_operations(stl_serial, &stl_ops); |
4766 | 4778 | |
4767 | 4779 | retval = tty_register_driver(stl_serial); |
... | ... | @@ -4787,7 +4799,9 @@ |
4787 | 4799 | |
4788 | 4800 | static void __exit stallion_module_exit(void) |
4789 | 4801 | { |
4790 | - int i; | |
4802 | + struct stlbrd *brdp; | |
4803 | + unsigned int i, j; | |
4804 | + int retval; | |
4791 | 4805 | |
4792 | 4806 | pr_debug("cleanup_module()\n"); |
4793 | 4807 | |
4794 | 4808 | |
4795 | 4809 | |
... | ... | @@ -4800,14 +4814,21 @@ |
4800 | 4814 | * a hangup on every open port - to try to flush out any processes |
4801 | 4815 | * hanging onto ports. |
4802 | 4816 | */ |
4817 | + for (i = 0; i < stl_nrbrds; i++) { | |
4818 | + if ((brdp = stl_brds[i]) == NULL || (brdp->state & STL_PROBED)) | |
4819 | + continue; | |
4820 | + for (j = 0; j < brdp->nrports; j++) | |
4821 | + tty_unregister_device(stl_serial, | |
4822 | + brdp->brdnr * STL_MAXPORTS + j); | |
4823 | + } | |
4803 | 4824 | tty_unregister_driver(stl_serial); |
4804 | 4825 | put_tty_driver(stl_serial); |
4805 | 4826 | |
4806 | 4827 | for (i = 0; i < 4; i++) |
4807 | 4828 | class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i)); |
4808 | - if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"))) | |
4829 | + if ((retval = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"))) | |
4809 | 4830 | printk("STALLION: failed to un-register serial memory device, " |
4810 | - "errno=%d\n", -i); | |
4831 | + "errno=%d\n", -retval); | |
4811 | 4832 | class_destroy(stallion_class); |
4812 | 4833 | |
4813 | 4834 | pci_unregister_driver(&stl_pcidriver); |