From cbf33f48d8bfbef87bd31190b56bbaba68b98bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Pouiller?= Date: Tue, 15 Oct 2024 16:56:50 +0200 Subject: [PATCH] drivers: wifi: siwx917: Simplify #ifdef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some #ifdef can be easily changed in IS_ENABLED(). Signed-off-by: Jérôme Pouiller --- drivers/wifi/siwx917/siwx917_wifi.c | 39 +++++++++++++++-------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/wifi/siwx917/siwx917_wifi.c b/drivers/wifi/siwx917/siwx917_wifi.c index 3059a43..14093fb 100644 --- a/drivers/wifi/siwx917/siwx917_wifi.c +++ b/drivers/wifi/siwx917/siwx917_wifi.c @@ -35,9 +35,10 @@ static unsigned int siwx917_on_join(sl_wifi_event_t event, wifi_mgmt_raise_connect_result_event(sidev->iface, WIFI_STATUS_CONN_SUCCESS); sidev->state = WIFI_STATE_COMPLETED; -#ifndef CONFIG_WIFI_SIWX917_NET_STACK_OFFLOAD - net_eth_carrier_on(sidev->iface); -#endif + + if (IS_ENABLED(CONFIG_WIFI_SIWX917_NET_STACK_NATIVE)) { + net_eth_carrier_on(sidev->iface); + } siwx917_on_join_ipv4(sidev); siwx917_on_join_ipv6(sidev); @@ -130,9 +131,9 @@ static int siwx917_disconnect(const struct device *dev) if (ret) { return -EIO; } -#ifndef CONFIG_WIFI_SIWX917_NET_STACK_OFFLOAD - net_eth_carrier_off(sidev->iface); -#endif + if (IS_ENABLED(CONFIG_WIFI_SIWX917_NET_STACK_NATIVE)) { + net_eth_carrier_off(sidev->iface); + } sidev->state = WIFI_STATE_INACTIVE; return 0; } @@ -229,7 +230,7 @@ static int siwx917_status(const struct device *dev, struct wifi_iface_status *st return 0; } -#ifndef CONFIG_WIFI_SIWX917_NET_STACK_OFFLOAD +#ifdef CONFIG_WIFI_SIWX917_NET_STACK_NATIVE static int siwx917_send(const struct device *dev, struct net_pkt *pkt) { @@ -297,13 +298,13 @@ sl_status_t sl_si91x_host_process_data_frame(sl_wifi_interface_t interface, static void siwx917_ethernet_init(struct net_if *iface) { -#ifndef CONFIG_WIFI_SIWX917_NET_STACK_OFFLOAD struct ethernet_context *eth_ctx; - eth_ctx = net_if_l2_data(iface); - eth_ctx->eth_if_type = L2_ETH_IF_TYPE_WIFI; - ethernet_init(iface); -#endif + if (IS_ENABLED(CONFIG_WIFI_SIWX917_NET_STACK_NATIVE)) { + eth_ctx = net_if_l2_data(iface); + eth_ctx->eth_if_type = L2_ETH_IF_TYPE_WIFI; + ethernet_init(iface); + } } static void siwx917_iface_init(struct net_if *iface) @@ -344,19 +345,19 @@ static const struct wifi_mgmt_ops siwx917_mgmt = { static const struct net_wifi_mgmt_offload siwx917_api = { .wifi_iface.iface_api.init = siwx917_iface_init, -#ifdef CONFIG_WIFI_SIWX917_NET_STACK_OFFLOAD - .wifi_iface.get_type = siwx917_get_type, -#else +#ifdef CONFIG_WIFI_SIWX917_NET_STACK_NATIVE .wifi_iface.send = siwx917_send, +#else + .wifi_iface.get_type = siwx917_get_type, #endif .wifi_mgmt_api = &siwx917_mgmt, }; static struct siwx917_dev siwx917_dev; -#ifdef CONFIG_WIFI_SIWX917_NET_STACK_OFFLOAD -NET_DEVICE_DT_INST_OFFLOAD_DEFINE(0, siwx917_dev_init, NULL, &siwx917_dev, NULL, - CONFIG_WIFI_INIT_PRIORITY, &siwx917_api, NET_ETH_MTU); -#else +#ifdef CONFIG_WIFI_SIWX917_NET_STACK_NATIVE ETH_NET_DEVICE_DT_INST_DEFINE(0, siwx917_dev_init, NULL, &siwx917_dev, NULL, CONFIG_WIFI_INIT_PRIORITY, &siwx917_api, NET_ETH_MTU); +#else +NET_DEVICE_DT_INST_OFFLOAD_DEFINE(0, siwx917_dev_init, NULL, &siwx917_dev, NULL, + CONFIG_WIFI_INIT_PRIORITY, &siwx917_api, NET_ETH_MTU); #endif