From 83dbeae3ab5c30e61292e6a310a7c507dbf04553 Mon Sep 17 00:00:00 2001 From: Li Jun Date: Thu, 27 Jul 2017 00:08:15 +0800 Subject: [PATCH] MLK-16013-11 staging: typec: only clear alert events for enabled irq Uncondtionaly clear all events may impact the typec controller state machine, so save the enabled irq and only clear alert events for enabled irq. Reviewed-by: Peter Chen Signed-off-by: Li Jun --- drivers/staging/typec/tcpci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c index 2b3b73b732f4..2c847c6c1105 100644 --- a/drivers/staging/typec/tcpci.c +++ b/drivers/staging/typec/tcpci.c @@ -39,6 +39,7 @@ struct tcpci { bool controls_vbus; struct tcpc_dev tcpc; + unsigned int irq_mask; }; static inline struct tcpci *tcpc_to_tcpci(struct tcpc_dev *tcpc) @@ -369,6 +370,8 @@ static int tcpci_init(struct tcpc_dev *tcpc) TCPC_ALERT_RX_HARD_RST | TCPC_ALERT_CC_STATUS; if (tcpci->controls_vbus) reg |= TCPC_ALERT_POWER_STATUS; + tcpci->irq_mask = reg; + return tcpci_write16(tcpci, TCPC_ALERT_MASK, reg); } @@ -380,10 +383,10 @@ static irqreturn_t tcpci_irq(int irq, void *dev_id) tcpci_read16(tcpci, TCPC_ALERT, &status); /* - * Clear alert status for everything except RX_STATUS, which shouldn't + * Clear alert status for enabled irq except RX_STATUS, which shouldn't * be cleared until we have successfully retrieved message. */ - if (status & ~TCPC_ALERT_RX_STATUS) + if ((status & ~TCPC_ALERT_RX_STATUS) & tcpci->irq_mask) tcpci_write16(tcpci, TCPC_ALERT, status & ~TCPC_ALERT_RX_STATUS); -- 2.17.1