+ driver-core-dont-fail-attaching-the-device-if-it.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     driver core: Don't fail attaching the device if it cannot be bound
has been added to the -mm tree.  Its filename is
     driver-core-dont-fail-attaching-the-device-if-it.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: driver core: Don't fail attaching the device if it cannot be bound
From: Cornelia Huck <cornelia.huck@xxxxxxxxxx>

Don't fail bus_attach_device() if the device cannot be bound.

If dev->driver has been specified, reset it to NULL if device_bind_driver()
failed and add the device as an unbound device.  As a result,
bus_attach_device() now cannot fail, and we can remove some checking from
device_add().

Also remove an unneeded check in bus_rescan_devices_helper().

Signed-off-by: Cornelia Huck <cornelia.huck@xxxxxxxxxx>
Cc: Greg KH <greg@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 drivers/base/base.h |    2 +-
 drivers/base/bus.c  |   13 +++++--------
 drivers/base/core.c |    5 +----
 drivers/base/dd.c   |    6 +++++-
 4 files changed, 12 insertions(+), 14 deletions(-)

diff -puN drivers/base/base.h~driver-core-dont-fail-attaching-the-device-if-it drivers/base/base.h
--- a/drivers/base/base.h~driver-core-dont-fail-attaching-the-device-if-it
+++ a/drivers/base/base.h
@@ -16,7 +16,7 @@ extern int cpu_dev_init(void);
 extern int attribute_container_init(void);
 
 extern int bus_add_device(struct device * dev);
-extern int bus_attach_device(struct device * dev);
+extern void bus_attach_device(struct device * dev);
 extern void bus_remove_device(struct device * dev);
 extern struct bus_type *get_bus(struct bus_type * bus);
 extern void put_bus(struct bus_type * bus);
diff -puN drivers/base/bus.c~driver-core-dont-fail-attaching-the-device-if-it drivers/base/bus.c
--- a/drivers/base/bus.c~driver-core-dont-fail-attaching-the-device-if-it
+++ a/drivers/base/bus.c
@@ -420,21 +420,20 @@ out_put:
  *	- Add device to bus's list of devices.
  *	- Try to attach to driver.
  */
-int bus_attach_device(struct device * dev)
+void bus_attach_device(struct device * dev)
 {
 	struct bus_type *bus = dev->bus;
-	int ret = 0;
+	int ret;
 
 	if (bus) {
 		dev->is_registered = 1;
 		ret = device_attach(dev);
-		if (ret >= 0) {
+		WARN_ON(ret < 0);
+		if (ret >= 0)
 			klist_add_tail(&dev->knode_bus, &bus->klist_devices);
-			ret = 0;
-		} else
+		else
 			dev->is_registered = 0;
 	}
-	return ret;
 }
 
 /**
@@ -607,8 +606,6 @@ static int __must_check bus_rescan_devic
 		ret = device_attach(dev);
 		if (dev->parent)
 			up(&dev->parent->sem);
-		if (ret > 0)
-			ret = 0;
 	}
 	return ret < 0 ? ret : 0;
 }
diff -puN drivers/base/core.c~driver-core-dont-fail-attaching-the-device-if-it drivers/base/core.c
--- a/drivers/base/core.c~driver-core-dont-fail-attaching-the-device-if-it
+++ a/drivers/base/core.c
@@ -585,8 +585,7 @@ int device_add(struct device *dev)
 	if ((error = bus_add_device(dev)))
 		goto BusError;
 	kobject_uevent(&dev->kobj, KOBJ_ADD);
-	if ((error = bus_attach_device(dev)))
-		goto AttachError;
+	bus_attach_device(dev);
 	if (parent)
 		klist_add_tail(&dev->knode_parent, &parent->klist_children);
 
@@ -604,8 +603,6 @@ int device_add(struct device *dev)
  Done:
 	put_device(dev);
 	return error;
- AttachError:
-	bus_remove_device(dev);
  BusError:
 	device_pm_remove(dev);
  PMError:
diff -puN drivers/base/dd.c~driver-core-dont-fail-attaching-the-device-if-it drivers/base/dd.c
--- a/drivers/base/dd.c~driver-core-dont-fail-attaching-the-device-if-it
+++ a/drivers/base/dd.c
@@ -226,7 +226,7 @@ static int device_probe_drivers(void *da
  *
  *	Returns 1 if the device was bound to a driver;
  *	0 if no matching device was found or multithreaded probing is done;
- *	error code otherwise.
+ *	-ENODEV if the device is not registered.
  *
  *	When called for a USB interface, @dev->parent->sem must be held.
  */
@@ -240,6 +240,10 @@ int device_attach(struct device * dev)
 		ret = device_bind_driver(dev);
 		if (ret == 0)
 			ret = 1;
+		else {
+			dev->driver = NULL;
+			ret = 0;
+		}
 	} else {
 		if (dev->bus->multithread_probe)
 			probe_task = kthread_run(device_probe_drivers, dev,
_

Patches currently in -mm which might be from cornelia.huck@xxxxxxxxxx are

driver-core-fixes-make_class_name-retval-checks.patch
driver-core-fixes-sysfs_create_link-retval-checks-in.patch
driver-core-fixes-device_register-retval-check-in.patch
driver-core-dont-stop-probing-on-probe-errors.patch
driver-core-change-function-call-order-in.patch
driver-core-per-subsystem-multithreaded-probing.patch
driver-core-dont-fail-attaching-the-device-if-it.patch
cpu-topology-consider-sysfs_create_group-return-value.patch
git-s390.patch
tty-switch-to-ktermios-sclp-fix.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux