diff options
author | 2013-12-23 00:39:47 +1000 | |
---|---|---|
committer | 2014-01-23 13:39:09 +1000 | |
commit | 24a4ae86de89b5cbbf8530c371007383de9f2d58 (patch) | |
tree | d365b16ea16243fc945c6222340b091d71136416 /drivers/gpu/drm/nouveau/core/subdev/instmem/base.c | |
parent | drm/nouveau/pwr: implement a simple i2c stack (diff) | |
download | linux-dev-24a4ae86de89b5cbbf8530c371007383de9f2d58.tar.xz linux-dev-24a4ae86de89b5cbbf8530c371007383de9f2d58.zip |
drm/nouveau/instmem: tidy up the subdev class definition
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/core/subdev/instmem/base.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/core/subdev/instmem/base.c | 94 |
1 files changed, 52 insertions, 42 deletions
diff --git a/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c b/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c index 6565f3dbbe04..5f5abf564ade 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c +++ b/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c @@ -22,7 +22,7 @@ * Authors: Ben Skeggs */ -#include <subdev/instmem.h> +#include "priv.h" int nouveau_instobj_create_(struct nouveau_object *parent, @@ -65,54 +65,31 @@ _nouveau_instobj_dtor(struct nouveau_object *object) return nouveau_instobj_destroy(iobj); } -int -nouveau_instmem_create_(struct nouveau_object *parent, - struct nouveau_object *engine, - struct nouveau_oclass *oclass, - int length, void **pobject) -{ - struct nouveau_instmem *imem; - int ret; +/****************************************************************************** + * instmem subdev base implementation + *****************************************************************************/ - ret = nouveau_subdev_create_(parent, engine, oclass, 0, - "INSTMEM", "instmem", length, pobject); - imem = *pobject; - if (ret) - return ret; - - INIT_LIST_HEAD(&imem->list); - return 0; -} - -int -nouveau_instmem_init(struct nouveau_instmem *imem) +static int +nouveau_instmem_alloc(struct nouveau_instmem *imem, + struct nouveau_object *parent, u32 size, u32 align, + struct nouveau_object **pobject) { - struct nouveau_instobj *iobj; - int ret, i; + struct nouveau_object *engine = nv_object(imem); + struct nouveau_instmem_impl *impl = (void *)engine->oclass; + int ret; - ret = nouveau_subdev_init(&imem->base); + ret = nouveau_object_ctor(parent, engine, impl->instobj, + (void *)(unsigned long)align, size, pobject); if (ret) return ret; - mutex_lock(&imem->base.mutex); - - list_for_each_entry(iobj, &imem->list, head) { - if (iobj->suspend) { - for (i = 0; i < iobj->size; i += 4) - nv_wo32(iobj, i, iobj->suspend[i / 4]); - vfree(iobj->suspend); - iobj->suspend = NULL; - } - } - - mutex_unlock(&imem->base.mutex); - return 0; } int -nouveau_instmem_fini(struct nouveau_instmem *imem, bool suspend) +_nouveau_instmem_fini(struct nouveau_object *object, bool suspend) { + struct nouveau_instmem *imem = (void *)object; struct nouveau_instobj *iobj; int i, ret = 0; @@ -143,12 +120,45 @@ int _nouveau_instmem_init(struct nouveau_object *object) { struct nouveau_instmem *imem = (void *)object; - return nouveau_instmem_init(imem); + struct nouveau_instobj *iobj; + int ret, i; + + ret = nouveau_subdev_init(&imem->base); + if (ret) + return ret; + + mutex_lock(&imem->base.mutex); + + list_for_each_entry(iobj, &imem->list, head) { + if (iobj->suspend) { + for (i = 0; i < iobj->size; i += 4) + nv_wo32(iobj, i, iobj->suspend[i / 4]); + vfree(iobj->suspend); + iobj->suspend = NULL; + } + } + + mutex_unlock(&imem->base.mutex); + + return 0; } int -_nouveau_instmem_fini(struct nouveau_object *object, bool suspend) +nouveau_instmem_create_(struct nouveau_object *parent, + struct nouveau_object *engine, + struct nouveau_oclass *oclass, + int length, void **pobject) { - struct nouveau_instmem *imem = (void *)object; - return nouveau_instmem_fini(imem, suspend); + struct nouveau_instmem *imem; + int ret; + + ret = nouveau_subdev_create_(parent, engine, oclass, 0, + "INSTMEM", "instmem", length, pobject); + imem = *pobject; + if (ret) + return ret; + + INIT_LIST_HEAD(&imem->list); + imem->alloc = nouveau_instmem_alloc; + return 0; } |