# MI_ReadDevice

## Syntax

  `#include <nitro/mi.h>
  int MI_ReadDevice(MIDevice *device, void *buffer, u32 offset, u32 length);`

## Arguments

device | Pointer to the `MIDevice` structure to access. The device must have been initialized using `MI_InitDevice()`.
buffer | The destination memory to store the loaded data.
offset | The start address of the device to which data should be read.
length | Data size to load.

## Return Values

If the function succeeds, it will return the actual amount of data that has been read. If it fails, it will return a negative value.

## Description

Reads data from a device using the `MIDevice` structure.
Internally, this just calls the callback function for reads specified in `MI_InitDevice()`.

This is a utility feature designed to separate the device control component from the module design. For more information, see the reference for the `MIDevice` structure.

## See Also

`MI_InitDevice, MI_WriteDevice
MIDevice, MIDeviceReadFunction, MIDeviceWriteFunction
`

## Revision History

2007/05/09 Initial version.

CONFIDENTIAL