| .. | .. |
|---|
| 25 | 25 | #include <nvif/if0008.h> |
|---|
| 26 | 26 | |
|---|
| 27 | 27 | void |
|---|
| 28 | | -nvif_mmu_fini(struct nvif_mmu *mmu) |
|---|
| 28 | +nvif_mmu_dtor(struct nvif_mmu *mmu) |
|---|
| 29 | 29 | { |
|---|
| 30 | 30 | kfree(mmu->kind); |
|---|
| 31 | 31 | kfree(mmu->type); |
|---|
| 32 | 32 | kfree(mmu->heap); |
|---|
| 33 | | - nvif_object_fini(&mmu->object); |
|---|
| 33 | + nvif_object_dtor(&mmu->object); |
|---|
| 34 | 34 | } |
|---|
| 35 | 35 | |
|---|
| 36 | 36 | int |
|---|
| 37 | | -nvif_mmu_init(struct nvif_object *parent, s32 oclass, struct nvif_mmu *mmu) |
|---|
| 37 | +nvif_mmu_ctor(struct nvif_object *parent, const char *name, s32 oclass, |
|---|
| 38 | + struct nvif_mmu *mmu) |
|---|
| 38 | 39 | { |
|---|
| 39 | 40 | static const struct nvif_mclass mems[] = { |
|---|
| 40 | 41 | { NVIF_CLASS_MEM_GF100, -1 }, |
|---|
| .. | .. |
|---|
| 50 | 51 | mmu->type = NULL; |
|---|
| 51 | 52 | mmu->kind = NULL; |
|---|
| 52 | 53 | |
|---|
| 53 | | - ret = nvif_object_init(parent, 0, oclass, &args, sizeof(args), |
|---|
| 54 | | - &mmu->object); |
|---|
| 54 | + ret = nvif_object_ctor(parent, name ? name : "nvifMmu", 0, oclass, |
|---|
| 55 | + &args, sizeof(args), &mmu->object); |
|---|
| 55 | 56 | if (ret) |
|---|
| 56 | 57 | goto done; |
|---|
| 57 | 58 | |
|---|
| .. | .. |
|---|
| 110 | 111 | |
|---|
| 111 | 112 | if (mmu->kind_nr) { |
|---|
| 112 | 113 | struct nvif_mmu_kind_v0 *kind; |
|---|
| 113 | | - u32 argc = sizeof(*kind) + sizeof(*kind->data) * mmu->kind_nr; |
|---|
| 114 | + size_t argc = struct_size(kind, data, mmu->kind_nr); |
|---|
| 114 | 115 | |
|---|
| 115 | 116 | if (ret = -ENOMEM, !(kind = kmalloc(argc, GFP_KERNEL))) |
|---|
| 116 | 117 | goto done; |
|---|
| .. | .. |
|---|
| 121 | 122 | kind, argc); |
|---|
| 122 | 123 | if (ret == 0) |
|---|
| 123 | 124 | memcpy(mmu->kind, kind->data, kind->count); |
|---|
| 125 | + mmu->kind_inv = kind->kind_inv; |
|---|
| 124 | 126 | kfree(kind); |
|---|
| 125 | 127 | } |
|---|
| 126 | 128 | |
|---|
| 127 | 129 | done: |
|---|
| 128 | 130 | if (ret) |
|---|
| 129 | | - nvif_mmu_fini(mmu); |
|---|
| 131 | + nvif_mmu_dtor(mmu); |
|---|
| 130 | 132 | return ret; |
|---|
| 131 | 133 | } |
|---|