Example #1
0
int fsl_mc_io_set_dpmcp(struct fsl_mc_io *mc_io,
			struct fsl_mc_device *dpmcp_dev)
{
	int error;

	if (WARN_ON(!dpmcp_dev))
		return -EINVAL;

	if (WARN_ON(mc_io->dpmcp_dev))
		return -EINVAL;

	if (WARN_ON(dpmcp_dev->mc_io))
		return -EINVAL;

	error = dpmcp_open(mc_io,
			   0,
			   dpmcp_dev->obj_desc.id,
			   &dpmcp_dev->mc_handle);
	if (error < 0)
		return error;

	mc_io->dpmcp_dev = dpmcp_dev;
	dpmcp_dev->mc_io = mc_io;
	return 0;
}
Example #2
0
/**
 * fsl_mc_portal_reset - Resets the dpmcp object for a given fsl_mc_io object
 *
 * @mc_io: Pointer to the fsl_mc_io object that wraps the MC portal to free
 */
int fsl_mc_portal_reset(struct fsl_mc_io *mc_io)
{
	int error;
	uint16_t token;
	struct fsl_mc_resource *resource = mc_io->resource;
	struct fsl_mc_device *mc_dev = resource->data;

	if (WARN_ON(resource->type != FSL_MC_POOL_DPMCP))
		return -EINVAL;

	if (WARN_ON(!mc_dev))
		return -EINVAL;

	error = dpmcp_open(mc_io, mc_dev->obj_desc.id, &token);
	if (error < 0) {
		dev_err(&mc_dev->dev, "dpmcp_open() failed: %d\n", error);
		return error;
	}

	error = dpmcp_reset(mc_io, token);
	if (error < 0) {
		dev_err(&mc_dev->dev, "dpmcp_reset() failed: %d\n", error);
		return error;
	}

	error = dpmcp_close(mc_io, token);
	if (error < 0) {
		dev_err(&mc_dev->dev, "dpmcp_close() failed: %d\n", error);
		return error;
	}

	return 0;
}