Skip to content

Commit 5b9ea24

Browse files
jerome-pouillerjhedberg
authored andcommitted
drivers: wifi: siwx917: Simplify #ifdef
Some #ifdef can be easily changed in IS_ENABLED(). Signed-off-by: Jérôme Pouiller <[email protected]>
1 parent 8d9c289 commit 5b9ea24

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

drivers/wifi/siwx917/siwx917_wifi.c

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ static unsigned int siwx917_on_join(sl_wifi_event_t event,
3535

3636
wifi_mgmt_raise_connect_result_event(sidev->iface, WIFI_STATUS_CONN_SUCCESS);
3737
sidev->state = WIFI_STATE_COMPLETED;
38-
#ifndef CONFIG_WIFI_SIWX917_NET_STACK_OFFLOAD
39-
net_eth_carrier_on(sidev->iface);
40-
#endif
38+
39+
if (IS_ENABLED(CONFIG_WIFI_SIWX917_NET_STACK_NATIVE)) {
40+
net_eth_carrier_on(sidev->iface);
41+
}
4142

4243
siwx917_on_join_ipv4(sidev);
4344
siwx917_on_join_ipv6(sidev);
@@ -130,9 +131,9 @@ static int siwx917_disconnect(const struct device *dev)
130131
if (ret) {
131132
return -EIO;
132133
}
133-
#ifndef CONFIG_WIFI_SIWX917_NET_STACK_OFFLOAD
134-
net_eth_carrier_off(sidev->iface);
135-
#endif
134+
if (IS_ENABLED(CONFIG_WIFI_SIWX917_NET_STACK_NATIVE)) {
135+
net_eth_carrier_off(sidev->iface);
136+
}
136137
sidev->state = WIFI_STATE_INACTIVE;
137138
return 0;
138139
}
@@ -229,7 +230,7 @@ static int siwx917_status(const struct device *dev, struct wifi_iface_status *st
229230
return 0;
230231
}
231232

232-
#ifndef CONFIG_WIFI_SIWX917_NET_STACK_OFFLOAD
233+
#ifdef CONFIG_WIFI_SIWX917_NET_STACK_NATIVE
233234

234235
static int siwx917_send(const struct device *dev, struct net_pkt *pkt)
235236
{
@@ -297,13 +298,13 @@ sl_status_t sl_si91x_host_process_data_frame(sl_wifi_interface_t interface,
297298

298299
static void siwx917_ethernet_init(struct net_if *iface)
299300
{
300-
#ifndef CONFIG_WIFI_SIWX917_NET_STACK_OFFLOAD
301301
struct ethernet_context *eth_ctx;
302302

303-
eth_ctx = net_if_l2_data(iface);
304-
eth_ctx->eth_if_type = L2_ETH_IF_TYPE_WIFI;
305-
ethernet_init(iface);
306-
#endif
303+
if (IS_ENABLED(CONFIG_WIFI_SIWX917_NET_STACK_NATIVE)) {
304+
eth_ctx = net_if_l2_data(iface);
305+
eth_ctx->eth_if_type = L2_ETH_IF_TYPE_WIFI;
306+
ethernet_init(iface);
307+
}
307308
}
308309

309310
static void siwx917_iface_init(struct net_if *iface)
@@ -344,19 +345,19 @@ static const struct wifi_mgmt_ops siwx917_mgmt = {
344345

345346
static const struct net_wifi_mgmt_offload siwx917_api = {
346347
.wifi_iface.iface_api.init = siwx917_iface_init,
347-
#ifdef CONFIG_WIFI_SIWX917_NET_STACK_OFFLOAD
348-
.wifi_iface.get_type = siwx917_get_type,
349-
#else
348+
#ifdef CONFIG_WIFI_SIWX917_NET_STACK_NATIVE
350349
.wifi_iface.send = siwx917_send,
350+
#else
351+
.wifi_iface.get_type = siwx917_get_type,
351352
#endif
352353
.wifi_mgmt_api = &siwx917_mgmt,
353354
};
354355

355356
static struct siwx917_dev siwx917_dev;
356-
#ifdef CONFIG_WIFI_SIWX917_NET_STACK_OFFLOAD
357-
NET_DEVICE_DT_INST_OFFLOAD_DEFINE(0, siwx917_dev_init, NULL, &siwx917_dev, NULL,
358-
CONFIG_WIFI_INIT_PRIORITY, &siwx917_api, NET_ETH_MTU);
359-
#else
357+
#ifdef CONFIG_WIFI_SIWX917_NET_STACK_NATIVE
360358
ETH_NET_DEVICE_DT_INST_DEFINE(0, siwx917_dev_init, NULL, &siwx917_dev, NULL,
361359
CONFIG_WIFI_INIT_PRIORITY, &siwx917_api, NET_ETH_MTU);
360+
#else
361+
NET_DEVICE_DT_INST_OFFLOAD_DEFINE(0, siwx917_dev_init, NULL, &siwx917_dev, NULL,
362+
CONFIG_WIFI_INIT_PRIORITY, &siwx917_api, NET_ETH_MTU);
362363
#endif

0 commit comments

Comments
 (0)