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: Ryan Wilson <hap9@epoch.ncsc.mil>, Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 5/7] driver core: driver_bind attribute returns incorrect value
Date: Fri, 14 Apr 2006 13:09:56 -0700	[thread overview]
Message-ID: <11450453961276-git-send-email-greg@kroah.com> (raw)
In-Reply-To: <11450453961756-git-send-email-greg@kroah.com>

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 files changed, 5 insertions(+), 0 deletions(-)

372254018eb1b65ee69210d11686bfc65c8d84db
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 48718b7..76656ac 100644
--- a/drivers/base/bus.c
+++ b/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);
-- 
1.2.6



  reply	other threads:[~2006-04-14 20:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-14 20:00 [GIT PATCH] Driver Core and sysfs patches for 2.6.17-rc1 Greg KH
2006-04-14 20:09 ` [PATCH 1/7] sysfs: Allow sysfs attribute files to be pollable Greg KH
2006-04-14 20:09   ` [PATCH 2/7] driver core: safely unbind drivers for devices not on a bus Greg KH
2006-04-14 20:09     ` [PATCH 3/7] BLOCK: delay all uevents until partition table is scanned Greg KH
2006-04-14 20:09       ` [PATCH 4/7] driver core: fix unnecessary NULL check in drivers/base/class.c Greg KH
2006-04-14 20:09         ` Greg KH [this message]
2006-04-14 20:09           ` [PATCH 6/7] pm: print name of failed suspend function Greg KH
2006-04-14 20:09             ` [PATCH 7/7] DMI: move dmi_scan.c from arch/i386 to drivers/firmware/ 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=11450453961276-git-send-email-greg@kroah.com \
    --to=greg@kroah.com \
    --cc=gregkh@suse.de \
    --cc=hap9@epoch.ncsc.mil \
    --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