Revert "arch: Don't free the context if the reference doesn't equal zero"

struct stm32_i2c_inst_s instance is allocated on every call to
stm32_i2cbus_initialize, and that instance is supposed to be deleted on every
call to stm32_i2cbus_uninitialize.

The "refs" counter just keeps track on when the last one is deleted, and
everything is unregisterd/disabled.

This reverts commit 8098c80338.
This commit is contained in:
Jukka Laitinen 2023-01-13 17:03:34 +04:00 committed by Xiang Xiao
parent ee9787a254
commit f9c8b4015f
6 changed files with 6 additions and 0 deletions

View File

@ -2804,6 +2804,7 @@ int stm32_i2cbus_uninitialize(struct i2c_master_s *dev)
if (--priv->refs)
{
nxmutex_unlock(&priv->lock);
kmm_free(dev);
return OK;
}

View File

@ -2803,6 +2803,7 @@ int stm32_i2cbus_uninitialize(struct i2c_master_s *dev)
if (--priv->refs)
{
nxmutex_unlock(&priv->lock);
kmm_free(dev);
return OK;
}

View File

@ -2842,6 +2842,7 @@ int stm32_i2cbus_uninitialize(struct i2c_master_s *dev)
if (--priv->refs)
{
nxmutex_unlock(&priv->lock);
kmm_free(dev);
return OK;
}

View File

@ -2805,6 +2805,7 @@ int stm32_i2cbus_uninitialize(struct i2c_master_s *dev)
if (--priv->refs)
{
nxmutex_unlock(&priv->lock);
kmm_free(dev);
return OK;
}

View File

@ -1247,6 +1247,7 @@ int stm32l4_1wireuninitialize(struct onewire_dev_s *dev)
if (--priv->refs)
{
nxmutex_unlock(&priv->lock);
kmm_free(priv);
return OK;
}

View File

@ -3007,6 +3007,7 @@ int stm32l4_i2cbus_uninitialize(struct i2c_master_s *dev)
if (--priv->refs)
{
nxmutex_unlock(&priv->lock);
kmm_free(dev);
return OK;
}