1.优化代码。

This commit is contained in:
MacRsh
2023-10-04 00:26:44 +08:00
parent 0b5b9fd8f7
commit 46d10954ac
2 changed files with 7 additions and 12 deletions

View File

@@ -190,15 +190,12 @@ static mr_err_t mr_i2c_device_ioctl(mr_device_t device, int cmd, void *args)
if (config->host_slave != i2c_device->config.host_slave)
{
if (config->host_slave == MR_I2C_HOST)
if (i2c_device->bus != MR_NULL)
{
if (i2c_device->bus != MR_NULL)
if (config->host_slave == MR_I2C_HOST)
{
mr_i2c_device_release_bus(i2c_device);
}
} else
{
if (i2c_device->bus != MR_NULL)
} else
{
/* Slave mode monopolizes the bus */
ret = mr_i2c_device_take_bus(i2c_device);