rem: dprintf( "rtl8139_nielx read_hook: The transfer is not yet finished!!!\n" ); return B_IO_ERROR;
add: TRACE( "rtl8139_nielx read_hook: The transfer is not yet finished!!!\n" ); unlock( former ); goto restart;
context: read_hook (void* cookie, off_t position, void *buf, size_t* num_bytes){	rtl8139_properties_t *data =/* (rtl8139_properties_t *)*/cookie;	packetheader_t *packet_header;		dprintf( "rtl8139_nielx: read_hook()\n" );	//if( !data->nonblocking )		acquire_sem_etc( data->input_wait , 1 , B_CAN_INTERRUPT , 0 );		//Next: check in command register if there's actually anything to be read	if ( READ_8( Command ) & BUFE  )	{		dprintf( "rtl8139_nielx read_hook: Nothing to read!!!\n" );		return B_IO_ERROR;	}		// Retrieve the packet header	packet_header = (packetheader_t *) ( ( uint8 *)data->receivebufferlog + data->receivebufferoffset );		// Check if the transfer is already done: EarlyRX	if ( packet_header->length == 0xfff0 )	{		dprintf( "rtl8139_nielx read_hook: The transfer is not yet finished!!!\n" );		return B_IO_ERROR;	}		//Check for an error: if needed: resetrx, length may not be bigger than 1514 + 4 CRC	if ( !( packet_header->bits & 0x1 ) || packet_header->length > 1518 )	{		dprintf( "rtl8139_nielx read_hook: Error in package reception: bits: %u length %u!!!\n" , packet_header->bits , packet_header->length);		return B_IO_ERROR;	}		dprintf( "rtl8139_nielx read_hook(): Packet size: %u Receiveheader: %u Buffer size: %lu\n" , packet_header->length , packet_header->bits , *num_bytes );		//Copy the packet	*num_bytes = packet_header->length - 4;	if ( data->receivebufferoffset + *num_bytes > 65536 )	{		//Packet wraps around , copy last bits except header ( = +4 )		memcpy( buf , data->receivebufferlog + data->receivebufferoffset + 4 , 0x10000 - ( data->receivebufferoffset + 4 ) ); 		//copy remaining bytes from the beginning		memcpy( buf + 0x10000 - ( data->receivebufferoffset + 4 ) , data->receivebufferlog , *num_bytes - (0x10000 - ( data->receivebufferoffset + 4 ) ) );		dprintf( "rtl8139_nielx read_hook: Wrapping around end of buffer\n" );	}	else		memcpy( buf , data->receivebufferlog + data->receivebufferoffset + 4 , packet_header->length - 4);  //length-4 because we don't want to copy the 4 bytes CRC		//Update the buffer -- 4 for the header length, plus 3 for the dword allignment	data->receivebufferoffset = ( data->receivebufferoffset + packet_header->length + 4 + 3 ) & ~3;				WRITE_16( CAPR , data->receivebufferoffset - 16 ); //-16, avoid overflow		dprintf( "rtl8139_nielx read_hook(): CBP %u CAPR %u \n" , READ_16( CBR ) , READ_16( CAPR ) );		// Re-enable interrupts	WRITE_16( ISR , ReceiveOk );	WRITE_16( IMR , 		ReceiveOk | ReceiveError | TransmitOk | TransmitError | 		ReceiveOverflow | ReceiveUnderflow | ReceiveFIFOOverrun |		TimeOut | SystemError );	return packet_header->length - 4;}