mtd: add support for MTDIOC_ERASESECTORS ioctl
Current driver supports MTDIOC_BULKERASE ioctl that erases the entire device. The added ioctl MTDIOC_ERASESECTORS adds possibility to erase just sectors defined by the user. This is similar to MEMERASE call in Linux kernel. Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
parent
5afa727eef
commit
02aa7bcefe
@ -469,6 +469,19 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MTDIOC_ERASESECTORS:
|
||||||
|
{
|
||||||
|
/* Erase sectors as defined in mtd_erase_s structure */
|
||||||
|
|
||||||
|
FAR struct mtd_erase_s *erase = (FAR struct mtd_erase_s *)arg;
|
||||||
|
|
||||||
|
ret = priv->parent->erase(priv->parent,
|
||||||
|
priv->firstblock / priv->blkpererase +
|
||||||
|
erase->startblock,
|
||||||
|
erase->nblocks);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
/* Pass any unhandled ioctl() calls to the underlying driver */
|
/* Pass any unhandled ioctl() calls to the underlying driver */
|
||||||
|
@ -74,6 +74,8 @@
|
|||||||
#define MTDIOC_ERASESTATE _MTDIOC(0x000a) /* IN: Pointer to uint8_t
|
#define MTDIOC_ERASESTATE _MTDIOC(0x000a) /* IN: Pointer to uint8_t
|
||||||
* OUT: Byte value that represents the
|
* OUT: Byte value that represents the
|
||||||
* erased state of the MTD cell */
|
* erased state of the MTD cell */
|
||||||
|
#define MTDIOC_ERASESECTORS _MTDIOC(0x000c) /* IN: Pointer to mtd_erase_s structure
|
||||||
|
* OUT: None */
|
||||||
|
|
||||||
/* Macros to hide implementation */
|
/* Macros to hide implementation */
|
||||||
|
|
||||||
@ -139,6 +141,14 @@ struct mtd_byte_write_s
|
|||||||
const uint8_t *buffer; /* Pointer to the data to write */
|
const uint8_t *buffer; /* Pointer to the data to write */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* This structure describes a range of erase sectors to be erased. */
|
||||||
|
|
||||||
|
struct mtd_erase_s
|
||||||
|
{
|
||||||
|
uint32_t startblock; /* First block to be erased */
|
||||||
|
uint32_t nblocks; /* Number of blocks to be erased */
|
||||||
|
};
|
||||||
|
|
||||||
/* This structure defines the interface to a simple memory technology device.
|
/* This structure defines the interface to a simple memory technology device.
|
||||||
* It will likely need to be extended in the future to support more complex
|
* It will likely need to be extended in the future to support more complex
|
||||||
* devices.
|
* devices.
|
||||||
|
Loading…
Reference in New Issue
Block a user