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

Commit 4b50e52b authored by Yeleswarapu Nagaradhesh's avatar Yeleswarapu Nagaradhesh Committed by Gerrit - the friendly Code Review server
Browse files

drivers: mfd: donot clear interrupt status



If there is a fake interrupt SW is clearing interrupt status,
due to this some of the required interrupts are getting cleared.
Remove clearing of status register to avoid this.

CRs-Fixed: 2045773
Change-Id: I38247d69bd49a64731c3ec695d5470f5c591fea6
Signed-off-by: default avatarYeleswarapu Nagaradhesh <nagaradh@codeaurora.org>
parent 1995d3a6
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -288,7 +288,7 @@ static irqreturn_t wcd9xxx_irq_thread(int irq, void *data)
	static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 1);
	struct wcd9xxx_core_resource *wcd9xxx_res = data;
	int num_irq_regs = wcd9xxx_res->num_irq_regs;
	u8 status[num_irq_regs], status1[num_irq_regs];
	u8 status[4], status1[4] = {0}, unmask_status[4] = {0};

	if (unlikely(wcd9xxx_lock_sleep(wcd9xxx_res) == false)) {
		dev_err(wcd9xxx_res->dev, "Failed to hold suspend\n");
@@ -311,6 +311,23 @@ static irqreturn_t wcd9xxx_irq_thread(int irq, void *data)
				"Failed to read interrupt status: %d\n", ret);
		goto err_disable_irq;
	}
	/*
	 * If status is 0 return without clearing.
	 * status contains: HW status - masked interrupts
	 * status1 contains: unhandled interrupts - masked interrupts
	 * unmasked_status contains: unhandled interrupts
	 */
	if (unlikely(!memcmp(status, status1, sizeof(status)))) {
		pr_debug("%s: status is 0\n", __func__);
		wcd9xxx_unlock_sleep(wcd9xxx_res);
		return IRQ_HANDLED;
	}

	/*
	 * Copy status to unmask_status before masking, otherwise SW may miss
	 * to clear masked interrupt in corner case.
	 */
	memcpy(unmask_status, status, sizeof(unmask_status));

	/* Apply masking */
	for (i = 0; i < num_irq_regs; i++)
@@ -334,6 +351,8 @@ static irqreturn_t wcd9xxx_irq_thread(int irq, void *data)
			wcd9xxx_irq_dispatch(wcd9xxx_res, &irqdata);
			status1[BIT_BYTE(irqdata.intr_num)] &=
					~BYTE_BIT_MASK(irqdata.intr_num);
			unmask_status[BIT_BYTE(irqdata.intr_num)] &=
					~BYTE_BIT_MASK(irqdata.intr_num);
		}
	}