Re: Porting Microsoft C to Linux

Alan Cox (alan@lxorguk.ukuu.org.uk)
Wed, 23 Sep 1998 13:01:54 +0100 (BST)


> timeout = jiffies;
> timeout += 5 * HZ;
> while (jiffies <= timeout);
>
> Sound about right?

You just crashed if the machine is SMP. Do not sit in
loops polling ;)

You want a more polite wait.

current->timeout = jiffies + 5*HZ;
current->state = TASK_INTERRUPTIBLE;
schedule();
if(signal_pending(current))
{
/* Ouch someone hit ^C while we were busy */
}

If you are loading the driver as a module this will also do the right
things and let other tasks continue to run happily.

> Also, this program downloads a control program to the card. The
> original code uses fgets and family. I know these do not work in
> modules, well at least I can't get them to work, what do I need to
> replace them with. I think I remember reading about this in Linux
> Device Drivers, but I can't find those details now...

Download the firmware from a user program. Its not needed in a device itself
unless you boot off it. Just provide an ioctl() to pass the firmware -
ie the loader program does fopen/fgets etc then does ioctl(fd, BLAHIOCFIRMWARE, &buf)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/