OSDN Git Service

fakelb: declare fakelb list static
authorAlexander Aring <alex.aring@gmail.com>
Sun, 17 May 2015 19:45:03 +0000 (21:45 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 19 May 2015 09:44:45 +0000 (11:44 +0200)
This patch moves the fakelb list of all registered phy's in a static
declaration in the fakelb driver.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/net/ieee802154/fakelb.c

index 43370fb..c7e7d50 100644 (file)
 
 static int numlbs = 2;
 static DEFINE_RWLOCK(fakelb_lock);
+static LIST_HEAD(fakelb_phys);
 
 struct fakelb_phy {
        struct ieee802154_hw *hw;
 
        struct list_head list;
-       struct fakelb_priv *fake;
 
        spinlock_t lock;
        bool working;
 };
 
-struct fakelb_priv {
-       struct list_head list;
-};
-
 static int
 fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level)
 {
@@ -82,7 +78,7 @@ fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
        struct fakelb_phy *phy;
 
        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)
                        continue;
 
@@ -132,7 +128,7 @@ static const struct ieee802154_ops fakelb_ops = {
 module_param(numlbs, int, 0);
 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;
        int err;
@@ -176,9 +172,6 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake)
        /* 950 MHz GFSK 802.15.4d-2009 */
        hw->phy->supported.channels[6] |= 0x3ffc00;
 
-       INIT_LIST_HEAD(&phy->list);
-       phy->fake = fake;
-
        spin_lock_init(&phy->lock);
 
        hw->parent = dev;
@@ -188,7 +181,7 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake)
                goto err_reg;
 
        write_lock_bh(&fakelb_lock);
-       list_add_tail(&phy->list, &fake->list);
+       list_add_tail(&phy->list, &fakelb_phys);
        write_unlock_bh(&fakelb_lock);
 
        return 0;
@@ -210,41 +203,30 @@ static void fakelb_del(struct fakelb_phy *phy)
 
 static int fakelb_probe(struct platform_device *pdev)
 {
-       struct fakelb_priv *priv;
        struct fakelb_phy *phy, *tmp;
        int err = -ENOMEM;
        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++) {
-               err = fakelb_add_one(&pdev->dev, priv);
+               err = fakelb_add_one(&pdev->dev);
                if (err < 0)
                        goto err_slave;
        }
 
-       platform_set_drvdata(pdev, priv);
        dev_info(&pdev->dev, "added ieee802154 hardware\n");
        return 0;
 
 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);
-err_alloc:
        return err;
 }
 
 static int fakelb_remove(struct platform_device *pdev)
 {
-       struct fakelb_priv *priv = platform_get_drvdata(pdev);
        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);
 
        return 0;