Next: Device Close, Previous: Device Reply Server, Up: Device Interface
The function
device_open
opens the device name and returns a port to it in device. The open count for the device is incremented by one. If the open count was 0, the open handler for the device is invoked.master_port must hold the master device port. name specifies the device to open, and is a string up to 128 characters long. mode is the open mode. It is a bitwise-or of the following constants:
D_READ
- Request read access for the device.
D_WRITE
- Request write access for the device.
D_NODELAY
- Do not delay an open.
The function returns
D_SUCCESS
if the device was successfully opened,D_INVALID_OPERATION
if master_port is not the master device port,D_WOULD_BLOCK
is the device is busy andD_NOWAIT
was specified in mode,D_ALREADY_OPEN
if the device is already open in an incompatible mode andD_NO_SUCH_DEVICE
if name does not denote a know device.
This is the asynchronous form of the
device_open
function.device_open_request
performs the open request. The meaning for the parameters is as indevice_open
. Additionally, the caller has to supply a reply port to which theds_device_open_reply
message is sent by the kernel when the open has been performed. The return value of the open operation is stored in return_code.As neither function receives a reply message, only message transmission errors apply. If no error occurs,
KERN_SUCCESS
is returned.