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
Cc: gregkh@suse.de
Subject: [PATCH] USB: move usb core to use class_simple instead of it's own class functions.
Date: Wed, 9 Mar 2005 16:34:46 -0800	[thread overview]
Message-ID: <1110414886692@kroah.com> (raw)
In-Reply-To: <11104148851950@kroah.com>

ChangeSet 1.2051, 2005/03/09 12:17:18-08:00, gregkh@suse.de

[PATCH] USB: move usb core to use class_simple instead of it's own class functions.

This is needed if the class code is going to be made easier to use, and it makes the code
smaller and easier to understand.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


 drivers/usb/core/file.c |   55 ++++++++++++++++--------------------------------
 1 files changed, 19 insertions(+), 36 deletions(-)


diff -Nru a/drivers/usb/core/file.c b/drivers/usb/core/file.c
--- a/drivers/usb/core/file.c	2005-03-09 16:28:31 -08:00
+++ b/drivers/usb/core/file.c	2005-03-09 16:28:31 -08:00
@@ -66,16 +66,7 @@
 	.open =		usb_open,
 };
 
-static void release_usb_class_dev(struct class_device *class_dev)
-{
-	dbg("%s - %s", __FUNCTION__, class_dev->class_id);
-	kfree(class_dev);
-}
-
-static struct class usb_class = {
-	.name		= "usb",
-	.release	= &release_usb_class_dev,
-};
+static struct class_simple *usb_class;
 
 int usb_major_init(void)
 {
@@ -87,9 +78,9 @@
 		goto out;
 	}
 
-	error = class_register(&usb_class);
-	if (error) {
-		err("class_register failed for usb devices");
+	usb_class = class_simple_create(THIS_MODULE, "usb");
+	if (IS_ERR(usb_class)) {
+		err("class_simple_create failed for usb devices");
 		unregister_chrdev(USB_MAJOR, "usb");
 		goto out;
 	}
@@ -102,7 +93,7 @@
 
 void usb_major_cleanup(void)
 {
-	class_unregister(&usb_class);
+	class_simple_destroy(usb_class);
 	devfs_remove("usb");
 	unregister_chrdev(USB_MAJOR, "usb");
 }
@@ -134,7 +125,6 @@
 	int minor_base = class_driver->minor_base;
 	int minor = 0;
 	char name[BUS_ID_SIZE];
-	struct class_device *class_dev;
 	char *temp;
 
 #ifdef CONFIG_USB_DYNAMIC_MINORS
@@ -174,22 +164,18 @@
 	devfs_mk_cdev(MKDEV(USB_MAJOR, minor), class_driver->mode, name);
 
 	/* create a usb class device for this usb interface */
-	class_dev = kmalloc(sizeof(*class_dev), GFP_KERNEL);
-	if (class_dev) {
-		memset(class_dev, 0x00, sizeof(struct class_device));
-		class_dev->devt = MKDEV(USB_MAJOR, minor);
-		class_dev->class = &usb_class;
-		class_dev->dev = &intf->dev;
-
-		temp = strrchr(name, '/');
-		if (temp && (temp[1] != 0x00))
-			++temp;
-		else
-			temp = name;
-		snprintf(class_dev->class_id, BUS_ID_SIZE, "%s", temp);
-		class_set_devdata(class_dev, (void *)(long)intf->minor);
-		class_device_register(class_dev);
-		intf->class_dev = class_dev;
+	temp = strrchr(name, '/');
+	if (temp && (temp[1] != 0x00))
+		++temp;
+	else
+		temp = name;
+	intf->class_dev = class_simple_device_add(usb_class, MKDEV(USB_MAJOR, minor), &intf->dev, "%s", temp);
+	if (IS_ERR(intf->class_dev)) {
+		spin_lock (&minor_lock);
+		usb_minors[intf->minor] = NULL;
+		spin_unlock (&minor_lock);
+		devfs_remove (name);
+		retval = PTR_ERR(intf->class_dev);
 	}
 exit:
 	return retval;
@@ -232,11 +218,8 @@
 
 	snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base);
 	devfs_remove (name);
-
-	if (intf->class_dev) {
-		class_device_unregister(intf->class_dev);
-		intf->class_dev = NULL;
-	}
+	class_simple_device_remove(MKDEV(USB_MAJOR, intf->minor));
+	intf->class_dev = NULL;
 	intf->minor = -1;
 }
 EXPORT_SYMBOL(usb_deregister_dev);


  reply	other threads:[~2005-03-10  4:00 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-10  0:34 [BK PATCH] Driver core and kobject updates for 2.6.11 Greg KH
2005-03-10  0:34 ` [PATCH] Kobject: remove some unneeded exports Greg KH
2005-03-10  0:34   ` [PATCH] Add 2.4.x cpufreq /proc and sysctl interface removal feature-removal-schedule Greg KH
2005-03-10  0:34     ` [PATCH] cpufreq 2.4 interface removal schedule Greg KH
2005-03-10  0:34       ` [PATCH] driver core: Separate platform device name from platform device number Greg KH
2005-03-10  0:34         ` [PATCH] class core: export MAJOR/MINOR to the hotplug env Greg KH
2005-03-10  0:34           ` [PATCH] block " Greg KH
2005-03-10  0:34             ` [PATCH] class_simple: pass dev_t to the class core Greg KH
2005-03-10  0:34               ` [PATCH] usb: class driver " Greg KH
2005-03-10  0:34                 ` [PATCH] i2c: " Greg KH
2005-03-10  0:34                   ` [PATCH] videodev: " Greg KH
2005-03-10  0:34                     ` [PATCH] driver core: clean driver unload Greg KH
2005-03-10  0:34                       ` [PATCH] Driver core: add "bus" symlink to class/block devices Greg KH
2005-03-10  0:34                         ` [PATCH] floppy.c: pass physical device to device registration Greg KH
2005-03-10  0:34                           ` [PATCH] kset: make ksets have a spinlock, and use that to lock their lists Greg KH
2005-03-10  0:34                             ` [PATCH] sysdev: make system_subsys static as no one else needs access to it Greg KH
2005-03-10  0:34                               ` [PATCH] kref: make kref_put return if this was the last put call Greg KH
2005-03-10  0:34                                 ` Greg KH [this message]
2005-03-10  0:34                                   ` [PATCH] kmap: remove usage of rwsem from kobj_map Greg KH
2005-03-10  0:34                                     ` [PATCH] sysdev: fix the name of the list of drivers to be a sane name Greg KH
2005-03-10  0:34                                       ` [PATCH] sysdev: remove the rwsem usage from this subsystem Greg KH
2005-03-10  0:34                                         ` [PATCH] class: add a semaphore to struct class, and use that instead of the subsystem rwsem Greg KH
2005-03-25 18:01         ` [PATCH] driver core: Separate platform device name from platform device number Paul Mundt
2005-03-25 18:10           ` Greg KH
2005-03-25 18:35             ` Paul Mundt
2005-03-25 19:38               ` Kyle Moffett
2005-03-25 19:58                 ` Paul Mundt
2005-03-25 20:17                   ` Kyle Moffett
2005-03-25 20:25                   ` Russell King
2005-03-25 20:56                     ` Paul Mundt
2005-03-25 21:03                       ` Russell King
2005-03-25 22:15                         ` Paul Mundt
2005-03-10  2:23     ` [PATCH] Add 2.4.x cpufreq /proc and sysctl interface removal feature-removal-schedule Dave Jones
2005-03-10  4:56     ` Dominik Brodowski

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=1110414886692@kroah.com \
    --to=greg@kroah.com \
    --cc=gregkh@suse.de \
    --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