Skip to content

Commit

Permalink
mtd: drop .write() function
Browse files Browse the repository at this point in the history
All MTD drivers should now implement the .write_page() function instead.
  • Loading branch information
benpicco committed Dec 13, 2023
1 parent 431afea commit 82cf5f3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
19 changes: 0 additions & 19 deletions drivers/include/mtd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 0 additions & 17 deletions drivers/mtd/mtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -296,15 +288,6 @@ int mtd_write_page_raw(mtd_dev_t *mtd, const void *src, uint32_t page, uint32_t
return -EOVERFLOW;
}

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;
}
}

/* Implementation assumes page size is <= INT_MAX and a power of two. */
/* We didn't find hardware yet where this is not true. */
assert(mtd->page_size <= INT_MAX);
Expand Down

0 comments on commit 82cf5f3

Please sign in to comment.