CKTfndDev(), rewrite
This commit is contained in:
parent
b96be8d576
commit
771d1fa697
|
|
@ -14,7 +14,6 @@ int
|
||||||
CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel *modfast)
|
CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel *modfast)
|
||||||
{
|
{
|
||||||
GENinstance *here;
|
GENinstance *here;
|
||||||
GENmodel *mods;
|
|
||||||
|
|
||||||
/* we know the device instance `fast' */
|
/* we know the device instance `fast' */
|
||||||
if (fast && *fast) {
|
if (fast && *fast) {
|
||||||
|
|
@ -23,57 +22,18 @@ CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel *
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we know the model `modfast', but need to find the device instance */
|
|
||||||
if (modfast) {
|
|
||||||
here = nghash_find(ckt->DEVnameHash, name);
|
here = nghash_find(ckt->DEVnameHash, name);
|
||||||
if (here && here->GENmodPtr == modfast) {
|
|
||||||
|
if (here) {
|
||||||
|
|
||||||
if (fast)
|
if (fast)
|
||||||
*fast = here;
|
*fast = here;
|
||||||
|
|
||||||
if (type)
|
if (type)
|
||||||
*type = modfast->GENmodType;
|
*type = here->GENmodPtr->GENmodType;
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
return E_NODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we know device `type', but need to find model and device instance */
|
|
||||||
if (*type >= 0 && *type < DEVmaxnum) {
|
|
||||||
/* look through all models */
|
|
||||||
for (mods = ckt->CKThead[*type]; mods ; mods = mods->GENnextModel) {
|
|
||||||
/* and all instances */
|
|
||||||
here = nghash_find(ckt->DEVnameHash, name);
|
|
||||||
if (here && here->GENmodPtr == mods) {
|
|
||||||
if (fast)
|
|
||||||
*fast = here;
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
if (mods->GENmodName == NULL)
|
|
||||||
return E_NODEV;
|
return E_NODEV;
|
||||||
}
|
|
||||||
return E_NOMOD;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we don't even know `type', search all of them */
|
|
||||||
if (*type == -1) {
|
|
||||||
for (*type = 0; *type < DEVmaxnum; (*type)++) {
|
|
||||||
/* look through all models */
|
|
||||||
for (mods = ckt->CKThead[*type]; mods; mods = mods->GENnextModel) {
|
|
||||||
/* and all instances */
|
|
||||||
here = nghash_find(ckt->DEVnameHash, name);
|
|
||||||
if (here && here->GENmodPtr == mods) {
|
|
||||||
if (fast)
|
|
||||||
*fast = here;
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
if (mods->GENmodName == NULL)
|
|
||||||
return E_NODEV;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*type = -1;
|
|
||||||
return E_NODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
return E_BADPARM;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue