bd: Adopted the sync function in the util block devices

pull/5926/head
Christopher Haster 2018-01-24 18:07:35 -06:00
parent 3f5d618c89
commit a4f8af9d5b
14 changed files with 84 additions and 0 deletions

View File

@ -84,6 +84,18 @@ int ChainingBlockDevice::deinit()
return 0;
}
int ChainingBlockDevice::sync()
{
for (size_t i = 0; i < _bd_count; i++) {
int err = _bds[i]->sync();
if (err) {
return err;
}
}
return 0;
}
int ChainingBlockDevice::read(void *b, bd_addr_t addr, bd_size_t size)
{
MBED_ASSERT(is_valid_read(addr, size));

View File

@ -85,6 +85,12 @@ public:
*/
virtual int deinit();
/** Ensure data on storage is in sync with the driver
*
* @return 0 on success or a negative error code on failure
*/
virtual int sync();
/** Read blocks from a block device
*
* @param buffer Buffer to write blocks to

View File

@ -53,6 +53,11 @@ int ExhaustibleBlockDevice::deinit()
return _bd->deinit();
}
int ExhaustibleBlockDevice::sync()
{
return _bd->sync();
}
int ExhaustibleBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
{
return _bd->read(buffer, addr, size);

View File

@ -70,6 +70,12 @@ public:
*/
virtual int deinit();
/** Ensure data on storage is in sync with the driver
*
* @return 0 on success or a negative error code on failure
*/
virtual int sync();
/** Read blocks from a block device
*
* @param buffer Buffer to read blocks into

View File

@ -234,6 +234,11 @@ int MBRBlockDevice::deinit()
return _bd->deinit();
}
int MBRBlockDevice::sync()
{
return _bd->sync();
}
int MBRBlockDevice::read(void *b, bd_addr_t addr, bd_size_t size)
{
MBED_ASSERT(is_valid_read(addr, size));

View File

@ -139,6 +139,12 @@ public:
*/
virtual int deinit();
/** Ensure data on storage is in sync with the driver
*
* @return 0 on success or a negative error code on failure
*/
virtual int sync();
/** Read blocks from a block device
*
* @param buffer Buffer to read blocks into

View File

@ -51,6 +51,11 @@ int ObservingBlockDevice::deinit()
return _bd->deinit();
}
int ObservingBlockDevice::sync()
{
return _bd->sync();
}
int ObservingBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
{
return _bd->read(buffer, addr, size);

View File

@ -56,6 +56,12 @@ public:
*/
virtual int deinit();
/** Ensure data on storage is in sync with the driver
*
* @return 0 on success or a negative error code on failure
*/
virtual int sync();
/** Read blocks from a block device
*
* @param buffer Buffer to read blocks into

View File

@ -35,6 +35,11 @@ int ProfilingBlockDevice::deinit()
return _bd->deinit();
}
int ProfilingBlockDevice::sync()
{
return _bd->sync();
}
int ProfilingBlockDevice::read(void *b, bd_addr_t addr, bd_size_t size)
{
int err = _bd->read(b, addr, size);

View File

@ -71,6 +71,12 @@ public:
*/
virtual int deinit();
/** Ensure data on storage is in sync with the driver
*
* @return 0 on success or a negative error code on failure
*/
virtual int sync();
/** Read blocks from a block device
*
* @param buffer Buffer to read blocks into

View File

@ -45,6 +45,11 @@ int ReadOnlyBlockDevice::deinit()
return _bd->deinit();
}
int ReadOnlyBlockDevice::sync()
{
return _bd->sync();
}
int ReadOnlyBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
{
return _bd->read(buffer, addr, size);

View File

@ -49,6 +49,12 @@ public:
*/
virtual int deinit();
/** Ensure data on storage is in sync with the driver
*
* @return 0 on success or a negative error code on failure
*/
virtual int sync();
/** Read blocks from a block device
*
* @param buffer Buffer to read blocks into

View File

@ -64,6 +64,11 @@ int SlicingBlockDevice::deinit()
return _bd->deinit();
}
int SlicingBlockDevice::sync()
{
return _bd->sync();
}
int SlicingBlockDevice::read(void *b, bd_addr_t addr, bd_size_t size)
{
MBED_ASSERT(is_valid_read(addr, size));

View File

@ -77,6 +77,12 @@ public:
*/
virtual int deinit();
/** Ensure data on storage is in sync with the driver
*
* @return 0 on success or a negative error code on failure
*/
virtual int sync();
/** Read blocks from a block device
*
* @param buffer Buffer to read blocks into