summaryrefslogtreecommitdiff
path: root/linux-core/drm_sysfs.c
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2007-07-12 15:28:17 -0700
committerIan Romanick <idr@us.ibm.com>2007-07-12 15:28:17 -0700
commit5522136b7f01402ae02cbe35180e3d80f850a6b3 (patch)
tree275da77af4df8b332f17cb503a4b58b608de8620 /linux-core/drm_sysfs.c
parent76ca1e858fb8e1a65ea49c0c62350d7ca91044a2 (diff)
parent851c950d988e5a47fa6add71427e5ef8d4dcf231 (diff)
Merge branch 'master' into xgi-0-0-2
Diffstat (limited to 'linux-core/drm_sysfs.c')
-rw-r--r--linux-core/drm_sysfs.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/linux-core/drm_sysfs.c b/linux-core/drm_sysfs.c
index ace0778b..9b2f5dce 100644
--- a/linux-core/drm_sysfs.c
+++ b/linux-core/drm_sysfs.c
@@ -93,11 +93,15 @@ struct drm_sysfs_class *drm_sysfs_create(struct module *owner, char *name)
retval = class_register(&cs->class);
if (retval)
goto error;
- class_create_file(&cs->class, &class_attr_version);
+ retval = class_create_file(&cs->class, &class_attr_version);
+ if (retval)
+ goto error_with_class;
return cs;
- error:
+ error_with_class:
+ class_unregister(&cs->class);
+ error:
kfree(cs);
return ERR_PTR(retval);
}
@@ -170,16 +174,31 @@ struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs,
if (retval)
goto error;
- class_device_create_file(&s_dev->class_dev, &cs->attr);
+ retval = class_device_create_file(&s_dev->class_dev, &cs->attr);
+ if (retval)
+ goto error_with_device;
+
class_set_devdata(&s_dev->class_dev, head);
- for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
- class_device_create_file(&s_dev->class_dev, &class_device_attrs[i]);
+ for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) {
+ retval = class_device_create_file(&s_dev->class_dev,
+ &class_device_attrs[i]);
+ if (retval)
+ goto error_with_files;
+ }
return &s_dev->class_dev;
-error:
+ error_with_files:
+ while (i > 0)
+ class_device_remove_file(&s_dev->class_dev,
+ &class_device_attrs[--i]);
+ class_device_remove_file(&s_dev->class_dev, &cs->attr);
+ error_with_device:
+ class_device_unregister(&s_dev->class_dev);
+ error:
kfree(s_dev);
+
return ERR_PTR(retval);
}