summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrml@tech9.net <rml@tech9.net>2003-10-23 00:50:27 -0700
committerGreg KH <gregkh@suse.de>2005-04-26 21:06:22 -0700
commitc332cfc72da865f3c9f5e34867fc3ac1b0bf0154 (patch)
tree363bc53f80d5c2f90bc3f62f8fc4510a6141650a
parenta34ea8f598af378dcd63528b6328d1bff7fab0f1 (diff)
[PATCH] udev: sleep_for_dev() bits
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.
-rw-r--r--udev-add.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/udev-add.c b/udev-add.c
index 7a89076add..d237834c68 100644
--- a/udev-add.c
+++ b/udev-add.c
@@ -139,26 +139,24 @@ exit:
static int sleep_for_dev(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 */
sleep(1);
- ++loop;
}
retval = -ENODEV;
exit: