Merge branch 'cleanup/netif_glue' into 'master'

netif_glue: Removed deprecated esp_eth_set_default_handlers and esp_eth_clear_default_handlers

Closes IDF-3736

See merge request espressif/esp-idf!15988
This commit is contained in:
Ondrej Kosta
2021-12-09 08:31:10 +00:00
5 changed files with 17 additions and 116 deletions

View File

@@ -1,16 +1,8 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "esp_eth.h"
@@ -42,37 +34,6 @@ esp_eth_netif_glue_handle_t esp_eth_new_netif_glue(esp_eth_handle_t eth_hdl);
*/
esp_err_t esp_eth_del_netif_glue(esp_eth_netif_glue_handle_t eth_netif_glue);
/**
* @brief Register default IP layer handlers for Ethernet
*
* @note: Ethernet handle might not yet properly initialized when setting up these default handlers
* @warning: This function is deprecated and is kept here only for compatibility reasons. Registration
* of default IP layer handlers for Ethernet is now handled automatically. Do not call this
* function if you want to use multiple Ethernet instances at a time.
*
* @param[in] esp_netif esp network interface handle created for Ethernet driver
* @return
* - ESP_ERR_INVALID_ARG: invalid parameter (esp_netif is NULL)
* - ESP_OK: set default IP layer handlers successfully
* - others: other failure occurred during register esp_event handler
*/
esp_err_t esp_eth_set_default_handlers(void *esp_netif) __attribute__ ((deprecated));
/**
* @brief Unregister default IP layer handlers for Ethernet
*
* @warning: This function is deprecated and is kept here only for compatibility reasons. Unregistration
* of default IP layer handlers for Ethernet is now handled automatically if not registered
* by calling esp_eth_set_default_handlers.
*
* @param[in] esp_netif esp network interface handle created for Ethernet driver
* @return
* - ESP_ERR_INVALID_ARG: invalid parameter (esp_netif is NULL)
* - ESP_OK: clear default IP layer handlers successfully
* - others: other failure occurred during unregister esp_event handler
*/
esp_err_t esp_eth_clear_default_handlers(void *esp_netif);
#ifdef __cplusplus
}
#endif

View File

@@ -1,16 +1,8 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdlib.h>
#include "esp_netif.h"
#include "esp_eth.h"
@@ -66,61 +58,6 @@ static esp_err_t esp_eth_post_attach(esp_netif_t *esp_netif, void *args)
return ESP_OK;
}
esp_err_t esp_eth_clear_default_handlers(void *esp_netif)
{
ESP_RETURN_ON_FALSE(esp_netif, ESP_ERR_INVALID_ARG, TAG, "esp_netif handle can't be null");
esp_event_handler_unregister(ETH_EVENT, ETHERNET_EVENT_START, esp_netif_action_start);
esp_event_handler_unregister(ETH_EVENT, ETHERNET_EVENT_STOP, esp_netif_action_stop);
esp_event_handler_unregister(ETH_EVENT, ETHERNET_EVENT_CONNECTED, esp_netif_action_connected);
esp_event_handler_unregister(ETH_EVENT, ETHERNET_EVENT_DISCONNECTED, esp_netif_action_disconnected);
esp_event_handler_unregister(IP_EVENT, IP_EVENT_ETH_GOT_IP, esp_netif_action_got_ip);
s_netif_glue_legacy_events_registered = false;
return ESP_OK;
}
esp_err_t esp_eth_set_default_handlers(void *esp_netif)
{
esp_err_t ret;
ESP_RETURN_ON_FALSE(esp_netif, ESP_ERR_INVALID_ARG, TAG, "esp_netif handle can't be null");
ret = esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_START, esp_netif_action_start, esp_netif);
if (ret != ESP_OK) {
goto fail;
}
ret = esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_STOP, esp_netif_action_stop, esp_netif);
if (ret != ESP_OK) {
goto fail;
}
ret = esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_CONNECTED, esp_netif_action_connected, esp_netif);
if (ret != ESP_OK) {
goto fail;
}
ret = esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_DISCONNECTED, esp_netif_action_disconnected, esp_netif);
if (ret != ESP_OK) {
goto fail;
}
ret = esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, esp_netif_action_got_ip, esp_netif);
if (ret != ESP_OK) {
goto fail;
}
s_netif_glue_legacy_events_registered = true;
return ESP_OK;
fail:
esp_eth_clear_default_handlers(esp_netif);
return ret;
}
static void eth_action_start(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data)
{
esp_eth_handle_t eth_handle = *(esp_eth_handle_t *)event_data;

View File

@@ -186,7 +186,6 @@ static void ethernet_deinit(test_vfs_eth_network_t *network_hndls)
TEST_ESP_OK(network_hndls->mac->del(network_hndls->mac));
TEST_ESP_OK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_ETH_GOT_IP, got_ip_event_handler));
TEST_ESP_OK(esp_event_handler_unregister(ETH_EVENT, ESP_EVENT_ANY_ID, eth_event_handler));
TEST_ESP_OK(esp_eth_clear_default_handlers(network_hndls->eth_netif));
esp_netif_destroy(network_hndls->eth_netif);
TEST_ESP_OK(esp_event_loop_delete_default());
}