int gxio_mpipe_destroy(gxio_mpipe_context_t *context)
{

	iounmap((void __force __iomem *)(context->mmio_cfg_base));
	iounmap((void __force __iomem *)(context->mmio_fast_base));
	return hv_dev_close(context->fd);

}
int __gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index,
		      unsigned int mode_flags)
{

	char file[32];
	int fd;
	int i;

	if (mpipe_index >= GXIO_MPIPE_INSTANCE_MAX)
		return -EINVAL;

	snprintf(file, sizeof(file), "mpipe/%d/iorpc", mpipe_index);
	fd = hv_dev_open((HV_VirtAddr) file, 0);

	context->fd = fd;

	if (fd < 0) {
		if (fd >= GXIO_ERR_MIN && fd <= GXIO_ERR_MAX)
			return fd;
		else
			return -ENODEV;
	}

	/* Map in the MMIO space. */
	context->mmio_cfg_base = (void __force *)
		iorpc_ioremap(fd, HV_MPIPE_CONFIG_MMIO_OFFSET,
			      HV_MPIPE_CONFIG_MMIO_SIZE);
	if (context->mmio_cfg_base == NULL)
		goto cfg_failed;

	context->mmio_fast_base = (void __force *)
		iorpc_ioremap(fd, HV_MPIPE_FAST_MMIO_OFFSET,
			      HV_MPIPE_FAST_MMIO_SIZE);
	if (context->mmio_fast_base == NULL)
		goto fast_failed;

	/* Initialize the stacks. */
	for (i = 0; i < 8; i++)
		context->__stacks.stacks[i] = 255;

	context->instance = mpipe_index;

	return 0;

      fast_failed:
	iounmap((void __force __iomem *)(context->mmio_cfg_base));
      cfg_failed:
	hv_dev_close(context->fd);
	context->fd = -1;
	return -ENODEV;

}
예제 #3
0
파일: softuart.c 프로젝트: rslotte/OGS-Tile
/*
 * The HV driver could still be transmitting buffered data after this
 * call.
 */
static void softuart_close(struct tty_struct *tty, struct file *filp)
{
	struct softuart_private *softuartp = tty->driver_data;
	unsigned long flags;

	if (!softuartp) /* This means the open failed */
		return;

	spin_lock_irqsave(&softuartp->lock, flags);

	if (tty->count == 1) {
		/* This is the last device close. */
		softuartp->tty = NULL;
		softuart_configure_downcall(0);
	}

	spin_unlock_irqrestore(&softuartp->lock, flags);

	hv_dev_close(softuart_fd);
}