提交 2c3af924 编写于 作者: B Ben Skeggs

drm/nouveau/core/client: use standard object dtor/init/fini paths

Preparation for supporting subclients, and also good for consistency.
Signed-off-by: NBen Skeggs <bskeggs@redhat.com>
上级 03295eab
...@@ -21,9 +21,6 @@ struct nvkm_client { ...@@ -21,9 +21,6 @@ struct nvkm_client {
int nvkm_client_new(const char *name, u64 device, const char *cfg, int nvkm_client_new(const char *name, u64 device, const char *cfg,
const char *dbg, struct nvkm_client **); const char *dbg, struct nvkm_client **);
void nvkm_client_del(struct nvkm_client **);
int nvkm_client_init(struct nvkm_client *);
int nvkm_client_fini(struct nvkm_client *, bool suspend);
int nvkm_client_notify_new(struct nvkm_object *, struct nvkm_event *, int nvkm_client_notify_new(struct nvkm_object *, struct nvkm_event *,
void *data, u32 size); void *data, u32 size);
......
...@@ -60,20 +60,24 @@ nvkm_client_ioctl(void *priv, bool super, void *data, u32 size, void **hack) ...@@ -60,20 +60,24 @@ nvkm_client_ioctl(void *priv, bool super, void *data, u32 size, void **hack)
static int static int
nvkm_client_resume(void *priv) nvkm_client_resume(void *priv)
{ {
return nvkm_client_init(priv); struct nvkm_client *client = priv;
return nvkm_object_init(&client->object);
} }
static int static int
nvkm_client_suspend(void *priv) nvkm_client_suspend(void *priv)
{ {
return nvkm_client_fini(priv, true); struct nvkm_client *client = priv;
return nvkm_object_fini(&client->object, true);
} }
static void static void
nvkm_client_driver_fini(void *priv) nvkm_client_driver_fini(void *priv)
{ {
struct nvkm_client *client = priv; struct nvkm_client *client = priv;
nvkm_client_del(&client); struct nvkm_object *object = &client->object;
nvkm_object_fini(object, false);
nvkm_object_del(&object);
} }
static int static int
......
...@@ -206,45 +206,36 @@ nvkm_client_child_get(struct nvkm_object *object, int index, ...@@ -206,45 +206,36 @@ nvkm_client_child_get(struct nvkm_object *object, int index,
return 0; return 0;
} }
static const struct nvkm_object_func static int
nvkm_client_object_func = { nvkm_client_fini(struct nvkm_object *object, bool suspend)
.mthd = nvkm_client_mthd,
.sclass = nvkm_client_child_get,
};
int
nvkm_client_fini(struct nvkm_client *client, bool suspend)
{ {
struct nvkm_object *object = &client->object; struct nvkm_client *client = nvkm_client(object);
const char *name[2] = { "fini", "suspend" }; const char *name[2] = { "fini", "suspend" };
int i; int i;
nvif_debug(object, "%s notify\n", name[suspend]); nvif_debug(object, "%s notify\n", name[suspend]);
for (i = 0; i < ARRAY_SIZE(client->notify); i++) for (i = 0; i < ARRAY_SIZE(client->notify); i++)
nvkm_client_notify_put(client, i); nvkm_client_notify_put(client, i);
return nvkm_object_fini(&client->object, suspend); return 0;
}
int
nvkm_client_init(struct nvkm_client *client)
{
return nvkm_object_init(&client->object);
} }
void static void *
nvkm_client_del(struct nvkm_client **pclient) nvkm_client_dtor(struct nvkm_object *object)
{ {
struct nvkm_client *client = *pclient; struct nvkm_client *client = nvkm_client(object);
int i; int i;
if (client) { for (i = 0; i < ARRAY_SIZE(client->notify); i++)
nvkm_client_fini(client, false); nvkm_client_notify_del(client, i);
for (i = 0; i < ARRAY_SIZE(client->notify); i++) return client;
nvkm_client_notify_del(client, i);
nvkm_object_dtor(&client->object);
kfree(*pclient);
*pclient = NULL;
}
} }
static const struct nvkm_object_func
nvkm_client = {
.dtor = nvkm_client_dtor,
.fini = nvkm_client_fini,
.mthd = nvkm_client_mthd,
.sclass = nvkm_client_child_get,
};
int int
nvkm_client_new(const char *name, u64 device, const char *cfg, nvkm_client_new(const char *name, u64 device, const char *cfg,
const char *dbg, struct nvkm_client **pclient) const char *dbg, struct nvkm_client **pclient)
...@@ -256,7 +247,7 @@ nvkm_client_new(const char *name, u64 device, const char *cfg, ...@@ -256,7 +247,7 @@ nvkm_client_new(const char *name, u64 device, const char *cfg,
return -ENOMEM; return -ENOMEM;
oclass.client = client; oclass.client = client;
nvkm_object_ctor(&nvkm_client_object_func, &oclass, &client->object); nvkm_object_ctor(&nvkm_client, &oclass, &client->object);
snprintf(client->name, sizeof(client->name), "%s", name); snprintf(client->name, sizeof(client->name), "%s", name);
client->device = device; client->device = device;
client->debug = nvkm_dbgopt(dbg, "CLIENT"); client->debug = nvkm_dbgopt(dbg, "CLIENT");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册