[patch 1/6] Convert from class_device to device in drivers/char/drm

From: tonyj
Date: Wed Aug 08 2007 - 01:32:28 EST


Convert from class_device to device in drivers/char/drm.

Signed-off-by: Tony Jones <tonyj@xxxxxxx>
Signed-off-by: Kay Sievers <kay.sievers@xxxxxxxx>

---
drivers/char/drm/drmP.h | 8 ++---
drivers/char/drm/drm_stub.c | 9 +++---
drivers/char/drm/drm_sysfs.c | 58 ++++++++++++++++++++++---------------------
3 files changed, 39 insertions(+), 36 deletions(-)

Index: b/drivers/char/drm/drm_sysfs.c
===================================================================
--- a/drivers/char/drm/drm_sysfs.c
+++ b/drivers/char/drm/drm_sysfs.c
@@ -78,79 +78,81 @@ void drm_sysfs_destroy(struct class *cla
class_destroy(class);
}

-static ssize_t show_dri(struct class_device *class_device, char *buf)
+static ssize_t show_dri(struct device *drm_sysfs_dev,
+ struct device_attribute *attr, char *buf)
{
- struct drm_device * dev = ((struct drm_head *)class_get_devdata(class_device))->dev;
+ struct drm_device *dev =
+ ((struct drm_head *)dev_get_drvdata(drm_sysfs_dev))->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);
}

-static struct class_device_attribute class_device_attrs[] = {
+static struct device_attribute drm_sysfs_device_attrs[] = {
__ATTR(dri_library_name, S_IRUGO, show_dri, NULL),
};

/**
- * drm_sysfs_device_add - adds a class device to sysfs for a character driver
+ * drm_sysfs_device_add - adds a device to sysfs for a character driver
* @cs: pointer to the struct class that this device should be registered to.
* @dev: the dev_t for the device to be added.
* @device: a pointer to a struct device that is assiociated with this class device.
* @fmt: string for the class device's name
*
- * A struct class_device will be created in sysfs, registered to the specified
+ * A struct device will be created in sysfs, registered to the specified
* class. A "dev" file will be created, showing the dev_t for the device. The
- * pointer to the struct class_device will be returned from the call. Any further
+ * pointer to the struct device will be returned from the call. Any further
* sysfs files that might be required can be created using this pointer.
* 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, struct drm_head *head)
+struct device *drm_sysfs_device_add(struct class *cs, struct drm_head *head)
{
- struct class_device *class_dev;
+ struct device *drm_sysfs_dev;
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 (IS_ERR(class_dev)) {
- err = PTR_ERR(class_dev);
+ drm_sysfs_dev = device_create(cs, &(head->dev->pdev)->dev,
+ MKDEV(DRM_MAJOR, head->minor),
+ "card%d", head->minor);
+ if (IS_ERR(drm_sysfs_dev)) {
+ err = PTR_ERR(drm_sysfs_dev);
goto err_out;
}

- class_set_devdata(class_dev, head);
+ dev_set_drvdata(drm_sysfs_dev, head);

- for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) {
- err = class_device_create_file(class_dev,
- &class_device_attrs[i]);
+ for (i = 0; i < ARRAY_SIZE(drm_sysfs_device_attrs); i++) {
+ err = device_create_file(drm_sysfs_dev,
+ &drm_sysfs_device_attrs[i]);
if (err)
goto err_out_files;
}

- return class_dev;
+ return drm_sysfs_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);
+ device_remove_file(drm_sysfs_dev,
+ &drm_sysfs_device_attrs[i]);
+ device_unregister(drm_sysfs_dev);
err_out:
return ERR_PTR(err);
}

/**
- * drm_sysfs_device_remove - removes a class device that was created with drm_sysfs_device_add()
- * @dev: the dev_t of the device that was previously registered.
+ * drm_sysfs_device_remove - removes a device that was created with drm_sysfs_device_add()
+ * @drm_sysfs_dev: the device that was previously registered
*
* This call unregisters and cleans up a class device that was created with a
* call to drm_sysfs_device_add()
*/
-void drm_sysfs_device_remove(struct class_device *class_dev)
+void drm_sysfs_device_remove(struct device *drm_sysfs_dev)
{
int i;

- for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
- class_device_remove_file(class_dev, &class_device_attrs[i]);
- class_device_unregister(class_dev);
+ for (i = 0; i < ARRAY_SIZE(drm_sysfs_device_attrs); i++)
+ device_remove_file(drm_sysfs_dev, &drm_sysfs_device_attrs[i]);
+ device_unregister(drm_sysfs_dev);
}
Index: b/drivers/char/drm/drmP.h
===================================================================
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -622,7 +622,7 @@ struct drm_head {
struct drm_device *dev;
struct proc_dir_entry *dev_root; /**< proc directory entry */
dev_t device; /**< Device number for mknod */
- struct class_device *dev_class;
+ struct device *drm_sysfs_class;
};

/**
@@ -1052,9 +1052,9 @@ extern void drm_pci_free(struct drm_devi
/* sysfs support (drm_sysfs.c) */
extern struct class *drm_sysfs_create(struct module *owner, char *name);
extern void drm_sysfs_destroy(struct class *cs);
-extern struct class_device *drm_sysfs_device_add(struct class *cs,
- struct drm_head *head);
-extern void drm_sysfs_device_remove(struct class_device *class_dev);
+extern struct device *drm_sysfs_device_add(struct class *cs,
+ struct drm_head *head);
+extern void drm_sysfs_device_remove(struct device *drm_sysfs_dev);

/*
* Basic memory manager support (drm_mm.c)
Index: b/drivers/char/drm/drm_stub.c
===================================================================
--- a/drivers/char/drm/drm_stub.c
+++ b/drivers/char/drm/drm_stub.c
@@ -168,11 +168,12 @@ static int drm_get_head(struct drm_devic
goto err_g1;
}

- head->dev_class = drm_sysfs_device_add(drm_class, head);
- if (IS_ERR(head->dev_class)) {
+ head->drm_sysfs_class =
+ drm_sysfs_device_add(drm_class, head);
+ if (IS_ERR(head->drm_sysfs_class)) {
printk(KERN_ERR
"DRM: Error sysfs_device_add.\n");
- ret = PTR_ERR(head->dev_class);
+ ret = PTR_ERR(head->drm_sysfs_class);
goto err_g2;
}
*heads = head;
@@ -283,7 +284,7 @@ int drm_put_head(struct drm_head * head)
DRM_DEBUG("release secondary minor %d\n", minor);

drm_proc_cleanup(minor, drm_proc_root, head->dev_root);
- drm_sysfs_device_remove(head->dev_class);
+ drm_sysfs_device_remove(head->drm_sysfs_class);

*head = (struct drm_head) {.dev = NULL};


--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/