diff options
author | Yuval Peress <peress@chromium.org> | 2020-11-07 11:06:42 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-08 03:41:09 +0000 |
commit | df5f77987d6707936c13a0e2fee09ddbd84c627a (patch) | |
tree | 40da0ac8b5ed777d07466df3b94c580999847030 | |
parent | 1665108ad76afffd5d365aee932a96cda3199f78 (diff) | |
download | chrome-ec-df5f77987d6707936c13a0e2fee09ddbd84c627a.tar.gz |
common:i2c: Migrate interrupt_(dis|en)able calls to irq_(un|)lock
This change migrates interrupt_disable -> irq_lock and
interrupt_enable -> irq_unlock.
BRANCH=none
BUG=b:172060699
TEST=make runtests -j, and built for various boards:
eve, volteer, arcada_ish, atlas, hatch, kohaku,
nocturne, samus, and scarlet
Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: Ia5d872d8b9fcabc23a859350cf3bf121597d84af
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2517629
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Queue: Simon Glass <sjg@chromium.org>
-rw-r--r-- | common/i2c_master.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/common/i2c_master.c b/common/i2c_master.c index ed94f2b38d..ad6c50c215 100644 --- a/common/i2c_master.c +++ b/common/i2c_master.c @@ -210,29 +210,31 @@ void i2c_lock(int port, int lock) /* Lock the controller, not the port */ port = i2c_port_to_controller(port); #endif - if (port < 0) + if (port < 0 || port >= ARRAY_SIZE(port_mutex)) return; if (lock) { + uint32_t irq_lock_key; + mutex_lock(port_mutex + port); /* Disable interrupt during changing counter for preemption. */ - interrupt_disable(); + irq_lock_key = irq_lock(); i2c_port_active_list |= 1 << port; /* Ec cannot enter sleep if there's any i2c port active. */ disable_sleep(SLEEP_MASK_I2C_MASTER); - interrupt_enable(); + irq_unlock(irq_lock_key); } else { - interrupt_disable(); + uint32_t irq_lock_key = irq_lock(); i2c_port_active_list &= ~BIT(port); /* Once there is no i2c port active, enable sleep bit of i2c. */ if (!i2c_port_active_list) enable_sleep(SLEEP_MASK_I2C_MASTER); - interrupt_enable(); + irq_unlock(irq_lock_key); mutex_unlock(port_mutex + port); } |