diff options
| author | a1012112796 <[email protected]> | 2023-05-12 12:11:28 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-12 00:11:28 -0400 |
| commit | 5e4a95f54d434c70a9d24ac14df83421364b615f (patch) | |
| tree | 3bdddd51f6b02108fbc1012fec728579d7bdd735 | |
| parent | c94a849ba4366e953b71f7dff2a9a767453832bf (diff) | |
[components/drivers] add result check for configure in `rt_spi_configure` (#7474)
Signed-off-by: a1012112796 <[email protected]>
Co-authored-by: Man, Jianting (Meco) <[email protected]>
| -rw-r--r-- | components/drivers/spi/spi_core.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/components/drivers/spi/spi_core.c b/components/drivers/spi/spi_core.c index c5e769db10..9cff697b32 100644 --- a/components/drivers/spi/spi_core.c +++ b/components/drivers/spi/spi_core.c @@ -90,7 +90,7 @@ rt_err_t rt_spi_bus_attach_device(struct rt_spi_device *device, rt_err_t rt_spi_configure(struct rt_spi_device *device, struct rt_spi_configuration *cfg) { - rt_err_t result; + rt_err_t result = -RT_ERROR; RT_ASSERT(device != RT_NULL); @@ -114,15 +114,25 @@ rt_err_t rt_spi_configure(struct rt_spi_device *device, { if (device->bus->owner == device) { - device->bus->ops->configure(device, &device->config); + /* current device is using, re-configure SPI bus */ + result = device->bus->ops->configure(device, &device->config); + if (result != RT_EOK) + { + /* configure SPI bus failed */ + LOG_E("SPI device %s configuration failed", device->parent.parent.name); + } } /* release lock */ rt_mutex_release(&(device->bus->lock)); } } + else + { + result = RT_EOK; + } - return RT_EOK; + return result; } rt_err_t rt_spi_send_then_send(struct rt_spi_device *device, |
