diff options
Diffstat (limited to 'drivers/char/rio/riotable.c')
-rw-r--r-- | drivers/char/rio/riotable.c | 76 |
1 files changed, 33 insertions, 43 deletions
diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c index a86b216ab653..f1d50142b91d 100644 --- a/drivers/char/rio/riotable.c +++ b/drivers/char/rio/riotable.c | |||
@@ -91,8 +91,7 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2"; | |||
91 | ** A configuration table has been loaded. It is now up to us | 91 | ** A configuration table has been loaded. It is now up to us |
92 | ** to sort it out and use the information contained therein. | 92 | ** to sort it out and use the information contained therein. |
93 | */ | 93 | */ |
94 | int RIONewTable(p) | 94 | int RIONewTable(struct rio_info *p) |
95 | struct rio_info *p; | ||
96 | { | 95 | { |
97 | int Host, Host1, Host2, NameIsUnique, Entry, SubEnt; | 96 | int Host, Host1, Host2, NameIsUnique, Entry, SubEnt; |
98 | struct Map *MapP; | 97 | struct Map *MapP; |
@@ -298,9 +297,9 @@ struct rio_info *p; | |||
298 | */ | 297 | */ |
299 | for (Host = 0; Host < RIO_HOSTS; Host++) { | 298 | for (Host = 0; Host < RIO_HOSTS; Host++) { |
300 | for (Entry = 0; Entry < MAX_RUP; Entry++) { | 299 | for (Entry = 0; Entry < MAX_RUP; Entry++) { |
301 | bzero((caddr_t) & p->RIOHosts[Host].Mapping[Entry], sizeof(struct Map)); | 300 | memset(&p->RIOHosts[Host].Mapping[Entry], 0, sizeof(struct Map)); |
302 | } | 301 | } |
303 | bzero((caddr_t) & p->RIOHosts[Host].Name[0], sizeof(p->RIOHosts[Host].Name)); | 302 | memset(&p->RIOHosts[Host].Name[0], 0, sizeof(p->RIOHosts[Host].Name)); |
304 | } | 303 | } |
305 | 304 | ||
306 | /* | 305 | /* |
@@ -409,9 +408,10 @@ struct rio_info *p; | |||
409 | /* | 408 | /* |
410 | ** User process needs the config table - build it from first | 409 | ** User process needs the config table - build it from first |
411 | ** principles. | 410 | ** principles. |
411 | ** | ||
412 | * FIXME: SMP locking | ||
412 | */ | 413 | */ |
413 | int RIOApel(p) | 414 | int RIOApel(struct rio_info *p) |
414 | struct rio_info *p; | ||
415 | { | 415 | { |
416 | int Host; | 416 | int Host; |
417 | int link; | 417 | int link; |
@@ -419,17 +419,17 @@ struct rio_info *p; | |||
419 | int Next = 0; | 419 | int Next = 0; |
420 | struct Map *MapP; | 420 | struct Map *MapP; |
421 | struct Host *HostP; | 421 | struct Host *HostP; |
422 | long oldspl; | 422 | unsigned long flags; |
423 | |||
424 | disable(oldspl); /* strange but true! */ | ||
425 | 423 | ||
426 | rio_dprintk(RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n"); | 424 | rio_dprintk(RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n"); |
427 | 425 | ||
428 | bzero((caddr_t) & p->RIOConnectTable[0], sizeof(struct Map) * TOTAL_MAP_ENTRIES); | 426 | memset(&p->RIOConnectTable[0], 0, sizeof(struct Map) * TOTAL_MAP_ENTRIES); |
429 | 427 | ||
430 | for (Host = 0; Host < RIO_HOSTS; Host++) { | 428 | for (Host = 0; Host < RIO_HOSTS; Host++) { |
431 | rio_dprintk(RIO_DEBUG_TABLE, "Processing host %d\n", Host); | 429 | rio_dprintk(RIO_DEBUG_TABLE, "Processing host %d\n", Host); |
432 | HostP = &p->RIOHosts[Host]; | 430 | HostP = &p->RIOHosts[Host]; |
431 | rio_spin_lock_irqsave(&HostP->HostLock, flags); | ||
432 | |||
433 | MapP = &p->RIOConnectTable[Next++]; | 433 | MapP = &p->RIOConnectTable[Next++]; |
434 | MapP->HostUniqueNum = HostP->UniqueNum; | 434 | MapP->HostUniqueNum = HostP->UniqueNum; |
435 | if ((HostP->Flags & RUN_STATE) != RC_RUNNING) | 435 | if ((HostP->Flags & RUN_STATE) != RC_RUNNING) |
@@ -453,8 +453,8 @@ struct rio_info *p; | |||
453 | Next++; | 453 | Next++; |
454 | } | 454 | } |
455 | } | 455 | } |
456 | rio_spin_unlock_irqrestore(&HostP->HostLock, flags); | ||
456 | } | 457 | } |
457 | restore(oldspl); | ||
458 | return 0; | 458 | return 0; |
459 | } | 459 | } |
460 | 460 | ||
@@ -463,9 +463,7 @@ struct rio_info *p; | |||
463 | ** if the entry is suitably inactive, then we can gob on it and remove | 463 | ** if the entry is suitably inactive, then we can gob on it and remove |
464 | ** it from the table. | 464 | ** it from the table. |
465 | */ | 465 | */ |
466 | int RIODeleteRta(p, MapP) | 466 | int RIODeleteRta(struct rio_info *p, struct Map *MapP) |
467 | struct rio_info *p; | ||
468 | struct Map *MapP; | ||
469 | { | 467 | { |
470 | int host, entry, port, link; | 468 | int host, entry, port, link; |
471 | int SysPort; | 469 | int SysPort; |
@@ -543,7 +541,7 @@ struct Map *MapP; | |||
543 | if (PortP->SecondBlock) { | 541 | if (PortP->SecondBlock) { |
544 | ushort dest_unit = HostMapP->ID; | 542 | ushort dest_unit = HostMapP->ID; |
545 | ushort dest_port = port - SysPort; | 543 | ushort dest_port = port - SysPort; |
546 | WORD *TxPktP; | 544 | u16 *TxPktP; |
547 | PKT *Pkt; | 545 | PKT *Pkt; |
548 | 546 | ||
549 | for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) { | 547 | for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) { |
@@ -554,19 +552,19 @@ struct Map *MapP; | |||
554 | ** a 32 bit pointer so it can be | 552 | ** a 32 bit pointer so it can be |
555 | ** accessed from the driver. | 553 | ** accessed from the driver. |
556 | */ | 554 | */ |
557 | Pkt = (PKT *) RIO_PTR(HostP->Caddr, RWORD(*TxPktP)); | 555 | Pkt = (PKT *) RIO_PTR(HostP->Caddr, readw(&*TxPktP)); |
558 | rio_dprintk(RIO_DEBUG_TABLE, "Tx packet (%x) destination: Old %x:%x New %x:%x\n", *TxPktP, Pkt->dest_unit, Pkt->dest_port, dest_unit, dest_port); | 556 | rio_dprintk(RIO_DEBUG_TABLE, "Tx packet (%x) destination: Old %x:%x New %x:%x\n", *TxPktP, Pkt->dest_unit, Pkt->dest_port, dest_unit, dest_port); |
559 | WWORD(Pkt->dest_unit, dest_unit); | 557 | writew(dest_unit, &Pkt->dest_unit); |
560 | WWORD(Pkt->dest_port, dest_port); | 558 | writew(dest_port, &Pkt->dest_port); |
561 | } | 559 | } |
562 | rio_dprintk(RIO_DEBUG_TABLE, "Port %d phb destination: Old %x:%x New %x:%x\n", port, PortP->PhbP->destination & 0xff, (PortP->PhbP->destination >> 8) & 0xff, dest_unit, dest_port); | 560 | rio_dprintk(RIO_DEBUG_TABLE, "Port %d phb destination: Old %x:%x New %x:%x\n", port, PortP->PhbP->destination & 0xff, (PortP->PhbP->destination >> 8) & 0xff, dest_unit, dest_port); |
563 | WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8)); | 561 | writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination); |
564 | } | 562 | } |
565 | rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags); | 563 | rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags); |
566 | } | 564 | } |
567 | } | 565 | } |
568 | rio_dprintk(RIO_DEBUG_TABLE, "Entry nulled.\n"); | 566 | rio_dprintk(RIO_DEBUG_TABLE, "Entry nulled.\n"); |
569 | bzero((char *) HostMapP, sizeof(struct Map)); | 567 | memset(HostMapP, 0, sizeof(struct Map)); |
570 | work_done++; | 568 | work_done++; |
571 | } | 569 | } |
572 | } | 570 | } |
@@ -576,11 +574,11 @@ struct Map *MapP; | |||
576 | /* XXXXX lock me up */ | 574 | /* XXXXX lock me up */ |
577 | for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) { | 575 | for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) { |
578 | if (p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) { | 576 | if (p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) { |
579 | bzero((char *) &p->RIOSavedTable[entry], sizeof(struct Map)); | 577 | memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map)); |
580 | work_done++; | 578 | work_done++; |
581 | } | 579 | } |
582 | if (p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) { | 580 | if (p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) { |
583 | bzero((char *) &p->RIOConnectTable[entry], sizeof(struct Map)); | 581 | memset(&p->RIOConnectTable[entry], 0, sizeof(struct Map)); |
584 | work_done++; | 582 | work_done++; |
585 | } | 583 | } |
586 | } | 584 | } |
@@ -742,12 +740,9 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP) | |||
742 | } | 740 | } |
743 | 741 | ||
744 | 742 | ||
745 | int RIOReMapPorts(p, HostP, HostMapP) | 743 | int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP) |
746 | struct rio_info *p; | ||
747 | struct Host *HostP; | ||
748 | struct Map *HostMapP; | ||
749 | { | 744 | { |
750 | register struct Port *PortP; | 745 | struct Port *PortP; |
751 | uint SubEnt; | 746 | uint SubEnt; |
752 | uint HostPort; | 747 | uint HostPort; |
753 | uint SysPort; | 748 | uint SysPort; |
@@ -794,12 +789,12 @@ struct Map *HostMapP; | |||
794 | */ | 789 | */ |
795 | if ((HostP->Flags & RUN_STATE) == RC_RUNNING) { | 790 | if ((HostP->Flags & RUN_STATE) == RC_RUNNING) { |
796 | struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort]; | 791 | struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort]; |
797 | PortP->TxAdd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_add)); | 792 | PortP->TxAdd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_add)); |
798 | PortP->TxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_start)); | 793 | PortP->TxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_start)); |
799 | PortP->TxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_end)); | 794 | PortP->TxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_end)); |
800 | PortP->RxRemove = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_remove)); | 795 | PortP->RxRemove = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_remove)); |
801 | PortP->RxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_start)); | 796 | PortP->RxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_start)); |
802 | PortP->RxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_end)); | 797 | PortP->RxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_end)); |
803 | } else | 798 | } else |
804 | PortP->PhbP = NULL; | 799 | PortP->PhbP = NULL; |
805 | 800 | ||
@@ -866,9 +861,6 @@ struct Map *HostMapP; | |||
866 | PortP->RxDataStart = 0; | 861 | PortP->RxDataStart = 0; |
867 | PortP->Cor2Copy = 0; | 862 | PortP->Cor2Copy = 0; |
868 | PortP->Name = &HostMapP->Name[0]; | 863 | PortP->Name = &HostMapP->Name[0]; |
869 | #ifdef STATS | ||
870 | bzero((caddr_t) & PortP->Stat, sizeof(struct RIOStats)); | ||
871 | #endif | ||
872 | PortP->statsGather = 0; | 864 | PortP->statsGather = 0; |
873 | PortP->txchars = 0; | 865 | PortP->txchars = 0; |
874 | PortP->rxchars = 0; | 866 | PortP->rxchars = 0; |
@@ -876,10 +868,10 @@ struct Map *HostMapP; | |||
876 | PortP->closes = 0; | 868 | PortP->closes = 0; |
877 | PortP->ioctls = 0; | 869 | PortP->ioctls = 0; |
878 | if (PortP->TxRingBuffer) | 870 | if (PortP->TxRingBuffer) |
879 | bzero(PortP->TxRingBuffer, p->RIOBufferSize); | 871 | memset(PortP->TxRingBuffer, 0, p->RIOBufferSize); |
880 | else if (p->RIOBufferSize) { | 872 | else if (p->RIOBufferSize) { |
881 | PortP->TxRingBuffer = sysbrk(p->RIOBufferSize); | 873 | PortP->TxRingBuffer = kmalloc(p->RIOBufferSize, GFP_KERNEL); |
882 | bzero(PortP->TxRingBuffer, p->RIOBufferSize); | 874 | memset(PortP->TxRingBuffer, 0, p->RIOBufferSize); |
883 | } | 875 | } |
884 | PortP->TxBufferOut = 0; | 876 | PortP->TxBufferOut = 0; |
885 | PortP->TxBufferIn = 0; | 877 | PortP->TxBufferIn = 0; |
@@ -890,7 +882,7 @@ struct Map *HostMapP; | |||
890 | ** If the same, we have received the same rx pkt from the RTA | 882 | ** If the same, we have received the same rx pkt from the RTA |
891 | ** twice. Initialise to a value not equal to PHB_RX_TGL or 0. | 883 | ** twice. Initialise to a value not equal to PHB_RX_TGL or 0. |
892 | */ | 884 | */ |
893 | PortP->LastRxTgl = ~(uchar) PHB_RX_TGL; | 885 | PortP->LastRxTgl = ~(u8) PHB_RX_TGL; |
894 | 886 | ||
895 | /* | 887 | /* |
896 | ** and mark the port as usable | 888 | ** and mark the port as usable |
@@ -906,9 +898,7 @@ struct Map *HostMapP; | |||
906 | return 0; | 898 | return 0; |
907 | } | 899 | } |
908 | 900 | ||
909 | int RIOChangeName(p, MapP) | 901 | int RIOChangeName(struct rio_info *p, struct Map *MapP) |
910 | struct rio_info *p; | ||
911 | struct Map *MapP; | ||
912 | { | 902 | { |
913 | int host; | 903 | int host; |
914 | struct Map *HostMapP; | 904 | struct Map *HostMapP; |