diff options
| author | iabdalkader <i.abdalkader@gmail.com> | 2023-11-02 09:10:38 +0100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-12-06 17:32:00 +1100 |
| commit | 50f31cc902d284db9f6ddbd60101608cfdbdbe7b (patch) | |
| tree | 4ef3f2e20d26c8da21b4ecc4346cba44603a3dbe /extmod/modnetwork.c | |
| parent | d30d5c99afba705e8286e9177768e0e38db59fff (diff) | |
extmod/modnetwork: Add deinit function to NIC protocol.
This is usually called on soft-reboot, a NIC can implement this to do any
necessary cleaning up (such as invalidating root pointers).
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Diffstat (limited to 'extmod/modnetwork.c')
| -rw-r--r-- | extmod/modnetwork.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/extmod/modnetwork.c b/extmod/modnetwork.c index f5734af9b..527d1729e 100644 --- a/extmod/modnetwork.c +++ b/extmod/modnetwork.c @@ -65,6 +65,15 @@ void mod_network_init(void) { } void mod_network_deinit(void) { + #if !MICROPY_PY_LWIP + for (mp_uint_t i = 0; i < MP_STATE_PORT(mod_network_nic_list).len; i++) { + mp_obj_t nic = MP_STATE_PORT(mod_network_nic_list).items[i]; + const mod_network_nic_protocol_t *nic_protocol = MP_OBJ_TYPE_GET_SLOT(mp_obj_get_type(nic), protocol); + if (nic_protocol->deinit) { + nic_protocol->deinit(); + } + } + #endif } void mod_network_register_nic(mp_obj_t nic) { |
