mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tonyj@suse.de
To: linux-kernel@vger.kernel.org
Cc: gregkh@suse.de, Kay Sievers <kay.sievers@vrfy.org>
Subject: [patch 1/6] Convert from class_device to device in drivers/char/drm
Date: Tue, 07 Aug 2007 22:28:43 -0700	[thread overview]
Message-ID: <20070808053013.880837000@suse.de> (raw)
In-Reply-To: <20070808052842.451400000@suse.de>

[-- Attachment #1: drm.patch --]
[-- Type: text/plain, Size: 6706 bytes --]

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

Signed-off-by: Tony Jones <tonyj@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>

---
 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};
 

-- 

  reply	other threads:[~2007-08-08  5:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-08  5:28 [patch 0/6] Convert from class_device to device [char, hwmon, video] tonyj
2007-08-08  5:28 ` tonyj [this message]
2007-08-14 22:35   ` [patch 1/6] Convert from class_device to device in drivers/char/drm Greg KH
2007-08-08  5:28 ` [patch 2/6] Convert from class_device to device in drivers/char tonyj
2007-08-08  5:28 ` [patch 3/6] Convert from class_device to device for hwmon tonyj
2007-08-14 22:35   ` Greg KH
2007-08-08  5:28 ` [patch 4/6] Convert from class_device to device for hwmon users tonyj
2007-08-08  5:28 ` [patch 5/6] Convert from class_device to device for drivers/video tonyj
2007-08-08  5:28 ` [patch 6/6] Misc cleanup tonyj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070808053013.880837000@suse.de \
    --to=tonyj@suse.de \
    --cc=gregkh@suse.de \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome