aboutsummaryrefslogtreecommitdiffstats
path: root/driver
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2006-04-04 12:10:10 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2006-04-04 12:10:10 -0700
commit1f3175a66a04109fb39a5c9d3febcf4aeeec1e82 (patch)
treeeff9b0cc2e493690e505918803f34b691342c6c0 /driver
parent89db993763d7241db3f0b8760c71dcb0cf6e5d91 (diff)
downloadpatches-1f3175a66a04109fb39a5c9d3febcf4aeeec1e82.tar.gz
usb and driver core patches added
Diffstat (limited to 'driver')
-rw-r--r--driver/bus_add_device-losing-an-error-return-from-the-probe-method.patch74
-rw-r--r--driver/driver-core-driver_bind-attribute-returns-incorrect-value.patch45
-rw-r--r--driver/driver-core-fix-unnecessary-null-check-in-drivers-base-class.c.patch46
3 files changed, 165 insertions, 0 deletions
diff --git a/driver/bus_add_device-losing-an-error-return-from-the-probe-method.patch b/driver/bus_add_device-losing-an-error-return-from-the-probe-method.patch
new file mode 100644
index 0000000000000..c3e5e86206034
--- /dev/null
+++ b/driver/bus_add_device-losing-an-error-return-from-the-probe-method.patch
@@ -0,0 +1,74 @@
+From rene.herman@keyaccess.nl Thu Mar 23 21:32:00 2006
+Message-ID: <44238489.8090402@keyaccess.nl>
+Date: Fri, 24 Mar 2006 06:32:57 +0100
+From: Rene Herman <rene.herman@keyaccess.nl>
+To: Greg Kroah-Hartman <gregkh@suse.de>
+Cc: Takashi Iwai <tiwai@suse.de>, ALSA devel <alsa-devel@alsa-project.org>, Linux Kernel <linux-kernel@vger.kernel.org>
+Subject: bus_add_device() losing an error return from the probe() method
+
+ALSA moved all ISA drivers over to the platform_driver interface in
+2.6.16, using this code structure in the module_inits:
+
+ cards = 0;
+ for (i = 0; i < SNDRV_CARDS; i++) {
+ struct platform_device *device;
+ device = platform_device_register_simple(
+ SND_FOO_DRIVER, i, NULL, 0);
+ if (IS_ERR(device)) {
+ err = PTR_ERR(device);
+ goto errout;
+ }
+ devices[i] = device;
+ cards++;
+ }
+ if (!cards) {
+ printk(KERN_ERR "FOO soundcard not found or device busy\n");
+ err = -ENODEV;
+ goto errout;
+ }
+ return 0;
+errout:
+ snd_foo_unregister_all();
+ return err;
+
+Unfortunately, the snd_foo_unregister_all() part here is unreachable
+under normal circumstances, since platform_device_register_simple()
+returns !IS_ERR, regardless of what the driver probe method returned.
+The driver then never fails to load, even when no cards were found.
+
+An error return from the driver probe() method is carried up through
+device_attach, but is then dropped on the floor in bus_add_device(). If
+I apply the attached patch, things work as I (and ALSA it seems) expect.
+
+From: Rene Herman <rene.herman@keyaccess.nl>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/base/bus.c | 13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+--- gregkh-2.6.orig/drivers/base/bus.c
++++ gregkh-2.6/drivers/base/bus.c
+@@ -372,14 +372,17 @@ 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);
++ error = device_attach(dev);
++ if (error < 0)
++ goto exit;
+ 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);
+- sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus");
+- }
++ if (error)
++ goto exit;
++ sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
++ sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus");
+ }
++exit:
+ return error;
+ }
+
diff --git a/driver/driver-core-driver_bind-attribute-returns-incorrect-value.patch b/driver/driver-core-driver_bind-attribute-returns-incorrect-value.patch
new file mode 100644
index 0000000000000..768c6b9505b0c
--- /dev/null
+++ b/driver/driver-core-driver_bind-attribute-returns-incorrect-value.patch
@@ -0,0 +1,45 @@
+From hap9@epoch.ncsc.mil Wed Mar 22 13:26:14 2006
+From: Ryan Wilson <hap9@epoch.ncsc.mil>
+Subject: driver core: driver_bind attribute returns incorrect value
+To: gregkh@suse.de
+Cc: linux-kernel@vger.kernel.org
+Date: Wed, 22 Mar 2006 16:26:25 -0500
+Message-Id: <1143062785.22254.15.camel@moss-tarheels.epoch.ncsc.mil>
+
+The manual driver <-> device binding attribute in sysfs doesn't return
+the correct value on failure or success of driver_probe_device.
+driver_probe_device returns 1 on success (the driver accepted the
+device) or 0 on probe failure (when the driver didn't accept the
+device but no real error occured). However, the attribute can't just
+return 0 or 1, it must return the number of bytes consumed from buf
+or an error value. Returning 0 indicates to userspace that nothing
+was written (even though the kernel has tried to do the bind/probe and
+failed). Returning 1 indicates that only one character was accepted in
+which case userspace will re-try the write with a partial string.
+
+A more correct version of driver_bind would return count (to indicate
+the entire string was consumed) when driver_probe_device returns 1
+and -ENODEV when driver_probe_device returns 0. This patch makes that
+change.
+
+Signed-off-by: Ryan Wilson <hap9@epoch.ncsc.mil>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/base/bus.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- gregkh-2.6.orig/drivers/base/bus.c
++++ gregkh-2.6/drivers/base/bus.c
+@@ -188,6 +188,11 @@ static ssize_t driver_bind(struct device
+ up(&dev->sem);
+ if (dev->parent)
+ up(&dev->parent->sem);
++
++ if (err > 0) /* success */
++ err = count;
++ else if (err == 0) /* driver didn't accept device */
++ err = -ENODEV;
+ }
+ put_device(dev);
+ put_bus(bus);
diff --git a/driver/driver-core-fix-unnecessary-null-check-in-drivers-base-class.c.patch b/driver/driver-core-fix-unnecessary-null-check-in-drivers-base-class.c.patch
new file mode 100644
index 0000000000000..9ddc54fbd05c3
--- /dev/null
+++ b/driver/driver-core-fix-unnecessary-null-check-in-drivers-base-class.c.patch
@@ -0,0 +1,46 @@
+From Jayachandran.Nair@digeo.com Mon Apr 3 12:32:20 2006
+From: "Jayachandran C" <jchandra@digeo.com>
+Date: Mon, 3 Apr 2006 12:31:53 -0700
+To: gregkh@suse.de
+Cc: <akpm@osdl.org>
+Subject: driver core: fix unnecessary NULL check in drivers/base/class.c
+Message-ID: <20060403193153.GB10314@random.pao.digeo.com>
+Content-Disposition: inline
+
+This patch tries to fix an issue in drivers/base/class.c, please
+review and apply if correct.
+
+Patch Description:
+ "parent_class" is checked for NULL already, so removed the unnecessary
+ check.
+
+Signed-off-by: Jayachandran C. <c.jayachandran@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/base/class.c | 13 ++++++-------
+ 1 file changed, 6 insertions(+), 7 deletions(-)
+
+--- gregkh-2.6.orig/drivers/base/class.c
++++ gregkh-2.6/drivers/base/class.c
+@@ -562,14 +562,13 @@ int class_device_add(struct class_device
+ kobject_uevent(&class_dev->kobj, KOBJ_ADD);
+
+ /* notify any interfaces this device is now here */
+- if (parent_class) {
+- down(&parent_class->sem);
+- list_add_tail(&class_dev->node, &parent_class->children);
+- list_for_each_entry(class_intf, &parent_class->interfaces, node)
+- if (class_intf->add)
+- class_intf->add(class_dev, class_intf);
+- up(&parent_class->sem);
++ down(&parent_class->sem);
++ list_add_tail(&class_dev->node, &parent_class->children);
++ list_for_each_entry(class_intf, &parent_class->interfaces, node) {
++ if (class_intf->add)
++ class_intf->add(class_dev, class_intf);
+ }
++ up(&parent_class->sem);
+
+ register_done:
+ if (error) {