summaryrefslogtreecommitdiff
path: root/nuttx/drivers/mtd
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/drivers/mtd')
-rw-r--r--nuttx/drivers/mtd/at45db.c7
-rwxr-xr-xnuttx/drivers/mtd/ftl.c13
-rw-r--r--nuttx/drivers/mtd/m25px.c7
-rwxr-xr-xnuttx/drivers/mtd/ramtron.c5
4 files changed, 18 insertions, 14 deletions
diff --git a/nuttx/drivers/mtd/at45db.c b/nuttx/drivers/mtd/at45db.c
index 201fee0d6..6ca2b12bc 100644
--- a/nuttx/drivers/mtd/at45db.c
+++ b/nuttx/drivers/mtd/at45db.c
@@ -2,7 +2,7 @@
* drivers/mtd/at45db.c
* Driver for SPI-based AT45DB161D (16Mbit)
*
- * Copyright (C) 2010 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -59,6 +59,7 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/arch.h>
#include <nuttx/ioctl.h>
#include <nuttx/spi.h>
@@ -826,7 +827,7 @@ FAR struct mtd_dev_s *at45db_initialize(FAR struct spi_dev_s *spi)
* to be extended to handle multiple FLASH parts on the same SPI bus.
*/
- priv = (FAR struct at45db_dev_s *)malloc(sizeof(struct at45db_dev_s));
+ priv = (FAR struct at45db_dev_s *)kmalloc(sizeof(struct at45db_dev_s));
if (priv)
{
/* Initialize the allocated structure */
@@ -893,6 +894,6 @@ FAR struct mtd_dev_s *at45db_initialize(FAR struct spi_dev_s *spi)
errout:
at45db_unlock(priv);
- free(priv);
+ kfree(priv);
return NULL;
}
diff --git a/nuttx/drivers/mtd/ftl.c b/nuttx/drivers/mtd/ftl.c
index 40f208f56..2aaff1b37 100755
--- a/nuttx/drivers/mtd/ftl.c
+++ b/nuttx/drivers/mtd/ftl.c
@@ -49,6 +49,7 @@
#include <debug.h>
#include <errno.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/fs.h>
#include <nuttx/ioctl.h>
#include <nuttx/mtd.h>
@@ -468,7 +469,7 @@ int ftl_initialize(int minor, uint8_t *buffer, FAR struct mtd_dev_s *mtd)
/* Allocate a ramdisk device structure */
- dev = (struct ftl_struct_s *)malloc(sizeof(struct ftl_struct_s));
+ dev = (struct ftl_struct_s *)kmalloc(sizeof(struct ftl_struct_s));
if (dev)
{
/* Initialize the ramdisk device structure */
@@ -484,18 +485,18 @@ int ftl_initialize(int minor, uint8_t *buffer, FAR struct mtd_dev_s *mtd)
if (ret < 0)
{
fdbg("MTD ioctl(MTDIOC_GEOMETRY) failed: %d\n", ret);
- free(dev);
+ kfree(dev);
return ret;
}
/* Allocate one, in-memory erase block buffer */
#ifdef CONFIG_FS_WRITABLE
- dev->eblock = (FAR uint8_t *)malloc(dev->geo.erasesize);
+ dev->eblock = (FAR uint8_t *)kmalloc(dev->geo.erasesize);
if (!dev->eblock)
{
fdbg("Failed to allocate an erase block buffer\n");
- free(dev);
+ kfree(dev);
return -ENOMEM;
}
#endif
@@ -525,7 +526,7 @@ int ftl_initialize(int minor, uint8_t *buffer, FAR struct mtd_dev_s *mtd)
if (ret < 0)
{
fdbg("rwb_initialize failed: %d\n", ret);
- free(dev);
+ kfree(dev);
return ret;
}
#endif
@@ -540,7 +541,7 @@ int ftl_initialize(int minor, uint8_t *buffer, FAR struct mtd_dev_s *mtd)
if (ret < 0)
{
fdbg("register_blockdriver failed: %d\n", -ret);
- free(dev);
+ kfree(dev);
}
}
return ret;
diff --git a/nuttx/drivers/mtd/m25px.c b/nuttx/drivers/mtd/m25px.c
index 18b9aea02..474006c7f 100644
--- a/nuttx/drivers/mtd/m25px.c
+++ b/nuttx/drivers/mtd/m25px.c
@@ -2,7 +2,7 @@
* drivers/mtd/m25px.c
* Driver for SPI-based M25P1 (128Kbit), M25P64 (64Mbit), and M25P128 (128Mbit) FLASH
*
- * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
+ * Copyright (C) 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
@@ -47,6 +47,7 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/ioctl.h>
#include <nuttx/spi.h>
#include <nuttx/mtd.h>
@@ -673,7 +674,7 @@ FAR struct mtd_dev_s *m25p_initialize(FAR struct spi_dev_s *dev)
* to be extended to handle multiple FLASH parts on the same SPI bus.
*/
- priv = (FAR struct m25p_dev_s *)malloc(sizeof(struct m25p_dev_s));
+ priv = (FAR struct m25p_dev_s *)kmalloc(sizeof(struct m25p_dev_s));
if (priv)
{
/* Initialize the allocated structure */
@@ -697,7 +698,7 @@ FAR struct mtd_dev_s *m25p_initialize(FAR struct spi_dev_s *dev)
/* Unrecognized! Discard all of that work we just did and return NULL */
fdbg("Unrecognized\n");
- free(priv);
+ kfree(priv);
priv = NULL;
}
}
diff --git a/nuttx/drivers/mtd/ramtron.c b/nuttx/drivers/mtd/ramtron.c
index ab27a0dc2..5739b3b05 100755
--- a/nuttx/drivers/mtd/ramtron.c
+++ b/nuttx/drivers/mtd/ramtron.c
@@ -67,6 +67,7 @@
#include <debug.h>
#include <assert.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/ioctl.h>
#include <nuttx/spi.h>
#include <nuttx/mtd.h>
@@ -635,7 +636,7 @@ FAR struct mtd_dev_s *ramtron_initialize(FAR struct spi_dev_s *dev)
* to be extended to handle multiple FLASH parts on the same SPI bus.
*/
- priv = (FAR struct ramtron_dev_s *)malloc(sizeof(struct ramtron_dev_s));
+ priv = (FAR struct ramtron_dev_s *)kmalloc(sizeof(struct ramtron_dev_s));
if (priv)
{
/* Initialize the allocated structure */
@@ -656,7 +657,7 @@ FAR struct mtd_dev_s *ramtron_initialize(FAR struct spi_dev_s *dev)
if (ramtron_readid(priv) != OK)
{
/* Unrecognized! Discard all of that work we just did and return NULL */
- free(priv);
+ kfree(priv);
priv = NULL;
}
}