Open() - Device Driver

static  void  FSDev_####_Open (FS_DEV  *p_dev,
                               void    *p_dev_cfg,
                               FS_ERR  *p_err);

File

Called from

Code enabled by

fs_dev_####.c

FSDev_Open()

N/A

The device driver Open() function should initialize the hardware to access a device and attempt to initialize that device. If this function is successful (i.e., it returns FS_ERR_NONE), then the file system suite expects the device to be ready for read and write accesses.

Arguments

p_dev

Pointer to device to open.

p_dev_cfg

Pointer to device configuration.

p_err

Pointer to variable that will receive the return error code from this function:

FS_ERR_NONE

Device opened successfully.

FS_ERR_DEV_ALREADY_OPEN

Device unit is already opened.

FS_ERR_DEV_INVALID_CFG

Device configuration specified invalid.

FS_ERR_DEV_INVALID_LOW_FMT

Device needs to be low-level formatted.

FS_ERR_DEV_INVALID_LOW_PARAMS

Device low-level device parameters invalid.

FS_ERR_DEV_INVALID_UNIT_NBR

Device unit number is invalid.

FS_ERR_DEV_IO

Device I/O error.

FS_ERR_DEV_NOT_PRESENT

Device unit is not present.

FS_ERR_DEV_TIMEOUT

Device timeout.

FS_ERR_MEM_ALLOC

Memory could not be allocated.

Returned Value

None.

Notes/Warnings

  1. Tracking whether a device is open is not necessary, because this should NEVER be called when a device is already open.
  2. Some drivers may need to track whether a device has been previously opened (indicating that the hardware has previously been initialized).
  3. This will be called every time the device is opened.
  4. The driver should identify the device instance to be opened by checking p_dev->UnitNbr. For example, if “template:2:” is to be opened, then p_dev->UnitNbr will hold the integer 2.
  5. The device driver Open() function is called while the caller holds the device lock.