drm: remove drm_file_t, drm_device_t and drm_head_t typedefs
[deliverable/linux.git] / drivers / char / drm / drm_sysfs.c
index 0b9f98a7eb10b1e2528e763be712f7e56c4c8911..cf4349b00b07474f21fb6168a6bed2fa1a10a8a3 100644 (file)
@@ -12,7 +12,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/device.h>
 #include <linux/kdev_t.h>
 #include <linux/err.h>
@@ -43,13 +42,24 @@ static CLASS_ATTR(version, S_IRUGO, version_show, NULL);
 struct class *drm_sysfs_create(struct module *owner, char *name)
 {
        struct class *class;
+       int err;
 
        class = class_create(owner, name);
-       if (!class)
-               return class;
+       if (IS_ERR(class)) {
+               err = PTR_ERR(class);
+               goto err_out;
+       }
+
+       err = class_create_file(class, &class_attr_version);
+       if (err)
+               goto err_out_class;
 
-       class_create_file(class, &class_attr_version);
        return class;
+
+err_out_class:
+       class_destroy(class);
+err_out:
+       return ERR_PTR(err);
 }
 
 /**
@@ -70,7 +80,7 @@ void drm_sysfs_destroy(struct class *class)
 
 static ssize_t show_dri(struct class_device *class_device, char *buf)
 {
-       drm_device_t * dev = ((drm_head_t *)class_get_devdata(class_device))->dev;
+       struct drm_device * dev = ((struct drm_head *)class_get_devdata(class_device))->dev;
        if (dev->driver->dri_library_name)
                return dev->driver->dri_library_name(dev, buf);
        return snprintf(buf, PAGE_SIZE, "%s\n", dev->driver->pci_driver.name);
@@ -94,23 +104,39 @@ static struct class_device_attribute class_device_attrs[] = {
  * Note: the struct class passed to this function must have previously been
  * created with a call to drm_sysfs_create().
  */
-struct class_device *drm_sysfs_device_add(struct class *cs, drm_head_t *head)
+struct class_device *drm_sysfs_device_add(struct class *cs, struct drm_head *head)
 {
        struct class_device *class_dev;
-       int i;
+       int i, j, err;
 
        class_dev = class_device_create(cs, NULL,
                                        MKDEV(DRM_MAJOR, head->minor),
                                        &(head->dev->pdev)->dev,
                                        "card%d", head->minor);
-       if (!class_dev)
-               return NULL;
+       if (IS_ERR(class_dev)) {
+               err = PTR_ERR(class_dev);
+               goto err_out;
+       }
 
        class_set_devdata(class_dev, head);
 
-       for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
-               class_device_create_file(class_dev, &class_device_attrs[i]);
+       for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) {
+               err = class_device_create_file(class_dev,
+                                              &class_device_attrs[i]);
+               if (err)
+                       goto err_out_files;
+       }
+
        return class_dev;
+
+err_out_files:
+       if (i > 0)
+               for (j = 0; j < i; j++)
+                       class_device_remove_file(class_dev,
+                                                &class_device_attrs[i]);
+       class_device_unregister(class_dev);
+err_out:
+       return ERR_PTR(err);
 }
 
 /**
This page took 0.117292 seconds and 5 git commands to generate.