Previous Next Table of Contents

6. lp_release(struct inode * inode, struct file * file)

6.1 General info.

Function: lp_release releases a parallel device.

Called from: release (Base driver operation).

Files: drivers/char/lp.c, include/linux/lp.h

6.2 Code description

This is a fairly simple function. Again, the arguments are just inode and file (same as for open). First, it grabs the minor device number, then frees the memory that was assigned for the buffer (and sets the buffer flag to null). Then it marks the device as no longer busy, and exists.

static int lp_release(struct inode * inode, struct file * file)
{
        unsigned int minor = MINOR(inode->i_rdev);

        kfree_s(lp_table[minor].lp_buffer, LP_BUFFER_SIZE);
        lp_table[minor].lp_buffer = NULL;
        LP_F(minor) &= ~LP_BUSY;
        MOD_DEC_USE_COUNT;
        return 0;
}


Previous Next Table of Contents