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: Kay Sievers <kay.sievers@suse.de>, Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 4/22] [PATCH] Driver core: bus device event delay
Date: Wed, 21 Jun 2006 12:45:47 -0700	[thread overview]
Message-ID: <1150919175882-git-send-email-greg@kroah.com> (raw)
In-Reply-To: <11509191721672-git-send-email-greg@kroah.com>

From: Kay Sievers <kay.sievers@suse.de>

split bus_add_device() and send device uevents after sysfs population

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/base/base.h |    1 +
 drivers/base/bus.c  |   22 ++++++++++++++++++----
 drivers/base/core.c |    3 ++-
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/base/base.h b/drivers/base/base.h
index 5735b38..bbbc2ac 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -11,6 +11,7 @@ extern int cpu_dev_init(void);
 extern int attribute_container_init(void);
 
 extern int bus_add_device(struct device * dev);
+extern void bus_attach_device(struct device * dev);
 extern void bus_remove_device(struct device * dev);
 
 extern int bus_add_driver(struct device_driver *);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 76656ac..b27a606 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -362,8 +362,7 @@ static void device_remove_attrs(struct b
  *	@dev:	device being added
  *
  *	- Add the device to its bus's list of devices.
- *	- Try to attach to driver.
- *	- Create link to device's physical location.
+ *	- Create link to device's bus.
  */
 int bus_add_device(struct device * dev)
 {
@@ -372,8 +371,6 @@ int bus_add_device(struct device * dev)
 
 	if (bus) {
 		pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
-		device_attach(dev);
-		klist_add_tail(&dev->knode_bus, &bus->klist_devices);
 		error = device_add_attrs(bus, dev);
 		if (!error) {
 			sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
@@ -384,6 +381,22 @@ int bus_add_device(struct device * dev)
 }
 
 /**
+ *	bus_attach_device - add device to bus
+ *	@dev:	device tried to attach to a driver
+ *
+ *	- Try to attach to driver.
+ */
+void bus_attach_device(struct device * dev)
+{
+	struct bus_type * bus = dev->bus;
+
+	if (bus) {
+		device_attach(dev);
+		klist_add_tail(&dev->knode_bus, &bus->klist_devices);
+	}
+}
+
+/**
  *	bus_remove_device - remove device from bus
  *	@dev:	device to be removed
  *
@@ -733,6 +746,7 @@ EXPORT_SYMBOL_GPL(bus_find_device);
 EXPORT_SYMBOL_GPL(bus_for_each_drv);
 
 EXPORT_SYMBOL_GPL(bus_add_device);
+EXPORT_SYMBOL_GPL(bus_attach_device);
 EXPORT_SYMBOL_GPL(bus_remove_device);
 EXPORT_SYMBOL_GPL(bus_register);
 EXPORT_SYMBOL_GPL(bus_unregister);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6b355bd..d5e15a0 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -274,11 +274,12 @@ int device_add(struct device *dev)
 	dev->uevent_attr.store = store_uevent;
 	device_create_file(dev, &dev->uevent_attr);
 
-	kobject_uevent(&dev->kobj, KOBJ_ADD);
 	if ((error = device_pm_add(dev)))
 		goto PMError;
 	if ((error = bus_add_device(dev)))
 		goto BusError;
+	kobject_uevent(&dev->kobj, KOBJ_ADD);
+	bus_attach_device(dev);
 	if (parent)
 		klist_add_tail(&dev->knode_parent, &parent->klist_children);
 
-- 
1.4.0


  reply	other threads:[~2006-06-21 19:49 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-21 19:45 [GIT PATCH] Driver Core patches for 2.6.17 Greg KH
2006-06-21 19:45 ` [PATCH 1/22] [PATCH] kobject: make people pay attention to kobject_add errors Greg KH
2006-06-21 19:45   ` [PATCH 2/22] [PATCH] Add kernel<->userspace ABI stability documentation Greg KH
2006-06-21 19:45     ` [PATCH 3/22] [PATCH] CCISS: add device symlink to the block cciss block devices in sysfs Greg KH
2006-06-21 19:45       ` Greg KH [this message]
2006-06-21 19:45         ` [PATCH 5/22] [PATCH] TTY: return class device pointer from tty_register_device() Greg KH
2006-06-21 19:45           ` [PATCH 6/22] [PATCH] i4l gigaset: move sysfs entry to tty class device Greg KH
2006-06-21 19:45             ` [PATCH 7/22] [PATCH] Driver core: class_device_add needs error checks Greg KH
2006-06-21 19:45               ` [PATCH 8/22] [PATCH] Driver Core: CONFIG_DEBUG_PM covers drivers/base/power too Greg KH
2006-06-21 19:45                 ` [PATCH 9/22] [PATCH] platform_bus learns about modalias Greg KH
2006-06-21 19:45                   ` [PATCH 10/22] [PATCH] Driver Core: remove unused exports Greg KH
2006-06-21 19:45                     ` [PATCH 11/22] [PATCH] Driver Core: Allow sysdev_class have attributes Greg KH
2006-06-21 19:45                       ` [PATCH 12/22] [PATCH] Driver Core: Fix platform_device_add to use device_add Greg KH
2006-06-21 19:45                         ` [PATCH 13/22] [PATCH] Driver Core: Add /sys/hypervisor when needed Greg KH
2006-06-21 19:45                           ` [PATCH 14/22] [PATCH] remove duplication from Documentation/power/devices.txt Greg KH
2006-06-21 19:45                             ` [PATCH 15/22] [PATCH] Driver core: PM_DEBUG device suspend() messages become informative Greg KH
2006-06-21 19:45                               ` [PATCH 16/22] [PATCH] firmware_class: s/semaphores/mutexes Greg KH
2006-06-21 19:46                                 ` [PATCH 17/22] [PATCH] Driver core: change make_class_name() to take kobjects Greg KH
2006-06-21 19:46                                   ` [PATCH 18/22] [PATCH] Driver core: allow struct device to have a dev_t Greg KH
2006-06-21 19:46                                     ` [PATCH 19/22] [PATCH] Driver core: add generic "subsystem" link to all devices Greg KH
2006-06-21 19:46                                       ` [PATCH 20/22] [PATCH] Driver core: add proper symlinks for devices Greg KH
2006-06-21 19:46                                         ` [PATCH 21/22] [PATCH] Driver Core: Make dev_info and friends print the bus name if there is no driver Greg KH
2006-06-21 19:46                                           ` [PATCH 22/22] [PATCH] Driver model: add ISA bus Greg KH

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=1150919175882-git-send-email-greg@kroah.com \
    --to=greg@kroah.com \
    --cc=gregkh@suse.de \
    --cc=kay.sievers@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