diff --git a/drivers/adc/adc_lmp90xxx.c b/drivers/adc/adc_lmp90xxx.c index aca6e4c49da..d52c78c6b56 100644 --- a/drivers/adc/adc_lmp90xxx.c +++ b/drivers/adc/adc_lmp90xxx.c @@ -193,6 +193,11 @@ static int lmp90xxx_read_reg(struct device *dev, u8_t addr, u8_t *dptr, return -EINVAL; } + if (k_is_in_isr()) { + /* Prevent SPI transactions from an ISR */ + return -EWOULDBLOCK; + } + k_mutex_lock(&data->ura_lock, K_FOREVER); if (ura != data->ura) { @@ -259,6 +264,11 @@ static int lmp90xxx_write_reg(struct device *dev, u8_t addr, u8_t *dptr, return -EINVAL; } + if (k_is_in_isr()) { + /* Prevent SPI transactions from an ISR */ + return -EWOULDBLOCK; + } + k_mutex_lock(&data->ura_lock, K_FOREVER); if (ura != data->ura) {