diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-06-04 07:35:15 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-06-12 18:50:23 -0400 |
commit | 718c4ca1f721be3ae67f9ff7d43b9a910e4a1ec3 (patch) | |
tree | 72e4e17b5b3ef534c823c21efdb2ab2d743fca80 /drivers/tty | |
parent | ee4cd1b225368abed7e0f4d344f1e9a93e87b98e (diff) |
TTY: cyclades, add local pointer for card
cy_pci_probe and cy_detect_isa reference cy_card[card_no] many times.
It makes the code hard to read. Let us add a local variable holding a
pointer to the card indexed by card_no and use that.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/cyclades.c | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c index e61cabdd69df..cff546839db9 100644 --- a/drivers/tty/cyclades.c +++ b/drivers/tty/cyclades.c | |||
@@ -3289,6 +3289,7 @@ static unsigned short __devinit cyy_init_card(void __iomem *true_base_addr, | |||
3289 | static int __init cy_detect_isa(void) | 3289 | static int __init cy_detect_isa(void) |
3290 | { | 3290 | { |
3291 | #ifdef CONFIG_ISA | 3291 | #ifdef CONFIG_ISA |
3292 | struct cyclades_card *card; | ||
3292 | unsigned short cy_isa_irq, nboard; | 3293 | unsigned short cy_isa_irq, nboard; |
3293 | void __iomem *cy_isa_address; | 3294 | void __iomem *cy_isa_address; |
3294 | unsigned short i, j, cy_isa_nchan; | 3295 | unsigned short i, j, cy_isa_nchan; |
@@ -3349,7 +3350,8 @@ static int __init cy_detect_isa(void) | |||
3349 | } | 3350 | } |
3350 | /* fill the next cy_card structure available */ | 3351 | /* fill the next cy_card structure available */ |
3351 | for (j = 0; j < NR_CARDS; j++) { | 3352 | for (j = 0; j < NR_CARDS; j++) { |
3352 | if (cy_card[j].base_addr == NULL) | 3353 | card = &cy_card[j]; |
3354 | if (card->base_addr == NULL) | ||
3353 | break; | 3355 | break; |
3354 | } | 3356 | } |
3355 | if (j == NR_CARDS) { /* no more cy_cards available */ | 3357 | if (j == NR_CARDS) { /* no more cy_cards available */ |
@@ -3363,7 +3365,7 @@ static int __init cy_detect_isa(void) | |||
3363 | 3365 | ||
3364 | /* allocate IRQ */ | 3366 | /* allocate IRQ */ |
3365 | if (request_irq(cy_isa_irq, cyy_interrupt, | 3367 | if (request_irq(cy_isa_irq, cyy_interrupt, |
3366 | 0, "Cyclom-Y", &cy_card[j])) { | 3368 | 0, "Cyclom-Y", card)) { |
3367 | printk(KERN_ERR "Cyclom-Y/ISA found at 0x%lx, but " | 3369 | printk(KERN_ERR "Cyclom-Y/ISA found at 0x%lx, but " |
3368 | "could not allocate IRQ#%d.\n", | 3370 | "could not allocate IRQ#%d.\n", |
3369 | (unsigned long)cy_isa_address, cy_isa_irq); | 3371 | (unsigned long)cy_isa_address, cy_isa_irq); |
@@ -3372,16 +3374,16 @@ static int __init cy_detect_isa(void) | |||
3372 | } | 3374 | } |
3373 | 3375 | ||
3374 | /* set cy_card */ | 3376 | /* set cy_card */ |
3375 | cy_card[j].base_addr = cy_isa_address; | 3377 | card->base_addr = cy_isa_address; |
3376 | cy_card[j].ctl_addr.p9050 = NULL; | 3378 | card->ctl_addr.p9050 = NULL; |
3377 | cy_card[j].irq = (int)cy_isa_irq; | 3379 | card->irq = (int)cy_isa_irq; |
3378 | cy_card[j].bus_index = 0; | 3380 | card->bus_index = 0; |
3379 | cy_card[j].first_line = cy_next_channel; | 3381 | card->first_line = cy_next_channel; |
3380 | cy_card[j].num_chips = cy_isa_nchan / CyPORTS_PER_CHIP; | 3382 | card->num_chips = cy_isa_nchan / CyPORTS_PER_CHIP; |
3381 | cy_card[j].nports = cy_isa_nchan; | 3383 | card->nports = cy_isa_nchan; |
3382 | if (cy_init_card(&cy_card[j])) { | 3384 | if (cy_init_card(card)) { |
3383 | cy_card[j].base_addr = NULL; | 3385 | card->base_addr = NULL; |
3384 | free_irq(cy_isa_irq, &cy_card[j]); | 3386 | free_irq(cy_isa_irq, card); |
3385 | iounmap(cy_isa_address); | 3387 | iounmap(cy_isa_address); |
3386 | continue; | 3388 | continue; |
3387 | } | 3389 | } |
@@ -3695,6 +3697,7 @@ err: | |||
3695 | static int __devinit cy_pci_probe(struct pci_dev *pdev, | 3697 | static int __devinit cy_pci_probe(struct pci_dev *pdev, |
3696 | const struct pci_device_id *ent) | 3698 | const struct pci_device_id *ent) |
3697 | { | 3699 | { |
3700 | struct cyclades_card *card; | ||
3698 | void __iomem *addr0 = NULL, *addr2 = NULL; | 3701 | void __iomem *addr0 = NULL, *addr2 = NULL; |
3699 | char *card_name = NULL; | 3702 | char *card_name = NULL; |
3700 | u32 uninitialized_var(mailbox); | 3703 | u32 uninitialized_var(mailbox); |
@@ -3829,7 +3832,8 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, | |||
3829 | } | 3832 | } |
3830 | /* fill the next cy_card structure available */ | 3833 | /* fill the next cy_card structure available */ |
3831 | for (card_no = 0; card_no < NR_CARDS; card_no++) { | 3834 | for (card_no = 0; card_no < NR_CARDS; card_no++) { |
3832 | if (cy_card[card_no].base_addr == NULL) | 3835 | card = &cy_card[card_no]; |
3836 | if (card->base_addr == NULL) | ||
3833 | break; | 3837 | break; |
3834 | } | 3838 | } |
3835 | if (card_no == NR_CARDS) { /* no more cy_cards available */ | 3839 | if (card_no == NR_CARDS) { /* no more cy_cards available */ |
@@ -3843,27 +3847,26 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, | |||
3843 | device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) { | 3847 | device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) { |
3844 | /* allocate IRQ */ | 3848 | /* allocate IRQ */ |
3845 | retval = request_irq(irq, cyy_interrupt, | 3849 | retval = request_irq(irq, cyy_interrupt, |
3846 | IRQF_SHARED, "Cyclom-Y", &cy_card[card_no]); | 3850 | IRQF_SHARED, "Cyclom-Y", card); |
3847 | if (retval) { | 3851 | if (retval) { |
3848 | dev_err(&pdev->dev, "could not allocate IRQ\n"); | 3852 | dev_err(&pdev->dev, "could not allocate IRQ\n"); |
3849 | goto err_unmap; | 3853 | goto err_unmap; |
3850 | } | 3854 | } |
3851 | cy_card[card_no].num_chips = nchan / CyPORTS_PER_CHIP; | 3855 | card->num_chips = nchan / CyPORTS_PER_CHIP; |
3852 | } else { | 3856 | } else { |
3853 | struct FIRM_ID __iomem *firm_id = addr2 + ID_ADDRESS; | 3857 | struct FIRM_ID __iomem *firm_id = addr2 + ID_ADDRESS; |
3854 | struct ZFW_CTRL __iomem *zfw_ctrl; | 3858 | struct ZFW_CTRL __iomem *zfw_ctrl; |
3855 | 3859 | ||
3856 | zfw_ctrl = addr2 + (readl(&firm_id->zfwctrl_addr) & 0xfffff); | 3860 | zfw_ctrl = addr2 + (readl(&firm_id->zfwctrl_addr) & 0xfffff); |
3857 | 3861 | ||
3858 | cy_card[card_no].hw_ver = mailbox; | 3862 | card->hw_ver = mailbox; |
3859 | cy_card[card_no].num_chips = (unsigned int)-1; | 3863 | card->num_chips = (unsigned int)-1; |
3860 | cy_card[card_no].board_ctrl = &zfw_ctrl->board_ctrl; | 3864 | card->board_ctrl = &zfw_ctrl->board_ctrl; |
3861 | #ifdef CONFIG_CYZ_INTR | 3865 | #ifdef CONFIG_CYZ_INTR |
3862 | /* allocate IRQ only if board has an IRQ */ | 3866 | /* allocate IRQ only if board has an IRQ */ |
3863 | if (irq != 0 && irq != 255) { | 3867 | if (irq != 0 && irq != 255) { |
3864 | retval = request_irq(irq, cyz_interrupt, | 3868 | retval = request_irq(irq, cyz_interrupt, |
3865 | IRQF_SHARED, "Cyclades-Z", | 3869 | IRQF_SHARED, "Cyclades-Z", card); |
3866 | &cy_card[card_no]); | ||
3867 | if (retval) { | 3870 | if (retval) { |
3868 | dev_err(&pdev->dev, "could not allocate IRQ\n"); | 3871 | dev_err(&pdev->dev, "could not allocate IRQ\n"); |
3869 | goto err_unmap; | 3872 | goto err_unmap; |
@@ -3873,17 +3876,17 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, | |||
3873 | } | 3876 | } |
3874 | 3877 | ||
3875 | /* set cy_card */ | 3878 | /* set cy_card */ |
3876 | cy_card[card_no].base_addr = addr2; | 3879 | card->base_addr = addr2; |
3877 | cy_card[card_no].ctl_addr.p9050 = addr0; | 3880 | card->ctl_addr.p9050 = addr0; |
3878 | cy_card[card_no].irq = irq; | 3881 | card->irq = irq; |
3879 | cy_card[card_no].bus_index = 1; | 3882 | card->bus_index = 1; |
3880 | cy_card[card_no].first_line = cy_next_channel; | 3883 | card->first_line = cy_next_channel; |
3881 | cy_card[card_no].nports = nchan; | 3884 | card->nports = nchan; |
3882 | retval = cy_init_card(&cy_card[card_no]); | 3885 | retval = cy_init_card(card); |
3883 | if (retval) | 3886 | if (retval) |
3884 | goto err_null; | 3887 | goto err_null; |
3885 | 3888 | ||
3886 | pci_set_drvdata(pdev, &cy_card[card_no]); | 3889 | pci_set_drvdata(pdev, card); |
3887 | 3890 | ||
3888 | if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo || | 3891 | if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo || |
3889 | device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) { | 3892 | device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) { |
@@ -3915,8 +3918,8 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, | |||
3915 | 3918 | ||
3916 | return 0; | 3919 | return 0; |
3917 | err_null: | 3920 | err_null: |
3918 | cy_card[card_no].base_addr = NULL; | 3921 | card->base_addr = NULL; |
3919 | free_irq(irq, &cy_card[card_no]); | 3922 | free_irq(irq, card); |
3920 | err_unmap: | 3923 | err_unmap: |
3921 | iounmap(addr0); | 3924 | iounmap(addr0); |
3922 | if (addr2) | 3925 | if (addr2) |