RTEMS Logo

RTEMS 4.9.2 On-Line Library


Console Driver Closing a Serial Device

PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

8.4.6: Closing a Serial Device

The console_close is invoked when the serial device is to be closed. This entry point corresponds to the device driver close entry point.

This routine is responsible for notifying Termios that the serial device was closed. This is done with a call to rtems_termios_close.

rtems_device_driver console_close(
    rtems_device_major_number major,
    rtems_device_minor_number minor,
    void *arg
)
{
    return rtems_termios_close(arg);
}

Termios will call the my_driver_last_close function if the last close happens on the device.

static int my_driver_last_close(int major, int minor, void *arg)
{
    my_driver_entry *e = &my_driver_table [minor];

    /*
     * There is no need to check the minor number since it is derived
     * from a file descriptor.  The upper layer takes care that it is
     * in a valid range.
     */

    /* Disconnect the TTY data structure */
    e->tty = NULL;

    /*
     * The driver may do some cleanup here.
     */

    return 0;
}


PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

Copyright © 1988-2008 OAR Corporation