Device Driver Tutorial

Defining the Close Device Entry Point

The close(9E) routine returns type int. The close(9E) routine should return either DDI_SUCCESS or the appropriate error number.

The close(9E) routine takes four arguments. This dummy driver is so simple that this dummy_close() routine does not use any of the close(9E) arguments. The examples in Chapter 3, Reading and Writing Data in Kernel Memory show the close(9E) routine in more detail.

The close(9E) routine must undo everything that the open(9E) routine did. The close(9E) routine must deallocate anything that was allocated, close anything that was opened, and destroy anything that was created in the open(9E) routine. In this dummy driver, the open(9E) routine is so simple that nothing needs to be reclaimed or undone in the close(9E) routine.

The following code is the dummy_close() routine that you should enter into your dummy.c file. You can copy the name portion of this function definition directly from the declaration you entered in Declaring the User Context Entry Points. Write a message to the system log and return success.

static int
dummy_close(dev_t dev, int flag, int otyp, cred_t *cred)
    cmn_err(CE_NOTE, "Inside dummy_close");
    return DDI_SUCCESS;