Skip to content

Commit 9cd80bb

Browse files
Jordan Yatesmbolivar-nordic
authored andcommitted
wifi: esp_at: move network device inst macro
Move the network device instantiation macro to above the esp_init function so that static variables declared by the macro are visible to the init function. Signed-off-by: Jordan Yates <[email protected]>
1 parent 764f9fc commit 9cd80bb

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/wifi/esp_at/esp.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,17 @@ static const struct net_wifi_mgmt_offload esp_api = {
10801080
.ap_disable = esp_mgmt_ap_disable,
10811081
};
10821082

1083+
static int esp_init(const struct device *dev);
1084+
1085+
/* The network device must be instantiated above the init function in order
1086+
* for the struct net_if that the macro declares to be visible inside the
1087+
* function. An `extern` declaration does not work as the struct is static.
1088+
*/
1089+
NET_DEVICE_DT_INST_OFFLOAD_DEFINE(0, esp_init, NULL,
1090+
&esp_driver_data, NULL,
1091+
CONFIG_WIFI_INIT_PRIORITY, &esp_api,
1092+
ESP_MTU);
1093+
10831094
static int esp_init(const struct device *dev)
10841095
{
10851096
struct esp_data *data = dev->data;
@@ -1157,8 +1168,3 @@ static int esp_init(const struct device *dev)
11571168
error:
11581169
return ret;
11591170
}
1160-
1161-
NET_DEVICE_DT_INST_OFFLOAD_DEFINE(0, esp_init, NULL,
1162-
&esp_driver_data, NULL,
1163-
CONFIG_WIFI_INIT_PRIORITY, &esp_api,
1164-
ESP_MTU);

0 commit comments

Comments
 (0)