Commit b82b99f1 authored by Alexander Aring's avatar Alexander Aring Committed by Marcel Holtmann

fakelb: declare fakelb list static

This patch moves the fakelb list of all registered phy's in a static
declaration in the fakelb driver.
Signed-off-by: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 3335d98c
...@@ -29,21 +29,17 @@ ...@@ -29,21 +29,17 @@
static int numlbs = 2; static int numlbs = 2;
static DEFINE_RWLOCK(fakelb_lock); static DEFINE_RWLOCK(fakelb_lock);
static LIST_HEAD(fakelb_phys);
struct fakelb_phy { struct fakelb_phy {
struct ieee802154_hw *hw; struct ieee802154_hw *hw;
struct list_head list; struct list_head list;
struct fakelb_priv *fake;
spinlock_t lock; spinlock_t lock;
bool working; bool working;
}; };
struct fakelb_priv {
struct list_head list;
};
static int static int
fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level) fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level)
{ {
...@@ -82,7 +78,7 @@ fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) ...@@ -82,7 +78,7 @@ fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
struct fakelb_phy *phy; struct fakelb_phy *phy;
read_lock_bh(&fakelb_lock); read_lock_bh(&fakelb_lock);
list_for_each_entry(phy, &current_phy->fake->list, list) { list_for_each_entry(phy, &fakelb_phys, list) {
if (current_phy == phy) if (current_phy == phy)
continue; continue;
...@@ -132,7 +128,7 @@ static const struct ieee802154_ops fakelb_ops = { ...@@ -132,7 +128,7 @@ static const struct ieee802154_ops fakelb_ops = {
module_param(numlbs, int, 0); module_param(numlbs, int, 0);
MODULE_PARM_DESC(numlbs, " number of pseudo devices"); MODULE_PARM_DESC(numlbs, " number of pseudo devices");
static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) static int fakelb_add_one(struct device *dev)
{ {
struct fakelb_phy *phy; struct fakelb_phy *phy;
int err; int err;
...@@ -176,9 +172,6 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) ...@@ -176,9 +172,6 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake)
/* 950 MHz GFSK 802.15.4d-2009 */ /* 950 MHz GFSK 802.15.4d-2009 */
hw->phy->supported.channels[6] |= 0x3ffc00; hw->phy->supported.channels[6] |= 0x3ffc00;
INIT_LIST_HEAD(&phy->list);
phy->fake = fake;
spin_lock_init(&phy->lock); spin_lock_init(&phy->lock);
hw->parent = dev; hw->parent = dev;
...@@ -188,7 +181,7 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) ...@@ -188,7 +181,7 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake)
goto err_reg; goto err_reg;
write_lock_bh(&fakelb_lock); write_lock_bh(&fakelb_lock);
list_add_tail(&phy->list, &fake->list); list_add_tail(&phy->list, &fakelb_phys);
write_unlock_bh(&fakelb_lock); write_unlock_bh(&fakelb_lock);
return 0; return 0;
...@@ -210,41 +203,30 @@ static void fakelb_del(struct fakelb_phy *phy) ...@@ -210,41 +203,30 @@ static void fakelb_del(struct fakelb_phy *phy)
static int fakelb_probe(struct platform_device *pdev) static int fakelb_probe(struct platform_device *pdev)
{ {
struct fakelb_priv *priv;
struct fakelb_phy *phy, *tmp; struct fakelb_phy *phy, *tmp;
int err = -ENOMEM; int err = -ENOMEM;
int i; int i;
priv = devm_kzalloc(&pdev->dev, sizeof(struct fakelb_priv),
GFP_KERNEL);
if (!priv)
goto err_alloc;
INIT_LIST_HEAD(&priv->list);
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);
if (err < 0) if (err < 0)
goto err_slave; goto err_slave;
} }
platform_set_drvdata(pdev, priv);
dev_info(&pdev->dev, "added ieee802154 hardware\n"); dev_info(&pdev->dev, "added ieee802154 hardware\n");
return 0; return 0;
err_slave: err_slave:
list_for_each_entry_safe(phy, tmp, &priv->list, list) list_for_each_entry_safe(phy, tmp, &fakelb_phys, list)
fakelb_del(phy); fakelb_del(phy);
err_alloc:
return err; return err;
} }
static int fakelb_remove(struct platform_device *pdev) static int fakelb_remove(struct platform_device *pdev)
{ {
struct fakelb_priv *priv = platform_get_drvdata(pdev);
struct fakelb_phy *phy, *temp; struct fakelb_phy *phy, *temp;
list_for_each_entry_safe(phy, temp, &priv->list, list) list_for_each_entry_safe(phy, temp, &fakelb_phys, list)
fakelb_del(phy); fakelb_del(phy);
return 0; return 0;
......
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