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>
This commit is contained in:
parent
ee4cd1b225
commit
718c4ca1f7
|
@ -3289,6 +3289,7 @@ static unsigned short __devinit cyy_init_card(void __iomem *true_base_addr,
|
||||||
static int __init cy_detect_isa(void)
|
static int __init cy_detect_isa(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_ISA
|
#ifdef CONFIG_ISA
|
||||||
|
struct cyclades_card *card;
|
||||||
unsigned short cy_isa_irq, nboard;
|
unsigned short cy_isa_irq, nboard;
|
||||||
void __iomem *cy_isa_address;
|
void __iomem *cy_isa_address;
|
||||||
unsigned short i, j, cy_isa_nchan;
|
unsigned short i, j, cy_isa_nchan;
|
||||||
|
@ -3349,7 +3350,8 @@ static int __init cy_detect_isa(void)
|
||||||
}
|
}
|
||||||
/* fill the next cy_card structure available */
|
/* fill the next cy_card structure available */
|
||||||
for (j = 0; j < NR_CARDS; j++) {
|
for (j = 0; j < NR_CARDS; j++) {
|
||||||
if (cy_card[j].base_addr == NULL)
|
card = &cy_card[j];
|
||||||
|
if (card->base_addr == NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (j == NR_CARDS) { /* no more cy_cards available */
|
if (j == NR_CARDS) { /* no more cy_cards available */
|
||||||
|
@ -3363,7 +3365,7 @@ static int __init cy_detect_isa(void)
|
||||||
|
|
||||||
/* allocate IRQ */
|
/* allocate IRQ */
|
||||||
if (request_irq(cy_isa_irq, cyy_interrupt,
|
if (request_irq(cy_isa_irq, cyy_interrupt,
|
||||||
0, "Cyclom-Y", &cy_card[j])) {
|
0, "Cyclom-Y", card)) {
|
||||||
printk(KERN_ERR "Cyclom-Y/ISA found at 0x%lx, but "
|
printk(KERN_ERR "Cyclom-Y/ISA found at 0x%lx, but "
|
||||||
"could not allocate IRQ#%d.\n",
|
"could not allocate IRQ#%d.\n",
|
||||||
(unsigned long)cy_isa_address, cy_isa_irq);
|
(unsigned long)cy_isa_address, cy_isa_irq);
|
||||||
|
@ -3372,16 +3374,16 @@ static int __init cy_detect_isa(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set cy_card */
|
/* set cy_card */
|
||||||
cy_card[j].base_addr = cy_isa_address;
|
card->base_addr = cy_isa_address;
|
||||||
cy_card[j].ctl_addr.p9050 = NULL;
|
card->ctl_addr.p9050 = NULL;
|
||||||
cy_card[j].irq = (int)cy_isa_irq;
|
card->irq = (int)cy_isa_irq;
|
||||||
cy_card[j].bus_index = 0;
|
card->bus_index = 0;
|
||||||
cy_card[j].first_line = cy_next_channel;
|
card->first_line = cy_next_channel;
|
||||||
cy_card[j].num_chips = cy_isa_nchan / CyPORTS_PER_CHIP;
|
card->num_chips = cy_isa_nchan / CyPORTS_PER_CHIP;
|
||||||
cy_card[j].nports = cy_isa_nchan;
|
card->nports = cy_isa_nchan;
|
||||||
if (cy_init_card(&cy_card[j])) {
|
if (cy_init_card(card)) {
|
||||||
cy_card[j].base_addr = NULL;
|
card->base_addr = NULL;
|
||||||
free_irq(cy_isa_irq, &cy_card[j]);
|
free_irq(cy_isa_irq, card);
|
||||||
iounmap(cy_isa_address);
|
iounmap(cy_isa_address);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -3695,6 +3697,7 @@ err:
|
||||||
static int __devinit cy_pci_probe(struct pci_dev *pdev,
|
static int __devinit cy_pci_probe(struct pci_dev *pdev,
|
||||||
const struct pci_device_id *ent)
|
const struct pci_device_id *ent)
|
||||||
{
|
{
|
||||||
|
struct cyclades_card *card;
|
||||||
void __iomem *addr0 = NULL, *addr2 = NULL;
|
void __iomem *addr0 = NULL, *addr2 = NULL;
|
||||||
char *card_name = NULL;
|
char *card_name = NULL;
|
||||||
u32 uninitialized_var(mailbox);
|
u32 uninitialized_var(mailbox);
|
||||||
|
@ -3829,7 +3832,8 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
|
||||||
}
|
}
|
||||||
/* fill the next cy_card structure available */
|
/* fill the next cy_card structure available */
|
||||||
for (card_no = 0; card_no < NR_CARDS; card_no++) {
|
for (card_no = 0; card_no < NR_CARDS; card_no++) {
|
||||||
if (cy_card[card_no].base_addr == NULL)
|
card = &cy_card[card_no];
|
||||||
|
if (card->base_addr == NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (card_no == NR_CARDS) { /* no more cy_cards available */
|
if (card_no == NR_CARDS) { /* no more cy_cards available */
|
||||||
|
@ -3843,27 +3847,26 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
|
||||||
device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) {
|
device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) {
|
||||||
/* allocate IRQ */
|
/* allocate IRQ */
|
||||||
retval = request_irq(irq, cyy_interrupt,
|
retval = request_irq(irq, cyy_interrupt,
|
||||||
IRQF_SHARED, "Cyclom-Y", &cy_card[card_no]);
|
IRQF_SHARED, "Cyclom-Y", card);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
dev_err(&pdev->dev, "could not allocate IRQ\n");
|
dev_err(&pdev->dev, "could not allocate IRQ\n");
|
||||||
goto err_unmap;
|
goto err_unmap;
|
||||||
}
|
}
|
||||||
cy_card[card_no].num_chips = nchan / CyPORTS_PER_CHIP;
|
card->num_chips = nchan / CyPORTS_PER_CHIP;
|
||||||
} else {
|
} else {
|
||||||
struct FIRM_ID __iomem *firm_id = addr2 + ID_ADDRESS;
|
struct FIRM_ID __iomem *firm_id = addr2 + ID_ADDRESS;
|
||||||
struct ZFW_CTRL __iomem *zfw_ctrl;
|
struct ZFW_CTRL __iomem *zfw_ctrl;
|
||||||
|
|
||||||
zfw_ctrl = addr2 + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
|
zfw_ctrl = addr2 + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
|
||||||
|
|
||||||
cy_card[card_no].hw_ver = mailbox;
|
card->hw_ver = mailbox;
|
||||||
cy_card[card_no].num_chips = (unsigned int)-1;
|
card->num_chips = (unsigned int)-1;
|
||||||
cy_card[card_no].board_ctrl = &zfw_ctrl->board_ctrl;
|
card->board_ctrl = &zfw_ctrl->board_ctrl;
|
||||||
#ifdef CONFIG_CYZ_INTR
|
#ifdef CONFIG_CYZ_INTR
|
||||||
/* allocate IRQ only if board has an IRQ */
|
/* allocate IRQ only if board has an IRQ */
|
||||||
if (irq != 0 && irq != 255) {
|
if (irq != 0 && irq != 255) {
|
||||||
retval = request_irq(irq, cyz_interrupt,
|
retval = request_irq(irq, cyz_interrupt,
|
||||||
IRQF_SHARED, "Cyclades-Z",
|
IRQF_SHARED, "Cyclades-Z", card);
|
||||||
&cy_card[card_no]);
|
|
||||||
if (retval) {
|
if (retval) {
|
||||||
dev_err(&pdev->dev, "could not allocate IRQ\n");
|
dev_err(&pdev->dev, "could not allocate IRQ\n");
|
||||||
goto err_unmap;
|
goto err_unmap;
|
||||||
|
@ -3873,17 +3876,17 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set cy_card */
|
/* set cy_card */
|
||||||
cy_card[card_no].base_addr = addr2;
|
card->base_addr = addr2;
|
||||||
cy_card[card_no].ctl_addr.p9050 = addr0;
|
card->ctl_addr.p9050 = addr0;
|
||||||
cy_card[card_no].irq = irq;
|
card->irq = irq;
|
||||||
cy_card[card_no].bus_index = 1;
|
card->bus_index = 1;
|
||||||
cy_card[card_no].first_line = cy_next_channel;
|
card->first_line = cy_next_channel;
|
||||||
cy_card[card_no].nports = nchan;
|
card->nports = nchan;
|
||||||
retval = cy_init_card(&cy_card[card_no]);
|
retval = cy_init_card(card);
|
||||||
if (retval)
|
if (retval)
|
||||||
goto err_null;
|
goto err_null;
|
||||||
|
|
||||||
pci_set_drvdata(pdev, &cy_card[card_no]);
|
pci_set_drvdata(pdev, card);
|
||||||
|
|
||||||
if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo ||
|
if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo ||
|
||||||
device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) {
|
device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) {
|
||||||
|
@ -3915,8 +3918,8 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
err_null:
|
err_null:
|
||||||
cy_card[card_no].base_addr = NULL;
|
card->base_addr = NULL;
|
||||||
free_irq(irq, &cy_card[card_no]);
|
free_irq(irq, card);
|
||||||
err_unmap:
|
err_unmap:
|
||||||
iounmap(addr0);
|
iounmap(addr0);
|
||||||
if (addr2)
|
if (addr2)
|
||||||
|
|
Loading…
Reference in New Issue