1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

mtd: drop .write() function

All MTD drivers should now implement the .write_page() function instead.
This commit is contained in:
Benjamin Valentin 2023-02-16 17:49:18 +01:00 committed by Benjamin Valentin
parent 431afeaa51
commit 9855b02b07
2 changed files with 5 additions and 33 deletions

View File

@ -250,25 +250,6 @@ struct mtd_desc {
uint32_t offset,
uint32_t size);
/**
* @brief Write to the Memory Technology Device (MTD)
*
* @p addr + @p size must be inside a page boundary. @p addr can be anywhere
* but the buffer cannot overlap two pages.
*
* @param[in] dev Pointer to the selected driver
* @param[in] buff Pointer to the data to be written
* @param[in] addr Starting address
* @param[in] size Number of bytes
*
* @retval 0 on success
* @retval <0 value on error
*/
int (*write)(mtd_dev_t *dev,
const void *buff,
uint32_t addr,
uint32_t size);
/**
* @brief Write to the Memory Technology Device (MTD) using
* pagewise addressing.

View File

@ -169,14 +169,6 @@ int mtd_write(mtd_dev_t *mtd, const void *src, uint32_t addr, uint32_t count)
return -ENODEV;
}
if (out_of_bounds(mtd, 0, addr, count)) {
return -EOVERFLOW;
}
if (mtd->driver->write) {
return mtd->driver->write(mtd, src, addr, count);
}
/* page size is always a power of two */
const uint32_t page_shift = bitarithm_msb(mtd->page_size);
const uint32_t page_mask = mtd->page_size - 1;
@ -255,6 +247,10 @@ int mtd_write_page(mtd_dev_t *mtd, const void *data, uint32_t page,
return -ENODEV;
}
if (mtd->driver->write_page == NULL) {
return -ENOTSUP;
}
if (out_of_bounds(mtd, page, offset, len)) {
return -EOVERFLOW;
}
@ -297,12 +293,7 @@ int mtd_write_page_raw(mtd_dev_t *mtd, const void *src, uint32_t page, uint32_t
}
if (mtd->driver->write_page == NULL) {
/* TODO: remove when all backends implement write_page */
if (mtd->driver->write) {
return mtd->driver->write(mtd, src, mtd->page_size * page + offset, count);
} else {
return -ENOTSUP;
}
return -ENOTSUP;
}
/* Implementation assumes page size is <= INT_MAX and a power of two. */