Skip to content

Commit

Permalink
pkg/lwext4: make use of mtd_write_sector()
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Dec 14, 2023
1 parent 31e4592 commit 5e30c0e
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions pkg/lwext4/fs/lwext4_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,12 @@ static int blockdev_bwrite(struct ext4_blockdev *bdev, const void *buf,
{
mtd_dev_t *dev = bdev->bdif->p_user;

uint32_t page = blk_id * dev->pages_per_sector;
uint32_t size = blk_cnt * dev->pages_per_sector * dev->page_size;

assert(blk_id <= UINT32_MAX);

DEBUG("lwext4: erase %"PRIu32" sectors starting with %"PRIu64"\n", blk_cnt, blk_id);
int res = mtd_erase_sector(dev, blk_id, blk_cnt);
if (res) {
return -res;
}

DEBUG("lwext4: write %"PRIu32" bytes to page %"PRIu32"\n", size, page);
DEBUG("lwext4: write %"PRIu32" bytes to sector %"PRIu32"\n",
blk_cnt * dev->pages_per_sector * dev->page_size, (uint32_t)blk_id);

return -mtd_write_page_raw(dev, buf, page, 0, size);
return -mtd_write_sector(dev, buf, blk_id, blk_cnt);
}

static int prepare(lwext4_desc_t *fs, const char *mount_point)
Expand Down

0 comments on commit 5e30c0e

Please sign in to comment.