MIPS: lantiq: Fix bitfield masking [Linux 4.9.188]

This Linux kernel change "MIPS: lantiq: Fix bitfield masking" is included in the Linux 4.9.188 release. This change is authored by Petr Cvek <petrcvekcz [at] gmail.com> on Thu Jun 20 23:39:37 2019 +0200. The commit for this change in Linux stable tree is f174142 (patch) which is from upstream commit ba1bc0f. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream ba1bc0f.

MIPS: lantiq: Fix bitfield masking

[ Upstream commit ba1bc0fcdeaf3bf583c1517bd2e3e29cf223c969 ]

The modification of EXIN register doesn't clean the bitfield before
the writing of a new value. After a few modifications the bitfield would
accumulate only '1's.

Signed-off-by: Petr Cvek <petrcvekcz@gmail.com>
Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: hauke@hauke-m.de
Cc: john@phrozen.org
Cc: linux-mips@vger.kernel.org
Cc: openwrt-devel@lists.openwrt.org
Cc: pakahmar@hotmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>

There are 5 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 arch/mips/lantiq/irq.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/mips/lantiq/irq.c b/arch/mips/lantiq/irq.c
index 8ac0e59..7c6f75c 100644
--- a/arch/mips/lantiq/irq.c
+++ b/arch/mips/lantiq/irq.c
@@ -160,8 +160,9 @@ static int ltq_eiu_settype(struct irq_data *d, unsigned int type)
            if (edge)
                irq_set_handler(d->hwirq, handle_edge_irq);

-           ltq_eiu_w32(ltq_eiu_r32(LTQ_EIU_EXIN_C) |
-               (val << (i * 4)), LTQ_EIU_EXIN_C);
+           ltq_eiu_w32((ltq_eiu_r32(LTQ_EIU_EXIN_C) &
+                   (~(7 << (i * 4)))) | (val << (i * 4)),
+                   LTQ_EIU_EXIN_C);

Leave a Reply

Your email address will not be published. Required fields are marked *