-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[componentss][net][lwip][port] #10793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -496,11 +496,14 @@ static err_t eth_netif_device_init(struct netif *netif) | |
| device = (rt_device_t) ethif; | ||
| if (rt_device_init(device) != RT_EOK) | ||
| { | ||
| return ERR_IF; | ||
| rt_kprintf("eth device initialization failed!\n"); | ||
| } | ||
| if (rt_device_open(device, RT_DEVICE_FLAG_RDWR) != RT_EOK) | ||
| else | ||
| { | ||
| return ERR_IF; | ||
| if (rt_device_open(device, RT_DEVICE_FLAG_RDWR) != RT_EOK) | ||
| { | ||
| rt_kprintf("eth device open failed!\n"); | ||
| } | ||
|
Comment on lines
500
to
+506
|
||
| } | ||
|
|
||
| /* copy device flags to netif flags */ | ||
|
|
@@ -684,11 +687,14 @@ static err_t af_unix_eth_netif_device_init(struct netif *netif) | |
| device = (rt_device_t) ethif; | ||
| if (rt_device_init(device) != RT_EOK) | ||
| { | ||
| return ERR_IF; | ||
| rt_kprintf("eth device initialization failed!\n"); | ||
| } | ||
| if (rt_device_open(device, RT_DEVICE_FLAG_RDWR) != RT_EOK) | ||
| else | ||
| { | ||
| return ERR_IF; | ||
| if (rt_device_open(device, RT_DEVICE_FLAG_RDWR) != RT_EOK) | ||
| { | ||
| rt_kprintf("eth device open failed!\n"); | ||
| } | ||
| } | ||
|
|
||
| /* copy device flags to netif flags */ | ||
|
|
@@ -850,23 +856,65 @@ rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up) | |
|
|
||
| RT_ASSERT(dev != RT_NULL); | ||
|
|
||
| struct eth_device* enetif = (struct eth_device*)dev->netif->state; | ||
| rt_device_t device = (rt_device_t)(&(enetif->parent)); | ||
|
|
||
| level = rt_spin_lock_irqsave(&(dev->spinlock)); | ||
| dev->link_changed = 0x01; | ||
| if (up == RT_TRUE) | ||
| { | ||
| /* @note Check whether the eth device was successfully initialized, otherwise re-initialize */ | ||
| if (!(device->flag & RT_DEVICE_FLAG_ACTIVATED)) | ||
| { | ||
| if (rt_device_init(device) != RT_EOK) | ||
| { | ||
| rt_kprintf("eth device initialization failed!\n"); | ||
| goto err; | ||
| } | ||
| if (rt_device_open(device, RT_DEVICE_FLAG_RDWR) != RT_EOK) | ||
| { | ||
| rt_kprintf("eth device open failed!\n"); | ||
| goto err; | ||
| } | ||
| } | ||
| dev->link_status = 0x01; | ||
| } | ||
| else | ||
| dev->link_status = 0x00; | ||
| rt_spin_unlock_irqrestore(&(dev->spinlock), level); | ||
|
|
||
| /* post message to ethernet thread */ | ||
| return rt_mb_send(ð_rx_thread_mb, (rt_ubase_t)dev); | ||
|
|
||
| err: | ||
| rt_spin_unlock_irqrestore(&(dev->spinlock), level); | ||
| return -RT_ERROR; | ||
| } | ||
| #else | ||
| /* NOTE: please not use it in interrupt when no RxThread exist */ | ||
| rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up) | ||
| { | ||
| struct eth_device* enetif = (struct eth_device*)dev->netif->state; | ||
| rt_device_t device = (rt_device_t)(&(enetif->parent)); | ||
|
|
||
| if (up == RT_TRUE) | ||
| { | ||
| /* @note Check whether the eth device was successfully initialized, otherwise re-initialize */ | ||
| if (!(device->flag & RT_DEVICE_FLAG_ACTIVATED)) | ||
|
||
| { | ||
| if (rt_device_init(device) != RT_EOK) | ||
| { | ||
| rt_kprintf("eth device initialization failed!\n"); | ||
| return -RT_ERROR; | ||
| } | ||
| if (rt_device_open(device, RT_DEVICE_FLAG_RDWR) != RT_EOK) | ||
| { | ||
| rt_kprintf("eth device open failed!\n"); | ||
| return -RT_ERROR; | ||
| } | ||
| } | ||
| netifapi_netif_set_link_up(dev->netif); | ||
| } | ||
| else | ||
| netifapi_netif_set_link_down(dev->netif); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the initialization case, removing the error return from device open failure removes important error information from the caller. The function should indicate failure when critical operations like device opening fail. / 与初始化情况类似,从设备打开失败中移除错误返回会从调用者那里移除重要的错误信息。当设备打开等关键操作失败时,函数应该指示失败。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Maihuanyi 这块不需要错误返回?