public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Driver Core update for 2.6.4
Date: Mon, 15 Mar 2004 15:59:08 -0800	[thread overview]
Message-ID: <1079395148429@kroah.com> (raw)
In-Reply-To: <10793951483511@kroah.com>

ChangeSet 1.1608.84.11, 2004/03/11 16:35:34-08:00, ogasawara@osdl.org

[PATCH] add sysfs simple class support for DRI char device

Patch adds sysfs simple class support for DRI character device (Major
226).  Also, adds some error checking.


 drivers/char/drm/drm_stub.h |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)


diff -Nru a/drivers/char/drm/drm_stub.h b/drivers/char/drm/drm_stub.h
--- a/drivers/char/drm/drm_stub.h	Mon Mar 15 15:28:51 2004
+++ b/drivers/char/drm/drm_stub.h	Mon Mar 15 15:28:51 2004
@@ -35,6 +35,8 @@
 
 #define DRM_STUB_MAXCARDS 16	/* Enough for one machine */
 
+static struct class_simple *drm_class;
+
 /** Stub list. One for each minor. */
 static struct drm_stub_list {
 	const char             *name;
@@ -117,6 +119,7 @@
 			DRM(stub_root) = DRM(proc_init)(dev, i, DRM(stub_root),
 							&DRM(stub_list)[i]
 							.dev_root);
+			class_simple_device_add(drm_class, MKDEV(DRM_MAJOR, i), NULL, name);
 			return i;
 		}
 	}
@@ -141,6 +144,7 @@
 	DRM(proc_cleanup)(minor, DRM(stub_root),
 			  DRM(stub_list)[minor].dev_root);
 	if (minor) {
+		class_simple_device_remove(MKDEV(DRM_MAJOR, minor));
 		inter_module_put("drm");
 	} else {
 		inter_module_unregister("drm");
@@ -148,6 +152,8 @@
 			  sizeof(*DRM(stub_list)) * DRM_STUB_MAXCARDS,
 			  DRM_MEM_STUB);
 		unregister_chrdev(DRM_MAJOR, "drm");
+		class_simple_device_remove(MKDEV(DRM_MAJOR, minor));
+		class_simple_destroy(drm_class);
 	}
 	return 0;
 }
@@ -170,10 +176,23 @@
 		       drm_device_t *dev)
 {
 	struct drm_stub_info *i = NULL;
+	int ret1;
+	int ret2;
 
 	DRM_DEBUG("\n");
-	if (register_chrdev(DRM_MAJOR, "drm", &DRM(stub_fops)))
+	ret1 = register_chrdev(DRM_MAJOR, "drm", &DRM(stub_fops));
+	if (!ret1) {
+		drm_class = class_simple_create(THIS_MODULE, "drm");
+		if (IS_ERR(drm_class)) {
+			printk (KERN_ERR "Error creating drm class.\n");
+			unregister_chrdev(DRM_MAJOR, "drm");
+			return PTR_ERR(drm_class);
+		}
+	}
+	else if (ret1 == -EBUSY)
 		i = (struct drm_stub_info *)inter_module_get("drm");
+	else
+		return -1;
 
 	if (i) {
 				/* Already registered */
@@ -186,8 +205,18 @@
 		DRM_DEBUG("calling inter_module_register\n");
 		inter_module_register("drm", THIS_MODULE, &DRM(stub_info));
 	}
-	if (DRM(stub_info).info_register)
-		return DRM(stub_info).info_register(name, fops, dev);
+	if (DRM(stub_info).info_register) {
+		ret2 = DRM(stub_info).info_register(name, fops, dev);
+		if (ret2) {
+			if (!ret1) {
+			unregister_chrdev(DRM_MAJOR, "drm");
+			class_simple_destroy(drm_class);
+			}
+			if (!i)
+				inter_module_unregister("drm");
+		}
+		return ret2;
+	}
 	return -1;
 }
 


  reply	other threads:[~2004-03-16  1:22 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-15 23:55 [BK PATCH] Driver Core update for 2.6.4 Greg KH
2004-03-15 23:59 ` [PATCH] " Greg KH
2004-03-15 23:59   ` Greg KH
2004-03-15 23:59     ` Greg KH
2004-03-15 23:59       ` Greg KH
2004-03-15 23:59         ` Greg KH
2004-03-15 23:59           ` Greg KH
2004-03-15 23:59             ` Greg KH
2004-03-15 23:59               ` Greg KH
2004-03-15 23:59                 ` Greg KH
2004-03-15 23:59                   ` Greg KH
2004-03-15 23:59                     ` Greg KH [this message]
2004-03-15 23:59                       ` Greg KH
2004-03-15 23:59                         ` Greg KH
2004-03-15 23:59                           ` Greg KH
2004-03-15 23:59                             ` Greg KH
2004-03-15 23:59                               ` Greg KH
2004-03-16  7:04                                 ` Christoph Hellwig
2004-03-16  9:51                                   ` Andrew Morton
     [not found] <1AajM-5vw-21@gated-at.bofh.it>
     [not found] ` <1Abpq-6Av-1@gated-at.bofh.it>
     [not found]   ` <1Aj3K-5Fn-9@gated-at.bofh.it>
     [not found]     ` <1AjwZ-65D-15@gated-at.bofh.it>
2004-03-16 16:14       ` Andi Kleen
2004-03-16 19:40         ` Greg KH
2004-03-17  0:01           ` Andi Kleen
2004-03-19  9:17         ` Jamie Lokier
2004-03-19 11:52           ` Giuseppe Bilotta

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=1079395148429@kroah.com \
    --to=greg@kroah.com \
    --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