how to free up allocated clists ?

Paul Barton-Davis pauld at cs.washington.edu
Wed Jun 19 10:19:50 AEST 1991


Here's an easy one for someone. I presumed a need to free up any
allocated clist cblocks that have been allocated by my device driver
when I finally close the device. It wasn't clear to me how to do this
from the descriptions of the various put/get clblock options, but
here's what I came up with (the entire close entry point is included):

pc21close (dev, flag)

dev_t dev;
int flag;

{
    register int unit;
    register int i;
    struct cblock *free_block;
    int x;

    if ((unit = minor (dev)) >= pc21_max)
    {
	u.u_error = ENODEV;
	return;
    }

    /* mark the board as available
     */

    pc21_params[unit].status &= ~PC21_BUSY;

    /* remove cblocks from output clist
     */

X    x = splcli();
X    while ((free_block = getcb (&(pc21_params[unit].output))) !=
X	   (struct cblock *) NULL)
X	putcf (free_block);
X    splx (x);

    u.u_error = 0;
    return;
}
 
Can someone tell me if the lines marked with an "X" do what I want
them to: get each allocated cblock and return it too the free list ?
Is there a better way to do this, or can I even forget about it
completely ?

Thanks for any advice - I'm hoping this isn't the source of a problem
we're having on a machine running this driver.
-- 
Paul Barton-Davis                                 <pauld at cs.washington.edu>

Man has survived because he did not know how to realize his wishes.
Now that he can realize them, he must either change them, or perish.



More information about the Comp.unix.internals mailing list