linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: linux-hotplug@vger.kernel.org
Subject: udev: sleep_for_dev() bits
Date: Wed, 22 Oct 2003 04:13:45 +0000	[thread overview]
Message-ID: <marc-linux-hotplug-106679637510598@msgid-missing> (raw)

OK, I fixed that bug you hinted at earlier in my previous
sleep_for_dev() patch.  I am sure you fixed it, but here we go
nonetheless, just in case.

I actually changed it up a bit.  It is probably faster to count down
from SECONDS_TO_WAIT_FOR_DEV than count up.

I also made the lone 'path' argument const, since it can be.

Some other misc. bits, too.

Patch is against udev-004.

	Robert Love


 udev-add.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff -urN udev-004/udev-add.c udev/udev-add.c
--- udev-004/udev-add.c	2003-10-20 17:39:08.000000000 -0400
+++ udev/udev-add.c	2003-10-22 00:09:48.820010080 -0400
@@ -130,24 +130,23 @@
  * If it doesn't happen in about 10 seconds, give up.
  */
 #define SECONDS_TO_WAIT_FOR_DEV		10
-int sleep_for_dev(char *path)
+static int sleep_for_dev(const char *path)
 {
 	char filename[SYSFS_PATH_MAX + 6];
-	struct stat buf;
-	int loop = 0;
-	int retval = -ENODEV;
+	int loop = SECONDS_TO_WAIT_FOR_DEV;
+	int retval;
 
 	strcpy(filename, sysfs_path);
 	strcat(filename, path);
 	strcat(filename, "/dev");
 
-	while (loop < SECONDS_TO_WAIT_FOR_DEV) {
+	while (loop--) {
+		struct stat buf;
+
 		dbg("looking for %s", filename);
 		retval = stat(filename, &buf);
-		if (retval = 0) {
-			retval = 0;
+		if (!retval)
 			goto exit;
-		}
 
 		/* sleep for a second or two to give the kernel a chance to
 		 * create the dev file */





-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations
Here's your chance to show off your extensive product knowledge
We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

             reply	other threads:[~2003-10-22  4:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-22  4:13 Robert Love [this message]
2003-10-22 23:49 ` udev: sleep_for_dev() bits 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=marc-linux-hotplug-106679637510598@msgid-missing \
    --to=rml@tech9.net \
    --cc=linux-hotplug@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;
as well as URLs for NNTP newsgroup(s).