Kernel - Reworked PCI API to be cleaner
[tpg/acess2.git] / Modules / Network / RTL8139 / rtl8139.c
index c63dfee..c2ec80a 100644 (file)
@@ -125,7 +125,7 @@ int RTL8139_Install(char **Options)
        Uint16  base;
        tCard   *card;
        
-       giRTL8139_CardCount = PCI_CountDevices(VENDOR_ID, DEVICE_ID, 0);
+       giRTL8139_CardCount = PCI_CountDevices(VENDOR_ID, DEVICE_ID);
        Log_Debug("RTL8139", "%i cards", giRTL8139_CardCount);
        
        if( giRTL8139_CardCount == 0 )  return MODULE_ERR_NOTNEEDED;
@@ -133,10 +133,10 @@ int RTL8139_Install(char **Options)
        gaRTL8139_Cards = calloc( giRTL8139_CardCount, sizeof(tCard) );
        
        //while( (id = PCI_GetDevice(0x10EC, 0x8139, 0, id)) != -1 )
-       while( (id = PCI_GetDevice(VENDOR_ID, DEVICE_ID, 0, i)) != -1 )
+       while( (id = PCI_GetDevice(VENDOR_ID, DEVICE_ID, i)) != -1 )
        {
                card = &gaRTL8139_Cards[i];
-               base = PCI_AssignPort( id, 0, 0x100 );
+               base = PCI_GetBAR( id, 0 );
                card->IOBase = base;
                card->IRQ = PCI_GetIRQ( id );
                
@@ -255,7 +255,10 @@ Uint64 RTL8139_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
        ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
 
 retry:
-       Semaphore_Wait( &card->ReadSemaphore, 1 );
+       if( Semaphore_Wait( &card->ReadSemaphore, 1 ) != 1 )
+       {
+               LEAVE_RET('i', 0);
+       }
        
        Mutex_Acquire( &card->ReadMutex );
        
@@ -423,9 +426,13 @@ void RTL8139_IRQHandler(int Num)
                        
                        LOG("packet_count = %i, read_ofs = 0x%x", packet_count, read_ofs);
                        
-                       Semaphore_Signal( &card->ReadSemaphore, packet_count );
                        if( packet_count )
+                       {
+                               if( Semaphore_Signal( &card->ReadSemaphore, packet_count ) != packet_count ) {
+                                       // Oops?
+                               }
                                VFS_MarkAvaliable( &card->Node, 1 );
+                       }
                        
                        outw(card->IOBase + ISR, FLAG_ISR_ROK);
                }

UCC git Repository :: git.ucc.asn.au