static void kobj_class_compile_common(kobj_class_t cls, kobj_ops_t ops) { kobj_method_t *m; int i; KOBJ_ASSERT(MA_OWNED); /* * Don't do anything if we are already compiled. */ if (cls->ops) return; /* * First register any methods which need it. */ for (i = 0, m = cls->methods; m->desc; i++, m++) kobj_register_method(m->desc); /* * Then initialise the ops table. */ for (i = 0; i < KOBJ_CACHE_SIZE; i++) ops->cache[i] = &null_method; ops->cls = cls; cls->ops = ops; }
static void kobj_class_compile_common(kobj_class_t cls, kobj_ops_t ops) { kobj_method_t *m; int i; /* * Don't do anything if we are already compiled. */ if (cls->ops) return; /* * First register any methods which need it. */ for (i = 0, m = cls->methods; m->desc; i++, m++) kobj_register_method(m->desc); /* * Then initialise the ops table. */ bzero(ops, sizeof(struct kobj_ops)); ops->cls = cls; cls->ops = ops; }
static void kobj_class_compile(kobj_class_t cls) { kobj_method_t *m; kobj_ops_t ops; int i; /* * Don't do anything if we are already compiled. */ if (cls->ops) return; /* * Allocate space for the compiled ops table. */ ops = kmalloc(sizeof(struct kobj_ops), M_KOBJ, M_INTWAIT); for (i = 0; i < KOBJ_CACHE_SIZE; i++) ops->cache[i] = &null_method; if (cls->ops) { /* * In case of preemption, another thread might have been faster, * but that's fine for us. */ if (ops) kfree(ops, M_KOBJ); return; } if (!ops) panic("kobj_compile_methods: out of memory"); ops->cls = cls; cls->ops = ops; /* * Afterwards register any methods which need it. */ for (m = cls->methods; m->desc; m++) kobj_register_method(m->desc); }