Skip to content

Commit 8b40bb1

Browse files
committed
drivers: i2c_stm32_v2: Refactor end of master transfer
The stm32_i2c_master_mode_end function can be replaced with a simple irq disable and giving to the device sync semaphore Signed-off-by: Erik Andersson <erian747@gmail.com>
1 parent 1b52926 commit 8b40bb1

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

drivers/i2c/i2c_ll_stm32_v2.c

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -243,31 +243,6 @@ static void i2c_stm32_disable_transfer_interrupts(const struct device *dev)
243243
}
244244
}
245245

246-
static void i2c_stm32_master_mode_end(const struct device *dev)
247-
{
248-
const struct i2c_stm32_config *cfg = dev->config;
249-
struct i2c_stm32_data *data = dev->data;
250-
I2C_TypeDef *i2c = cfg->i2c;
251-
252-
i2c_stm32_disable_transfer_interrupts(dev);
253-
254-
if (LL_I2C_IsEnabledReloadMode(i2c)) {
255-
LL_I2C_DisableReloadMode(i2c);
256-
}
257-
258-
#if defined(CONFIG_I2C_TARGET)
259-
data->master_active = false;
260-
if (!data->slave_attached && !data->smbalert_active) {
261-
LL_I2C_Disable(i2c);
262-
}
263-
#else
264-
if (!data->smbalert_active) {
265-
LL_I2C_Disable(i2c);
266-
}
267-
#endif
268-
k_sem_give(&data->device_sync_sem);
269-
}
270-
271246
#if defined(CONFIG_I2C_TARGET)
272247
static void i2c_stm32_slave_event(const struct device *dev)
273248
{
@@ -662,7 +637,9 @@ int i2c_stm32_error(const struct device *dev)
662637

663638
return 0;
664639
end:
665-
i2c_stm32_master_mode_end(dev);
640+
i2c_stm32_disable_transfer_interrupts(dev);
641+
/* Wakeup thread */
642+
k_sem_give(&data->device_sync_sem);
666643
return -EIO;
667644
}
668645

0 commit comments

Comments
 (0)