mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #5926 from geky/bd-sync
bd: Add sync function to the block device APIpull/5977/head
commit
101fc62495
|
@ -59,6 +59,15 @@ public:
|
|||
*/
|
||||
virtual int deinit() = 0;
|
||||
|
||||
/** Ensure data on storage is in sync with the driver
|
||||
*
|
||||
* @return 0 on success or a negative error code on failure
|
||||
*/
|
||||
virtual int sync()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Read blocks from a block device
|
||||
*
|
||||
* If a failure occurs, it is not possible to determine how many bytes succeeded
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -102,7 +102,8 @@ static int lfs_bd_erase(const struct lfs_config *c, lfs_block_t block)
|
|||
|
||||
static int lfs_bd_sync(const struct lfs_config *c)
|
||||
{
|
||||
return 0;
|
||||
BlockDevice *bd = (BlockDevice *)c->context;
|
||||
return bd->sync();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue