#if NEED_TO_FIX 
#ifdef NEED_TO_FIX 
int RIOAssignRta( struct rio_info *p, struct Map *MapP ){    int host;    struct Map *HostMapP;    char *sptr;    int	link;    rio_dprintk (RIO_DEBUG_TABLE, "Assign entry on host %x, rta %x, ID %d, Sysport %d\n",				MapP->HostUniqueNum,MapP->RtaUniqueNum,				MapP->ID, (int)MapP->SysPort);    if ((MapP->ID != (ushort)-1) &&	((int)MapP->ID < (int)1 || (int)MapP->ID > MAX_RUP ))    {	rio_dprintk (RIO_DEBUG_TABLE, "Bad ID in map entry!\n");	p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;	return -EINVAL;    }    if (MapP->RtaUniqueNum == 0)    {	rio_dprintk (RIO_DEBUG_TABLE, "Rta Unique number zero!\n");	p->RIOError.Error = RTA_UNIQUE_NUMBER_ZERO;	return -EINVAL;    }    if ( (MapP->SysPort != NO_PORT) && (MapP->SysPort % PORTS_PER_RTA) )    {	rio_dprintk (RIO_DEBUG_TABLE, "Port %d not multiple of %d!\n",(int)MapP->SysPort,PORTS_PER_RTA);	p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;	return -EINVAL;    }    if ( (MapP->SysPort != NO_PORT) && (MapP->SysPort >= RIO_PORTS) )    {	rio_dprintk (RIO_DEBUG_TABLE, "Port %d not valid!\n",(int)MapP->SysPort);	p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;	return -EINVAL;    }    /*    ** Copy the name across to the map entry.    */    MapP->Name[MAX_NAME_LEN-1] = '\0';    sptr = MapP->Name;    while ( *sptr )    {    if ( *sptr<' ' || *sptr>'~' )    {	rio_dprintk (RIO_DEBUG_TABLE, "Name entry contains non-printing characters!\n");	p->RIOError.Error = BAD_CHARACTER_IN_NAME;	return -EINVAL;    }    sptr++;    }    for ( host=0; host < p->RIONumHosts; host++ )    {	if ( MapP->HostUniqueNum == p->RIOHosts[host].UniqueNum )	{	    if ( (p->RIOHosts[host].Flags & RUN_STATE) != RC_RUNNING )	    {		p->RIOError.Error = HOST_NOT_RUNNING;		return -ENXIO;	    }	    /*	    ** Now we have a host we need to allocate an ID	    ** if the entry does not already have one.	    */	    if (MapP->ID == (ushort)-1)	    {		int nNewID;		rio_dprintk (RIO_DEBUG_TABLE, "Attempting to get a new ID for rta \"%s\"\n",		      MapP->Name);		/*		** The idea here is to allow RTA's to be assigned		** before they actually appear on the network.		** This allows the addition of RTA's without having		** to plug them in.		** What we do is:		**  - Find a free ID and allocate it to the RTA.		**  - If this map entry is the second half of a		**    16 port entry then find the other half and		**    make sure the 2 cross reference each other.		*/		if (RIOFindFreeID(p, &p->RIOHosts[host], &nNewID, NULL) != 0)		{		    p->RIOError.Error = COULDNT_FIND_ENTRY;		    return -EBUSY;		}		MapP->ID = (ushort)nNewID + 1;		rio_dprintk (RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID);		HostMapP = &p->RIOHosts[host].Mapping[nNewID];		HostMapP->RtaUniqueNum = MapP->RtaUniqueNum;		HostMapP->HostUniqueNum = MapP->HostUniqueNum;		HostMapP->ID = MapP->ID;		for (link = 0; link < LINKS_PER_UNIT; link++)		{		    HostMapP->Topology[link].Unit = ROUTE_DISCONNECT;		    HostMapP->Topology[link].Link = NO_LINK;		}		if (MapP->Flags & RTA16_SECOND_SLOT)		{		    int unit;		    for (unit = 0; unit < MAX_RUP; unit++)			if (p->RIOHosts[host].Mapping[unit].RtaUniqueNum ==			    MapP->RtaUniqueNum)			    break;		    if (unit == MAX_RUP)		    {			p->RIOError.Error = COULDNT_FIND_ENTRY;			return -EBUSY;		    }		    HostMapP->Flags |= RTA16_SECOND_SLOT;		    HostMapP->ID2 = MapP->ID2 = p->RIOHosts[host].Mapping[unit].ID;		    p->RIOHosts[host].Mapping[unit].ID2 = MapP->ID;		    rio_dprintk (RIO_DEBUG_TABLE, "Cross referenced id %d to ID %d.\n",			  MapP->ID,			  p->RIOHosts[host].Mapping[unit].ID);		}	    }	    HostMapP = &p->RIOHosts[host].Mapping[MapP->ID-1];	    if ( HostMapP->Flags & SLOT_IN_USE )	    {		rio_dprintk (RIO_DEBUG_TABLE, "Map table slot for ID %d is already in use.\n", MapP->ID);		p->RIOError.Error = ID_ALREADY_IN_USE;		return -EBUSY;	    }	    /*	    ** Assign the sys ports and the name, and mark the slot as	    ** being in use.	    */	    HostMapP->SysPort = MapP->SysPort;	    if ((MapP->Flags & RTA16_SECOND_SLOT) == 0)	      CCOPY( MapP->Name, HostMapP->Name, MAX_NAME_LEN );	    HostMapP->Flags = SLOT_IN_USE | RTA_BOOTED;#if NEED_TO_FIX	    RIO_SV_BROADCAST(p->RIOHosts[host].svFlags[MapP->ID-1]);#endif	    if (MapP->Flags & RTA16_SECOND_SLOT)		HostMapP->Flags |= RTA16_SECOND_SLOT;	    RIOReMapPorts( p, &p->RIOHosts[host], HostMapP );	    /*	    ** Adjust 2nd block of 8 phbs	    */	    if (MapP->Flags & RTA16_SECOND_SLOT)		RIOFixPhbs(p, &p->RIOHosts[host], HostMapP->ID - 1);	    if ( HostMapP->SysPort != NO_PORT )	    {		if ( HostMapP->SysPort < p->RIOFirstPortsBooted )		    p->RIOFirstPortsBooted = HostMapP->SysPort;		if ( HostMapP->SysPort > p->RIOLastPortsBooted )		    p->RIOLastPortsBooted = HostMapP->SysPort;	    }	    if (MapP->Flags & RTA16_SECOND_SLOT)	        rio_dprintk (RIO_DEBUG_TABLE, "Second map of RTA %s added to configuration\n",		 p->RIOHosts[host].Mapping[MapP->ID2 - 1].Name);	    else	        rio_dprintk (RIO_DEBUG_TABLE, "RTA %s added to configuration\n", MapP->Name);	    return 0;	}    }    p->RIOError.Error = UNKNOWN_HOST_NUMBER;    rio_dprintk (RIO_DEBUG_TABLE, "Unknown host %x\n", MapP->HostUniqueNum);    return -ENXIO;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/44456d37b59d8e541936ed26d8b6e08d27e88ac1/riotable.c/buggy/drivers/char/rio/riotable.c