Skip to content

Commit 5380bc5

Browse files
Daniel Wagenknechtgalak
authored andcommitted
drivers: i2c_ll_stm32_v2: reorder to remove duplication
Disabling of Interrupts is duplicated. Move it to a position that is common to messages that end with and without errors. Signed-off-by: Daniel Wagenknecht <[email protected]>
1 parent c393bfd commit 5380bc5

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

drivers/i2c/i2c_ll_stm32_v2.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,17 @@ int stm32_i2c_msg_write(struct device *dev, struct i2c_msg *msg,
142142
LL_I2C_EnableIT_NACK(i2c);
143143

144144
k_sem_take(&data->device_sync_sem, K_FOREVER);
145+
LL_I2C_DisableIT_TX(i2c);
146+
LL_I2C_DisableIT_NACK(i2c);
147+
145148
if (data->current.is_nack || data->current.is_err) {
146149
goto error;
147150
}
148151

149152
msg_done(dev, msg->flags);
150-
LL_I2C_DisableIT_TX(i2c);
151-
LL_I2C_DisableIT_NACK(i2c);
152153

153154
return 0;
154155
error:
155-
LL_I2C_DisableIT_TX(i2c);
156-
LL_I2C_DisableIT_NACK(i2c);
157-
158156
if (data->current.is_nack) {
159157
SYS_LOG_DBG("%s: NACK", __func__);
160158
data->current.is_nack = 0;
@@ -185,16 +183,16 @@ int stm32_i2c_msg_read(struct device *dev, struct i2c_msg *msg,
185183
LL_I2C_EnableIT_RX(i2c);
186184

187185
k_sem_take(&data->device_sync_sem, K_FOREVER);
186+
LL_I2C_DisableIT_RX(i2c);
187+
188188
if (data->current.is_err) {
189189
goto error;
190190
}
191191

192192
msg_done(dev, msg->flags);
193-
LL_I2C_DisableIT_RX(i2c);
194193

195194
return 0;
196195
error:
197-
LL_I2C_DisableIT_RX(i2c);
198196
SYS_LOG_DBG("%s: ERR %d", __func__, data->current.is_err);
199197
data->current.is_err = 0;
200198

0 commit comments

Comments
 (0)