devswdel Kernel Service

Purpose

Deletes a device driver entry from the device switch table.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include <sys/device.h>

int devswdel
(
devno)
dev_t devno;

Parameter

Item Description
devno Specifies the major and minor device numbers of the device to be deleted.

Description

The devswdel kernel service is typically called by a device driver's ddconfig routine on termination to remove the device driver's entry points from the device switch table.The device switch table is a table of device switch (devsw) structures indexed by the device driver's major device number. The device driver interface services use this table of structures in the kernel to facilitate calling device driver routines.

The major device number portion of the devno parameter is used to specify the index into the device switch table for the entry to be removed. Before the device switch structure is removed, the existing entry is checked to determine if any opened device is using it.

If an opened device is currently occupying the entry to be removed, the devswdel service does not perform the update. Instead, it returns an EEXIST return code. If the removal is successful, a return code of 0 is set.

The devswdel service removes a device switch structure entry from the table by marking the entry as undefined and setting all of the entry point fields within the structure to a nodev value. As a result, any callers of the removed device driver return an ENODEV error code. If the specified entry is already marked undefined, the devswdel service returns an ENODEV error code.

Execution Environment

The devswdel kernel service can be called from the process environment only.

Return Values

Item Description
0 Indicates a successful operation.
EEXIST Indicates that the specified device switch entry is in use and cannot be removed.
ENODEV Indicates that the specified device switch entry is not defined.
EINVAL Indicates that the major device number portion of the devno parameter exceeds the maximum permitted number of device switch entries.