diff options
-rw-r--r-- | chip/lm4/lpc.c | 18 | ||||
-rw-r--r-- | chip/mec1322/lpc.c | 18 |
2 files changed, 30 insertions, 6 deletions
diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c index eb1e53a802..0593570b61 100644 --- a/chip/lm4/lpc.c +++ b/chip/lm4/lpc.c @@ -389,12 +389,25 @@ void lpc_set_host_event_state(uint32_t mask) int lpc_query_host_event_state(void) { + const uint32_t any_mask = event_mask[0] | event_mask[1] | event_mask[2]; int evt_index = 0; int i; for (i = 0; i < 32; i++) { - if (host_events & (1 << i)) { - host_clear_events(1 << i); + const uint32_t e = (1 << i); + + if (host_events & e) { + host_clear_events(e); + + /* + * If host hasn't unmasked this event, drop it. We do + * this at query time rather than event generation time + * so that the host has a chance to unmask events + * before they're dropped by a query. + */ + if (!(e & any_mask)) + continue; + evt_index = i + 1; /* Events are 1-based */ break; } @@ -403,7 +416,6 @@ int lpc_query_host_event_state(void) return evt_index; } - void lpc_set_host_event_mask(enum lpc_host_event_type type, uint32_t mask) { event_mask[type] = mask; diff --git a/chip/mec1322/lpc.c b/chip/mec1322/lpc.c index fb3ace7438..5c715797b5 100644 --- a/chip/mec1322/lpc.c +++ b/chip/mec1322/lpc.c @@ -341,12 +341,25 @@ void lpc_set_host_event_state(uint32_t mask) int lpc_query_host_event_state(void) { + const uint32_t any_mask = event_mask[0] | event_mask[1] | event_mask[2]; int evt_index = 0; int i; for (i = 0; i < 32; i++) { - if (host_events & (1 << i)) { - host_clear_events(1 << i); + const uint32_t e = (1 << i); + + if (host_events & e) { + host_clear_events(e); + + /* + * If host hasn't unmasked this event, drop it. We do + * this at query time rather than event generation time + * so that the host has a chance to unmask events + * before they're dropped by a query. + */ + if (!(e & any_mask)) + continue; + evt_index = i + 1; /* Events are 1-based */ break; } @@ -355,7 +368,6 @@ int lpc_query_host_event_state(void) return evt_index; } - void lpc_set_host_event_mask(enum lpc_host_event_type type, uint32_t mask) { event_mask[type] = mask; |