/* @block_dev: Pointer to block device @start: First block to write/erase @blkcnt: Count of blocks @buffer: Pointer to data buffer for write or NULL for erase  */
static lbaint_t fb_mmc_blk_write(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, const void *buffer)
/* @block_dev: Pointer to block device @start: First block to write/erase @blkcnt: Count of blocks @buffer: Pointer to data buffer for write or NULL for erase  */
static lbaint_t fb_mmc_blk_write(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, const void *buffer)
{
	lbaint_t blk = start;
	lbaint_t blks_written;
	lbaint_t cur_blkcnt;
	lbaint_t blks = 0;
	int i;
	for (i = 0; i < blkcnt; i += FASTBOOT_MAX_BLK_WRITE) {
		cur_blkcnt = min((int)blkcnt - i, FASTBOOT_MAX_BLK_WRITE);
		if (buffer) {
			if (fastboot_progress_callback)
				fastboot_progress_callback("writing");
			blks_written = blk_dwrite(block_dev, blk, cur_blkcnt,
						  buffer + (i * block_dev->blksz));
		} else {
			if (fastboot_progress_callback)
				fastboot_progress_callback("erasing");
			blks_written = blk_derase(block_dev, blk, cur_blkcnt);
		}
		blk += blks_written;
		blks += blks_written;
	}
	return blks;
}