static int ps3_vuart_bus_interrupt_get()

in ps3-vuart.c [902:956]


static int ps3_vuart_bus_interrupt_get(void)
{
	int result;

	pr_debug(" -> %s:%d\n", __func__, __LINE__);

	vuart_bus_priv.use_count++;

	BUG_ON(vuart_bus_priv.use_count > 2);

	if (vuart_bus_priv.use_count != 1)
		return 0;

	BUG_ON(vuart_bus_priv.bmp);

	vuart_bus_priv.bmp = kzalloc(sizeof(struct ports_bmp), GFP_KERNEL);

	if (!vuart_bus_priv.bmp) {
		result = -ENOMEM;
		goto fail_bmp_malloc;
	}

	result = ps3_vuart_irq_setup(PS3_BINDING_CPU_ANY, vuart_bus_priv.bmp,
		&vuart_bus_priv.virq);

	if (result) {
		pr_debug("%s:%d: ps3_vuart_irq_setup failed (%d)\n",
			__func__, __LINE__, result);
		result = -EPERM;
		goto fail_alloc_irq;
	}

	result = request_irq(vuart_bus_priv.virq, ps3_vuart_irq_handler,
		0, "vuart", &vuart_bus_priv);

	if (result) {
		pr_debug("%s:%d: request_irq failed (%d)\n",
			__func__, __LINE__, result);
		goto fail_request_irq;
	}

	pr_debug(" <- %s:%d: ok\n", __func__, __LINE__);
	return result;

fail_request_irq:
	ps3_vuart_irq_destroy(vuart_bus_priv.virq);
	vuart_bus_priv.virq = 0;
fail_alloc_irq:
	kfree(vuart_bus_priv.bmp);
	vuart_bus_priv.bmp = NULL;
fail_bmp_malloc:
	vuart_bus_priv.use_count--;
	pr_debug(" <- %s:%d: failed\n", __func__, __LINE__);
	return result;
}