summaryrefslogtreecommitdiff
path: root/nuttx/drivers
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-02-01 08:20:30 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-02-01 08:20:30 -0600
commitcbeb0d860dfd5bc0195f20f716325fa79c0521b7 (patch)
tree253503a0c98279905833c8ad526a09d6884adab6 /nuttx/drivers
parent9096cffc4582f100c0b2d1a72450617bc2fc327f (diff)
downloadpx4-nuttx-cbeb0d860dfd5bc0195f20f716325fa79c0521b7.tar.gz
px4-nuttx-cbeb0d860dfd5bc0195f20f716325fa79c0521b7.tar.bz2
px4-nuttx-cbeb0d860dfd5bc0195f20f716325fa79c0521b7.zip
RAM disk: Missed a few changes in the last commit
Diffstat (limited to 'nuttx/drivers')
-rw-r--r--nuttx/drivers/ramdisk.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/nuttx/drivers/ramdisk.c b/nuttx/drivers/ramdisk.c
index 4c9a1405d..2ccecc7c9 100644
--- a/nuttx/drivers/ramdisk.c
+++ b/nuttx/drivers/ramdisk.c
@@ -142,13 +142,22 @@ static const struct block_operations g_bops =
static void rd_destroy(FAR struct rd_struct_s *dev)
{
- /* And free the dev structure.
- * REVISIT: This is not very helpful. What we really need to know
- * is if we can free the RAM disk memory; that is the major resource
- * consumed by this driver. But we do not know if we can or should.
- */
+ fvdbg("Destroying RAM disk\n");
- kmm_free(dev);
+ /* We we configured to free the RAM disk memory when unlinked? */
+
+#ifdef CONFIG_FS_WRITABLE
+ if (RDFLAG_IS_UNLINKED(dev->rd_flags))
+ {
+ /* Yes.. do it */
+
+ kmm_free(dev->rd_buffer);
+ }
+#endif
+
+ /* And free the block driver itself */
+
+ kmm_free(dev);
}
/****************************************************************************