summaryrefslogtreecommitdiff
path: root/nuttx/drivers/bch
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/drivers/bch')
-rw-r--r--nuttx/drivers/bch/bchlib_read.c7
-rw-r--r--nuttx/drivers/bch/bchlib_write.c20
2 files changed, 21 insertions, 6 deletions
diff --git a/nuttx/drivers/bch/bchlib_read.c b/nuttx/drivers/bch/bchlib_read.c
index 7319e3412..e146f02f8 100644
--- a/nuttx/drivers/bch/bchlib_read.c
+++ b/nuttx/drivers/bch/bchlib_read.c
@@ -145,7 +145,9 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, size_t le
len -= nbytes;
}
- /* Then read all of the full sectors following the partial sector */
+ /* Then read all of the full sectors following the partial sector directly
+ * into the user buffer.
+ */
if (len >= bch->sectsize )
{
@@ -155,7 +157,8 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, size_t le
nsectors = bch->nsectors - sector;
}
- ret = bch->inode->u.i_bops->read(bch->inode, bch->buffer, sector, nsectors);
+ ret = bch->inode->u.i_bops->read(bch->inode, (FAR uint8_t *)buffer,
+ sector, nsectors);
if (ret < 0)
{
fdbg("Read failed: %d\n");
diff --git a/nuttx/drivers/bch/bchlib_write.c b/nuttx/drivers/bch/bchlib_write.c
index 0f362ef8d..956f1619f 100644
--- a/nuttx/drivers/bch/bchlib_write.c
+++ b/nuttx/drivers/bch/bchlib_write.c
@@ -1,7 +1,7 @@
/****************************************************************************
* drivers/bch/bchlib_write.c
*
- * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -145,7 +145,9 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, si
len -= nbytes;
}
- /* Then write all of the full sectors following the partial sector */
+ /* Then write all of the full sectors following the partial sector
+ * directly from the user buffer.
+ */
if (len >= bch->sectsize )
{
@@ -157,10 +159,11 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, si
/* Write the contiguous sectors */
- ret = bch->inode->u.i_bops->write(bch->inode, bch->buffer, sector, nsectors);
+ ret = bch->inode->u.i_bops->write(bch->inode, (FAR uint8_t *)buffer,
+ sector, nsectors);
if (ret < 0)
{
- fdbg("Write failed: %d\n");
+ fdbg("Write failed: %d\n", ret);
return ret;
}
@@ -199,6 +202,15 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, si
byteswritten += len;
}
+ /* Finally, flush any cached writes to the device as well */
+
+ ret = bchlib_flushsector(bch);
+ if (ret < 0)
+ {
+ fdbg("Flush failed: %d\n", ret);
+ return ret;
+ }
+
return byteswritten;
}