struct nvkm_object **pengine,
struct nvkm_oclass **poclass)
{
- struct nvkm_sclass *sclass;
+ struct nvkm_oclass *sclass, *oclass;
struct nvkm_engine *engine;
- struct nvkm_oclass *oclass;
u64 mask;
+ int i;
sclass = nv_parent(parent)->sclass;
- while (sclass) {
- if ((sclass->oclass->handle & 0xffff) == handle) {
+ while ((oclass = sclass++) && oclass->ofuncs) {
+ if (oclass->handle == handle) {
*pengine = &parent->engine->subdev.object;
- *poclass = sclass->oclass;
+ *poclass = oclass;
return 0;
}
-
- sclass = sclass->sclass;
}
mask = nv_parent(parent)->engine;
- while (mask) {
- int i = __ffs64(mask);
-
- if (nv_iclass(parent, NV_CLIENT_CLASS))
- engine = nv_engine(nv_client(parent)->device);
- else
- engine = nvkm_engine(parent, i);
-
+ while (i = __ffs64(mask), mask) {
+ engine = nvkm_engine(parent, i);
if (engine) {
oclass = engine->sclass;
while (oclass->ofuncs) {
- if ((oclass->handle & 0xffff) == handle) {
+ if (oclass->handle == handle) {
*pengine = nv_object(engine);
*poclass = oclass;
return 0;
int
nvkm_parent_lclass(struct nvkm_object *parent, u32 *lclass, int size)
{
- struct nvkm_sclass *sclass;
+ struct nvkm_oclass *sclass, *oclass;
struct nvkm_engine *engine;
- struct nvkm_oclass *oclass;
int nr = -1, i;
u64 mask;
sclass = nv_parent(parent)->sclass;
- while (sclass) {
+ while ((oclass = sclass++) && oclass->ofuncs) {
if (++nr < size)
- lclass[nr] = sclass->oclass->handle & 0xffff;
- sclass = sclass->sclass;
+ lclass[nr] = oclass->handle;
}
mask = nv_parent(parent)->engine;
if (engine && (oclass = engine->sclass)) {
while (oclass->ofuncs) {
if (++nr < size)
- lclass[nr] = oclass->handle & 0xffff;
+ lclass[nr] = oclass->handle;
oclass++;
}
}
int size, void **pobject)
{
struct nvkm_parent *object;
- struct nvkm_sclass *nclass;
int ret;
ret = nvkm_object_create_(parent, engine, oclass, pclass |
if (ret)
return ret;
- while (sclass && sclass->ofuncs) {
- nclass = kzalloc(sizeof(*nclass), GFP_KERNEL);
- if (!nclass)
- return -ENOMEM;
-
- nclass->sclass = object->sclass;
- object->sclass = nclass;
- nclass->engine = engine ? nv_engine(engine) : NULL;
- nclass->oclass = sclass;
- sclass++;
- }
-
+ object->sclass = sclass;
object->engine = engcls;
return 0;
}
void
nvkm_parent_destroy(struct nvkm_parent *parent)
{
- struct nvkm_sclass *sclass;
-
- while ((sclass = parent->sclass)) {
- parent->sclass = sclass->sclass;
- kfree(sclass);
- }
-
nvkm_object_destroy(&parent->object);
}