Skip to content

Commit bf2ba73

Browse files
committed
update(class): replace ecm & rndis USB_ERR_NOTDEV with USB_ERR_NOTCONN
Signed-off-by: sakumisu <[email protected]>
1 parent cf22bcf commit bf2ba73

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

class/cdc/usbd_cdc_ecm.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void cdc_ecm_int_in(uint8_t busid, uint8_t ep, uint32_t nbytes)
173173
int usbd_cdc_ecm_start_write(uint8_t *buf, uint32_t len)
174174
{
175175
if (!usb_device_is_configured(0)) {
176-
return -USB_ERR_NODEV;
176+
return -USB_ERR_NOTCONN;
177177
}
178178

179179
if (g_cdc_ecm_tx_data_length > 0) {
@@ -189,7 +189,7 @@ int usbd_cdc_ecm_start_write(uint8_t *buf, uint32_t len)
189189
int usbd_cdc_ecm_start_read(uint8_t *buf, uint32_t len)
190190
{
191191
if (!usb_device_is_configured(0)) {
192-
return -USB_ERR_NODEV;
192+
return -USB_ERR_NOTCONN;
193193
}
194194

195195
g_cdc_ecm_rx_data_length = 0;
@@ -222,6 +222,10 @@ int usbd_cdc_ecm_eth_tx(struct pbuf *p)
222222
struct pbuf *q;
223223
uint8_t *buffer;
224224

225+
if (!usb_device_is_configured(0)) {
226+
return -USB_ERR_NOTCONN;
227+
}
228+
225229
if (g_cdc_ecm_tx_data_length > 0) {
226230
return -USB_ERR_BUSY;
227231
}
@@ -261,8 +265,12 @@ struct usbd_interface *usbd_cdc_ecm_init_intf(struct usbd_interface *intf, const
261265
return intf;
262266
}
263267

264-
void usbd_cdc_ecm_set_connect(bool connect, uint32_t speed[2])
268+
int usbd_cdc_ecm_set_connect(bool connect, uint32_t speed[2])
265269
{
270+
if (!usb_device_is_configured(0)) {
271+
return -USB_ERR_NOTCONN;
272+
}
273+
266274
if (connect) {
267275
g_current_net_status = 2;
268276
memcpy(g_connect_speed_table, speed, 8);
@@ -271,6 +279,8 @@ void usbd_cdc_ecm_set_connect(bool connect, uint32_t speed[2])
271279
g_current_net_status = 1;
272280
usbd_cdc_ecm_send_notify(CDC_ECM_NOTIFY_CODE_NETWORK_CONNECTION, CDC_ECM_NET_DISCONNECTED, NULL);
273281
}
282+
283+
return 0;
274284
}
275285

276286
__WEAK void usbd_cdc_ecm_data_recv_done(uint32_t len)

class/cdc/usbd_cdc_ecm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern "C" {
1515
/* Init cdc ecm interface driver */
1616
struct usbd_interface *usbd_cdc_ecm_init_intf(struct usbd_interface *intf, const uint8_t int_ep, const uint8_t out_ep, const uint8_t in_ep);
1717

18-
void usbd_cdc_ecm_set_connect(bool connect, uint32_t speed[2]);
18+
int usbd_cdc_ecm_set_connect(bool connect, uint32_t speed[2]);
1919

2020
void usbd_cdc_ecm_data_recv_done(uint32_t len);
2121
void usbd_cdc_ecm_data_send_done(uint32_t len);

class/wireless/usbd_rndis.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ void rndis_int_in(uint8_t busid, uint8_t ep, uint32_t nbytes)
515515
int usbd_rndis_start_write(uint8_t *buf, uint32_t len)
516516
{
517517
if (!usb_device_is_configured(0)) {
518-
return -USB_ERR_NODEV;
518+
return -USB_ERR_NOTCONN;
519519
}
520520

521521
if (g_rndis_tx_data_length > 0) {
@@ -531,7 +531,7 @@ int usbd_rndis_start_write(uint8_t *buf, uint32_t len)
531531
int usbd_rndis_start_read(uint8_t *buf, uint32_t len)
532532
{
533533
if (!usb_device_is_configured(0)) {
534-
return -USB_ERR_NODEV;
534+
return -USB_ERR_NOTCONN;
535535
}
536536

537537
g_rndis_rx_data_buffer = buf;
@@ -569,7 +569,7 @@ int usbd_rndis_eth_tx(struct pbuf *p)
569569
uint8_t *buffer;
570570
rndis_data_packet_t *hdr;
571571

572-
if (g_usbd_rndis.link_status == NDIS_MEDIA_STATE_DISCONNECTED) {
572+
if (!usb_device_is_configured(0)) {
573573
return -USB_ERR_NOTCONN;
574574
}
575575

@@ -630,7 +630,7 @@ struct usbd_interface *usbd_rndis_init_intf(struct usbd_interface *intf,
630630
int usbd_rndis_set_connect(bool connect)
631631
{
632632
if (!usb_device_is_configured(0)) {
633-
return -USB_ERR_NODEV;
633+
return -USB_ERR_NOTCONN;
634634
}
635635

636636
if(g_usbd_rndis.set_rsp_get)

0 commit comments

Comments
 (0)