Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 278de69d authored by Tarun Gupta's avatar Tarun Gupta Committed by Gerrit - the friendly Code Review server
Browse files

USB: gadget: Fix Bug in to disable interrupts usecase



USB driver is using a timer to enable interrupt, so the interrupts are not
disabled for long time. If following scenario happens timer keeps getting
rearmed indefinitely. If interrupts are already enabled and call to enable
interrupts again is received, in this case we should not rearm the timer.
Timer is required to be rearmed only when interrupts are disabled and
another call for disabling interrupt is received.

This change fixes the above issue and adds some debug messages

Change-Id: I9f391d259bd441d3516323366412b5a2822382b4
Signed-off-by: default avatarTarun Gupta <tarung@codeaurora.org>
parent c67f84f6
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -516,7 +516,10 @@ void msm_usb_irq_disable(bool disable)
	spin_lock_irqsave(udc->lock, flags);

	if (_udc_ctxt.irq_disabled == disable) {
		mod_timer(&_udc_ctxt.irq_enable_timer, IRQ_ENABLE_DELAY);
		pr_debug("Interrupt state already disable = %d\n", disable);
		if (disable)
			mod_timer(&_udc_ctxt.irq_enable_timer,
					IRQ_ENABLE_DELAY);
		spin_unlock_irqrestore(udc->lock, flags);
		return;
	}
@@ -524,10 +527,12 @@ void msm_usb_irq_disable(bool disable)
	if (disable) {
		disable_irq_nosync(_udc_ctxt.irq);
		/* start timer here */
		pr_debug("%s: Disabling interrupts\n", __func__);
		mod_timer(&_udc_ctxt.irq_enable_timer, IRQ_ENABLE_DELAY);
		_udc_ctxt.irq_disabled = true;

	} else {
		pr_debug("%s: Enabling interrupts\n", __func__);
		del_timer(&_udc_ctxt.irq_enable_timer);
		enable_irq(_udc_ctxt.irq);
		_udc_ctxt.irq_disabled = false;
@@ -538,6 +543,7 @@ void msm_usb_irq_disable(bool disable)

static void enable_usb_irq_timer_func(unsigned long data)
{
	pr_debug("enabling interrupt from timer\n");
	msm_usb_irq_disable(false);
}