/* @dev: device @blknr: first block to be write @blkcnt: number of blocks to write @buffer: input buffer Return: number of blocks transferred  */
static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer)
/* @dev: device @blknr: first block to be write @blkcnt: number of blocks to write @buffer: input buffer Return: number of blocks transferred  */
static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer)
{
	struct efi_blk_platdata *platdata = dev_get_platdata(dev);
	struct efi_block_io *io = platdata->io;
	efi_status_t ret;
	EFI_PRINT("%s: write '%s', from block " LBAFU ", " LBAFU " blocks\n",
		  __func__, dev->name, blknr, blkcnt);
	ret = EFI_CALL(io->write_blocks(
				io, io->media->media_id, (u64)blknr,
				(efi_uintn_t)blkcnt *
				(efi_uintn_t)io->media->block_size,
				(void *)buffer));
	EFI_PRINT("%s: r = %u\n", __func__,
		  (unsigned int)(ret & ~EFI_ERROR_MASK));
	if (ret != EFI_SUCCESS)
		return 0;
	return blkcnt;
}