Commit 3335d98c authored by Alexander Aring's avatar Alexander Aring Committed by Marcel Holtmann

fakelb: declare rwlock static

This patch moves the rwlock declarition into a static variable.
Signed-off-by: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 9f8b97f8
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <net/cfg802154.h> #include <net/cfg802154.h>
static int numlbs = 2; static int numlbs = 2;
static DEFINE_RWLOCK(fakelb_lock);
struct fakelb_phy { struct fakelb_phy {
struct ieee802154_hw *hw; struct ieee802154_hw *hw;
...@@ -41,7 +42,6 @@ struct fakelb_phy { ...@@ -41,7 +42,6 @@ struct fakelb_phy {
struct fakelb_priv { struct fakelb_priv {
struct list_head list; struct list_head list;
rwlock_t lock;
}; };
static int static int
...@@ -79,10 +79,9 @@ static int ...@@ -79,10 +79,9 @@ static int
fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
{ {
struct fakelb_phy *current_phy = hw->priv; struct fakelb_phy *current_phy = hw->priv;
struct fakelb_priv *fake = current_phy->fake;
struct fakelb_phy *phy; struct fakelb_phy *phy;
read_lock_bh(&fake->lock); read_lock_bh(&fakelb_lock);
list_for_each_entry(phy, &current_phy->fake->list, list) { list_for_each_entry(phy, &current_phy->fake->list, list) {
if (current_phy == phy) if (current_phy == phy)
continue; continue;
...@@ -91,7 +90,7 @@ fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) ...@@ -91,7 +90,7 @@ fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
current_phy->hw->phy->current_channel) current_phy->hw->phy->current_channel)
fakelb_hw_deliver(phy, skb); fakelb_hw_deliver(phy, skb);
} }
read_unlock_bh(&fake->lock); read_unlock_bh(&fakelb_lock);
return 0; return 0;
} }
...@@ -188,9 +187,9 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) ...@@ -188,9 +187,9 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake)
if (err) if (err)
goto err_reg; goto err_reg;
write_lock_bh(&fake->lock); write_lock_bh(&fakelb_lock);
list_add_tail(&phy->list, &fake->list); list_add_tail(&phy->list, &fake->list);
write_unlock_bh(&fake->lock); write_unlock_bh(&fakelb_lock);
return 0; return 0;
...@@ -201,9 +200,9 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) ...@@ -201,9 +200,9 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake)
static void fakelb_del(struct fakelb_phy *phy) static void fakelb_del(struct fakelb_phy *phy)
{ {
write_lock_bh(&phy->fake->lock); write_lock_bh(&fakelb_lock);
list_del(&phy->list); list_del(&phy->list);
write_unlock_bh(&phy->fake->lock); write_unlock_bh(&fakelb_lock);
ieee802154_unregister_hw(phy->hw); ieee802154_unregister_hw(phy->hw);
ieee802154_free_hw(phy->hw); ieee802154_free_hw(phy->hw);
...@@ -222,7 +221,6 @@ static int fakelb_probe(struct platform_device *pdev) ...@@ -222,7 +221,6 @@ static int fakelb_probe(struct platform_device *pdev)
goto err_alloc; goto err_alloc;
INIT_LIST_HEAD(&priv->list); INIT_LIST_HEAD(&priv->list);
rwlock_init(&priv->lock);
for (i = 0; i < numlbs; i++) { for (i = 0; i < numlbs; i++) {
err = fakelb_add_one(&pdev->dev, priv); err = fakelb_add_one(&pdev->dev, priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment