summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorzms123456 <[email protected]>2024-09-14 05:32:35 +0800
committerGitHub <[email protected]>2024-09-13 17:32:35 -0400
commit140ca0d2ff1f776632766aba135c3b5a282bad22 (patch)
tree888c42bd93ba22cbc8df865d8855f2d1f2c77f00 /components
parentfb02e7934db9c6fe75df9c6fb7064b4132934845 (diff)
[components][sal]replace netdev's spin_lock_irqsave to spin_lock
netdev的函数不会在中断中调用,无需关中断
Diffstat (limited to 'components')
-rw-r--r--components/net/netdev/src/netdev.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/components/net/netdev/src/netdev.c b/components/net/netdev/src/netdev.c
index e6398cf02e..8d21db756c 100644
--- a/components/net/netdev/src/netdev.c
+++ b/components/net/netdev/src/netdev.c
@@ -55,7 +55,6 @@ static RT_DEFINE_SPINLOCK(_spinlock);
*/
int netdev_register(struct netdev *netdev, const char *name, void *user_data)
{
- rt_base_t level;
rt_uint16_t flags_mask;
rt_uint16_t index;
@@ -103,7 +102,7 @@ int netdev_register(struct netdev *netdev, const char *name, void *user_data)
/* initialize current network interface device single list */
rt_slist_init(&(netdev->list));
- level = rt_spin_lock_irqsave(&_spinlock);
+ rt_spin_lock(&_spinlock);
if (netdev_list == RT_NULL)
{
@@ -115,7 +114,7 @@ int netdev_register(struct netdev *netdev, const char *name, void *user_data)
rt_slist_append(&(netdev_list->list), &(netdev->list));
}
- rt_spin_unlock_irqrestore(&_spinlock, level);
+ rt_spin_unlock(&_spinlock);
if (netdev_default == RT_NULL)
{
@@ -146,7 +145,6 @@ int netdev_register(struct netdev *netdev, const char *name, void *user_data)
*/
int netdev_unregister(struct netdev *netdev)
{
- rt_base_t level;
rt_slist_t *node = RT_NULL;
struct netdev *cur_netdev = RT_NULL;
@@ -157,7 +155,7 @@ int netdev_unregister(struct netdev *netdev)
return -RT_ERROR;
}
- level = rt_spin_lock_irqsave(&_spinlock);
+ rt_spin_lock(&_spinlock);
for (node = &(netdev_list->list); node; node = rt_slist_next(node))
{
@@ -188,7 +186,7 @@ int netdev_unregister(struct netdev *netdev)
break;
}
}
- rt_spin_unlock_irqrestore(&_spinlock, level);
+ rt_spin_unlock(&_spinlock);
#if defined(SAL_USING_AF_NETLINK)
rtnl_ip_notify(netdev, RTM_DELLINK);
@@ -233,7 +231,6 @@ void netdev_set_register_callback(netdev_callback_fn register_callback)
*/
struct netdev *netdev_get_first_by_flags(uint16_t flags)
{
- rt_base_t level;
rt_slist_t *node = RT_NULL;
struct netdev *netdev = RT_NULL;
@@ -242,19 +239,19 @@ struct netdev *netdev_get_first_by_flags(uint16_t flags)
return RT_NULL;
}
- level = rt_spin_lock_irqsave(&_spinlock);
+ rt_spin_lock(&_spinlock);
for (node = &(netdev_list->list); node; node = rt_slist_next(node))
{
netdev = rt_slist_entry(node, struct netdev, list);
if (netdev && (netdev->flags & flags) != 0)
{
- rt_spin_unlock_irqrestore(&_spinlock, level);
+ rt_spin_unlock(&_spinlock);
return netdev;
}
}
- rt_spin_unlock_irqrestore(&_spinlock, level);
+ rt_spin_unlock(&_spinlock);
return RT_NULL;
}
@@ -270,7 +267,6 @@ struct netdev *netdev_get_first_by_flags(uint16_t flags)
*/
struct netdev *netdev_get_by_ipaddr(ip_addr_t *ip_addr)
{
- rt_base_t level;
rt_slist_t *node = RT_NULL;
struct netdev *netdev = RT_NULL;
@@ -279,19 +275,19 @@ struct netdev *netdev_get_by_ipaddr(ip_addr_t *ip_addr)
return RT_NULL;
}
- level = rt_spin_lock_irqsave(&_spinlock);
+ rt_spin_lock(&_spinlock);
for (node = &(netdev_list->list); node; node = rt_slist_next(node))
{
netdev = rt_slist_entry(node, struct netdev, list);
if (netdev && ip_addr_cmp(&(netdev->ip_addr), ip_addr))
{
- rt_spin_unlock_irqrestore(&_spinlock, level);
+ rt_spin_unlock(&_spinlock);
return netdev;
}
}
- rt_spin_unlock_irqrestore(&_spinlock, level);
+ rt_spin_unlock(&_spinlock);
return RT_NULL;
}
@@ -307,7 +303,6 @@ struct netdev *netdev_get_by_ipaddr(ip_addr_t *ip_addr)
*/
struct netdev *netdev_get_by_name(const char *name)
{
- rt_base_t level;
rt_slist_t *node = RT_NULL;
struct netdev *netdev = RT_NULL;
@@ -316,19 +311,19 @@ struct netdev *netdev_get_by_name(const char *name)
return RT_NULL;
}
- level = rt_spin_lock_irqsave(&_spinlock);
+ rt_spin_lock(&_spinlock);
for (node = &(netdev_list->list); node; node = rt_slist_next(node))
{
netdev = rt_slist_entry(node, struct netdev, list);
if (netdev && (rt_strncmp(netdev->name, name, rt_strlen(name) < RT_NAME_MAX ? rt_strlen(name) : RT_NAME_MAX) == 0))
{
- rt_spin_unlock_irqrestore(&_spinlock, level);
+ rt_spin_unlock(&_spinlock);
return netdev;
}
}
- rt_spin_unlock_irqrestore(&_spinlock, level);
+ rt_spin_unlock(&_spinlock);
return RT_NULL;
}
@@ -345,7 +340,6 @@ struct netdev *netdev_get_by_name(const char *name)
*/
struct netdev *netdev_get_by_family(int family)
{
- rt_base_t level;
rt_slist_t *node = RT_NULL;
struct netdev *netdev = RT_NULL;
struct sal_proto_family *pf = RT_NULL;
@@ -355,7 +349,7 @@ struct netdev *netdev_get_by_family(int family)
return RT_NULL;
}
- level = rt_spin_lock_irqsave(&_spinlock);
+ rt_spin_lock(&_spinlock);
for (node = &(netdev_list->list); node; node = rt_slist_next(node))
{
@@ -363,7 +357,7 @@ struct netdev *netdev_get_by_family(int family)
pf = (struct sal_proto_family *) netdev->sal_user_data;
if (pf && pf->skt_ops && pf->family == family && netdev_is_up(netdev))
{
- rt_spin_unlock_irqrestore(&_spinlock, level);
+ rt_spin_unlock(&_spinlock);
return netdev;
}
}
@@ -374,12 +368,12 @@ struct netdev *netdev_get_by_family(int family)
pf = (struct sal_proto_family *) netdev->sal_user_data;
if (pf && pf->skt_ops && pf->sec_family == family && netdev_is_up(netdev))
{
- rt_spin_unlock_irqrestore(&_spinlock, level);
+ rt_spin_unlock(&_spinlock);
return netdev;
}
}
- rt_spin_unlock_irqrestore(&_spinlock, level);
+ rt_spin_unlock(&_spinlock);
return RT_NULL;
}