mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-12 21:40:02 +01:00
ethernet: add reference counter for mac and phy
This commit is contained in:
@@ -297,7 +297,9 @@ err:
|
||||
static esp_err_t ip101_del(esp_eth_phy_t *phy)
|
||||
{
|
||||
phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent);
|
||||
free(ip101);
|
||||
if (atomic_fetch_sub(&phy->ref_count, 1) == 1) {
|
||||
free(ip101);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -348,6 +350,7 @@ esp_eth_phy_t *esp_eth_phy_new_ip101(const eth_phy_config_t *config)
|
||||
ip101->parent.get_addr = ip101_get_addr;
|
||||
ip101->parent.set_addr = ip101_set_addr;
|
||||
ip101->parent.del = ip101_del;
|
||||
atomic_init(&ip101->parent.ref_count, 1);
|
||||
|
||||
return &(ip101->parent);
|
||||
err:
|
||||
|
||||
Reference in New Issue
Block a user