static int mbochs_dmabuf_export(struct mbochs_dmabuf *dmabuf)
{
	struct mdev_state *mdev_state = dmabuf->mdev_state;
	struct device *dev = mdev_state->vdev.dev;
	DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
	struct dma_buf *buf;

	WARN_ON(!mutex_is_locked(&mdev_state->ops_lock));

	if (!IS_ALIGNED(dmabuf->mode.offset, PAGE_SIZE)) {
		dev_info_ratelimited(dev, "%s: framebuffer not page-aligned\n",
				     __func__);
		return -EINVAL;
	}

	exp_info.ops = &mbochs_dmabuf_ops;
	exp_info.size = dmabuf->mode.size;
	exp_info.priv = dmabuf;

	buf = dma_buf_export(&exp_info);
	if (IS_ERR(buf)) {
		dev_info_ratelimited(dev, "%s: dma_buf_export failed: %ld\n",
				     __func__, PTR_ERR(buf));
		return PTR_ERR(buf);
	}

	dmabuf->buf = buf;
	dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id);
	return 0;
}
static int mbochs_dmabuf_export(struct mbochs_dmabuf *dmabuf)
{
	struct mdev_state *mdev_state = dmabuf->mdev_state;
	struct device *dev = mdev_state->vdev.dev;
	DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
	struct dma_buf *buf;

	WARN_ON(!mutex_is_locked(&mdev_state->ops_lock));

	if (!IS_ALIGNED(dmabuf->mode.offset, PAGE_SIZE)) {
		dev_info_ratelimited(dev, "%s: framebuffer not page-aligned\n",
				     __func__);
		return -EINVAL;
	}

	exp_info.ops = &mbochs_dmabuf_ops;
	exp_info.size = dmabuf->mode.size;
	exp_info.priv = dmabuf;

	buf = dma_buf_export(&exp_info);
	if (IS_ERR(buf)) {
		dev_info_ratelimited(dev, "%s: dma_buf_export failed: %ld\n",
				     __func__, PTR_ERR(buf));
		return PTR_ERR(buf);
	}

	dmabuf->buf = buf;
	dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id);
	return 0;
}