Skip to contentSkip to conversation

drm/nouveau: remove >1 sclass support from nouveau_parent_create_

PATCH In review Marcin Slusarz 2 participants 4 messages Oct 7, 2012 – Oct 9, 2012 3 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/nouveau: remove >1 sclass support from nouveau_parent_create_

It's unused (only one codepath passes sclass at all and it's always one), broken (overwrites the same field, leaking previous one) and confusing.

---
 drivers/gpu/drm/nouveau/core/core/client.c           | 2 +-
 drivers/gpu/drm/nouveau/core/core/parent.c           | 3 +--
 drivers/gpu/drm/nouveau/core/include/subdev/device.h | 2 +-
 drivers/gpu/drm/nouveau/core/subdev/device/base.c    | 6 +++---
 4 files changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/core/core/client.c +1 -1
index c617f04..87850ec 100644
@@ -58,7 +58,7 @@ nouveau_client_create_(const char *name, u64 devname, const char *cfg,
 		return -ENODEV;
 
 	ret = nouveau_namedb_create_(NULL, NULL, &nouveau_client_oclass,
-				     NV_CLIENT_CLASS, nouveau_device_sclass,
+				     NV_CLIENT_CLASS, &nouveau_device_sclass,
 				     0, length, pobject);
 	client = *pobject;
 	if (ret)
drivers/gpu/drm/nouveau/core/core/parent.c +1 -2
index 0e7733c..1a48e58 100644
@@ -85,7 +85,7 @@ nouveau_parent_create_(struct nouveau_object *parent,
 	if (ret)
 		return ret;
 
-	while (sclass && sclass->ofuncs) {
+	if (sclass && sclass->ofuncs) {
 		nclass = kzalloc(sizeof(*nclass), GFP_KERNEL);
 		if (!nclass)
 			return -ENOMEM;
@@ -94,7 +94,6 @@ nouveau_parent_create_(struct nouveau_object *parent,
 		object->sclass = nclass;
 		nclass->engine = engine ? nv_engine(engine) : NULL;
 		nclass->oclass = sclass;
-		sclass++;
 	}
 
 	object->engine = engcls;
drivers/gpu/drm/nouveau/core/include/subdev/device.h +1 -1
index c9e4c4a..0966f33 100644
@@ -18,7 +18,7 @@ int nv50_identify(struct nouveau_device *);
 int nvc0_identify(struct nouveau_device *);
 int nve0_identify(struct nouveau_device *);
 
-extern struct nouveau_oclass nouveau_device_sclass[];
+extern struct nouveau_oclass nouveau_device_sclass;
 struct nouveau_device *nouveau_device_find(u64 name);
 
 #endif
drivers/gpu/drm/nouveau/core/subdev/device/base.c +3 -3
index 2cec8a8..352a940 100644
@@ -409,9 +409,9 @@ nouveau_devobj_ofuncs = {
  * nouveau_device: engine functions
  *****************************************************************************/
 struct nouveau_oclass
-nouveau_device_sclass[] = {
-	{ 0x0080, &nouveau_devobj_ofuncs },
-	{}
+nouveau_device_sclass = {
+	.handle = 0x0080,
+	.ofuncs = &nouveau_devobj_ofuncs,
 };
 
 static void
Signature · 1 line
1.7.12

A message that is not in the archive (sent off-list or not yet received): 1349650171-25045-4-git-send-email-marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 2 lines · Marcin Slusarz

It's unused (only one codepath passes sclass at all and it's always one), broken (overwrites the same field, leaking previous one) and confusing.

It's only *currently* unused, I have WIP code in branches that uses it, otherwise it wouldn't still exist :)

I will take a look today at the claims it's broken, it wasn't at some point but may have got busted along the way somehow.

Thanks!
Ben.

Quoted 80 lines
---
 drivers/gpu/drm/nouveau/core/core/client.c           | 2 +-
 drivers/gpu/drm/nouveau/core/core/parent.c           | 3 +--
 drivers/gpu/drm/nouveau/core/include/subdev/device.h | 2 +-
 drivers/gpu/drm/nouveau/core/subdev/device/base.c    | 6 +++---
 4 files changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/core/core/client.c +1 -1
index c617f04..87850ec 100644
@@ -58,7 +58,7 @@ nouveau_client_create_(const char *name, u64 devname, const char *cfg,
 		return -ENODEV;
 
 	ret = nouveau_namedb_create_(NULL, NULL, &nouveau_client_oclass,
-				     NV_CLIENT_CLASS, nouveau_device_sclass,
+				     NV_CLIENT_CLASS, &nouveau_device_sclass,
 				     0, length, pobject);
 	client = *pobject;
 	if (ret)
drivers/gpu/drm/nouveau/core/core/parent.c +1 -2
index 0e7733c..1a48e58 100644
@@ -85,7 +85,7 @@ nouveau_parent_create_(struct nouveau_object *parent,
 	if (ret)
 		return ret;
 
-	while (sclass && sclass->ofuncs) {
+	if (sclass && sclass->ofuncs) {
 		nclass = kzalloc(sizeof(*nclass), GFP_KERNEL);
 		if (!nclass)
 			return -ENOMEM;
@@ -94,7 +94,6 @@ nouveau_parent_create_(struct nouveau_object *parent,
 		object->sclass = nclass;
 		nclass->engine = engine ? nv_engine(engine) : NULL;
 		nclass->oclass = sclass;
-		sclass++;
 	}
 
 	object->engine = engcls;
drivers/gpu/drm/nouveau/core/include/subdev/device.h +1 -1
index c9e4c4a..0966f33 100644
@@ -18,7 +18,7 @@ int nv50_identify(struct nouveau_device *);
 int nvc0_identify(struct nouveau_device *);
 int nve0_identify(struct nouveau_device *);
 
-extern struct nouveau_oclass nouveau_device_sclass[];
+extern struct nouveau_oclass nouveau_device_sclass;
 struct nouveau_device *nouveau_device_find(u64 name);
 
 #endif
drivers/gpu/drm/nouveau/core/subdev/device/base.c +3 -3
index 2cec8a8..352a940 100644
@@ -409,9 +409,9 @@ nouveau_devobj_ofuncs = {
  * nouveau_device: engine functions
  *****************************************************************************/
 struct nouveau_oclass
-nouveau_device_sclass[] = {
-	{ 0x0080, &nouveau_devobj_ofuncs },
-	{}
+nouveau_device_sclass = {
+	.handle = 0x0080,
+	.ofuncs = &nouveau_devobj_ofuncs,
 };
 
 static void
Signature · 6 lines
1.7.12

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 20121008010646.GB4197-6RkuLLNOGXsZ315U/[email protected]

#4 lore raw
Quoted 5 lines · Ben Skeggs
Quoted 2 lines · Marcin Slusarz

It's unused (only one codepath passes sclass at all and it's always one), broken (overwrites the same field, leaking previous one) and confusing.

It's only *currently* unused, I have WIP code in branches that uses it, otherwise it wouldn't still exist :)

Yeah, like _nouveau_parent_ctor :P

Quoted 2 lines

I will take a look today at the claims it's broken, it wasn't at some point but may have got busted along the way somehow.

Oh, it chains them in list...

/me hides.

Marcin

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 8 lines · Marcin Slusarz
Quoted 5 lines · Ben Skeggs
Quoted 2 lines · Marcin Slusarz

It's unused (only one codepath passes sclass at all and it's always one), broken (overwrites the same field, leaking previous one) and confusing.

It's only *currently* unused, I have WIP code in branches that uses it, otherwise it wouldn't still exist :)

Yeah, like _nouveau_parent_ctor :P

Point taken :P

Quoted 7 lines
Quoted 3 lines

I will take a look today at the claims it's broken, it wasn't at some point but may have got busted along the way somehow.

Oh, it chains them in list...

/me hides.

Hehe :)

Ben.

Quoted 2 lines

Marcin