Skip to content

Commit f2aac10

Browse files
committed
usb: device_next: usbd_cdc_ncm: correct net_if_carrier use
net_if_carrier is to be used independently of the administrative state (start and stop of the ethernet_api). This seem to work. Signed-off-by: Fin Maaß <[email protected]>
1 parent 7fb1fa2 commit f2aac10

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

subsys/usb/device_next/class/usbd_cdc_ncm.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ static void ncm_handle_notifications(const struct device *dev, const int err)
635635
if (data->if_state == IF_STATE_CONNECTION_STATUS_SUBMITTED) {
636636
data->if_state = IF_STATE_CONNECTION_STATUS_SENT;
637637
LOG_INF("Connection status sent");
638+
net_if_carrier_on(data->iface);
638639
}
639640
}
640641

@@ -840,6 +841,7 @@ static void usbd_cdc_ncm_update(struct usbd_class_data *const c_data,
840841

841842
if (data_iface == iface && alternate == 0) {
842843
atomic_clear_bit(&data->state, CDC_NCM_DATA_IFACE_ENABLED);
844+
net_if_carrier_off(data->iface);
843845
data->tx_seq = 0;
844846
data->rx_seq = 0;
845847
}
@@ -868,6 +870,8 @@ static void usbd_cdc_ncm_disable(struct usbd_class_data *const c_data)
868870
atomic_clear_bit(&data->state, CDC_NCM_DATA_IFACE_ENABLED);
869871
atomic_clear_bit(&data->state, CDC_NCM_CLASS_SUSPENDED);
870872

873+
net_if_carrier_off(data->iface);
874+
871875
LOG_INF("Disabled %s", c_data->name);
872876
}
873877

@@ -1123,7 +1127,6 @@ static int cdc_ncm_iface_start(const struct device *dev)
11231127
LOG_DBG("Start interface %d", net_if_get_by_iface(data->iface));
11241128

11251129
atomic_set_bit(&data->state, CDC_NCM_IFACE_UP);
1126-
net_if_carrier_on(data->iface);
11271130

11281131
if (atomic_test_bit(&data->state, CDC_NCM_DATA_IFACE_ENABLED)) {
11291132
(void)k_work_reschedule(&data->notif_work, K_MSEC(1));

0 commit comments

Comments
 (0)