summaryrefslogtreecommitdiffstats
path: root/drivers/net/ieee802154/fakelb.c
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2015-05-17 21:45:00 +0200
committerMarcel Holtmann <marcel@holtmann.org>2015-05-19 11:44:45 +0200
commitdb3f5d0df9af1e5965e64595595a6a719c42fcf3 (patch)
tree7cdf0810fe94d47175d03b1764b92c64d3df80cb /drivers/net/ieee802154/fakelb.c
parentfakelb: use list_for_each_entry_safe (diff)
downloadlinux-db3f5d0df9af1e5965e64595595a6a719c42fcf3.tar.xz
linux-db3f5d0df9af1e5965e64595595a6a719c42fcf3.zip
fakelb: rename fakelb_dev_priv to fakelb_phy
This patch renames fakelb_dev_priv to fakelb_phy. We don't faking devices here, we fake wpan phys. This avoids also confusing with the variable priv, which is used several times in this driver to represent this structure. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/net/ieee802154/fakelb.c')
-rw-r--r--drivers/net/ieee802154/fakelb.c93
1 files changed, 47 insertions, 46 deletions
diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c
index 66f99c4f9768..5c4fbb861eb0 100644
--- a/drivers/net/ieee802154/fakelb.c
+++ b/drivers/net/ieee802154/fakelb.c
@@ -29,7 +29,7 @@
static int numlbs = 2;
-struct fakelb_dev_priv {
+struct fakelb_phy {
struct ieee802154_hw *hw;
struct list_head list;
@@ -62,36 +62,37 @@ fakelb_hw_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
}
static void
-fakelb_hw_deliver(struct fakelb_dev_priv *priv, struct sk_buff *skb)
+fakelb_hw_deliver(struct fakelb_phy *phy, struct sk_buff *skb)
{
struct sk_buff *newskb;
- spin_lock(&priv->lock);
- if (priv->working) {
+ spin_lock(&phy->lock);
+ if (phy->working) {
newskb = pskb_copy(skb, GFP_ATOMIC);
if (newskb)
- ieee802154_rx_irqsafe(priv->hw, newskb, 0xcc);
+ ieee802154_rx_irqsafe(phy->hw, newskb, 0xcc);
}
- spin_unlock(&priv->lock);
+ spin_unlock(&phy->lock);
}
static int
fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
{
- struct fakelb_dev_priv *priv = hw->priv;
- struct fakelb_priv *fake = priv->fake;
+ struct fakelb_phy *current_phy = hw->priv;
+ struct fakelb_priv *fake = current_phy->fake;
read_lock_bh(&fake->lock);
- if (priv->list.next == priv->list.prev) {
+ if (current_phy->list.next == current_phy->list.prev) {
/* we are the only one device */
- fakelb_hw_deliver(priv, skb);
+ fakelb_hw_deliver(current_phy, skb);
} else {
- struct fakelb_dev_priv *dp;
- list_for_each_entry(dp, &priv->fake->list, list) {
- if (dp != priv &&
- (dp->hw->phy->current_channel ==
- priv->hw->phy->current_channel))
- fakelb_hw_deliver(dp, skb);
+ struct fakelb_phy *phy;
+
+ list_for_each_entry(phy, &current_phy->fake->list, list) {
+ if (current_phy != phy &&
+ (phy->hw->phy->current_channel ==
+ current_phy->hw->phy->current_channel))
+ fakelb_hw_deliver(phy, skb);
}
}
read_unlock_bh(&fake->lock);
@@ -101,26 +102,26 @@ fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
static int
fakelb_hw_start(struct ieee802154_hw *hw) {
- struct fakelb_dev_priv *priv = hw->priv;
+ struct fakelb_phy *phy = hw->priv;
int ret = 0;
- spin_lock(&priv->lock);
- if (priv->working)
+ spin_lock(&phy->lock);
+ if (phy->working)
ret = -EBUSY;
else
- priv->working = 1;
- spin_unlock(&priv->lock);
+ phy->working = 1;
+ spin_unlock(&phy->lock);
return ret;
}
static void
fakelb_hw_stop(struct ieee802154_hw *hw) {
- struct fakelb_dev_priv *priv = hw->priv;
+ struct fakelb_phy *phy = hw->priv;
- spin_lock(&priv->lock);
- priv->working = 0;
- spin_unlock(&priv->lock);
+ spin_lock(&phy->lock);
+ phy->working = 0;
+ spin_unlock(&phy->lock);
}
static const struct ieee802154_ops fakelb_ops = {
@@ -138,16 +139,16 @@ MODULE_PARM_DESC(numlbs, " number of pseudo devices");
static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake)
{
- struct fakelb_dev_priv *priv;
+ struct fakelb_phy *phy;
int err;
struct ieee802154_hw *hw;
- hw = ieee802154_alloc_hw(sizeof(*priv), &fakelb_ops);
+ hw = ieee802154_alloc_hw(sizeof(*phy), &fakelb_ops);
if (!hw)
return -ENOMEM;
- priv = hw->priv;
- priv->hw = hw;
+ phy = hw->priv;
+ phy->hw = hw;
/* 868 MHz BPSK 802.15.4-2003 */
hw->phy->supported.channels[0] |= 1;
@@ -180,10 +181,10 @@ 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(&priv->list);
- priv->fake = fake;
+ INIT_LIST_HEAD(&phy->list);
+ phy->fake = fake;
- spin_lock_init(&priv->lock);
+ spin_lock_init(&phy->lock);
hw->parent = dev;
@@ -192,30 +193,30 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake)
goto err_reg;
write_lock_bh(&fake->lock);
- list_add_tail(&priv->list, &fake->list);
+ list_add_tail(&phy->list, &fake->list);
write_unlock_bh(&fake->lock);
return 0;
err_reg:
- ieee802154_free_hw(priv->hw);
+ ieee802154_free_hw(phy->hw);
return err;
}
-static void fakelb_del(struct fakelb_dev_priv *priv)
+static void fakelb_del(struct fakelb_phy *phy)
{
- write_lock_bh(&priv->fake->lock);
- list_del(&priv->list);
- write_unlock_bh(&priv->fake->lock);
+ write_lock_bh(&phy->fake->lock);
+ list_del(&phy->list);
+ write_unlock_bh(&phy->fake->lock);
- ieee802154_unregister_hw(priv->hw);
- ieee802154_free_hw(priv->hw);
+ ieee802154_unregister_hw(phy->hw);
+ ieee802154_free_hw(phy->hw);
}
static int fakelb_probe(struct platform_device *pdev)
{
struct fakelb_priv *priv;
- struct fakelb_dev_priv *dp, *tmp;
+ struct fakelb_phy *phy, *tmp;
int err = -ENOMEM;
int i;
@@ -238,8 +239,8 @@ static int fakelb_probe(struct platform_device *pdev)
return 0;
err_slave:
- list_for_each_entry_safe(dp, tmp, &priv->list, list)
- fakelb_del(dp);
+ list_for_each_entry_safe(phy, tmp, &priv->list, list)
+ fakelb_del(phy);
err_alloc:
return err;
}
@@ -247,10 +248,10 @@ err_alloc:
static int fakelb_remove(struct platform_device *pdev)
{
struct fakelb_priv *priv = platform_get_drvdata(pdev);
- struct fakelb_dev_priv *dp, *temp;
+ struct fakelb_phy *phy, *temp;
- list_for_each_entry_safe(dp, temp, &priv->list, list)
- fakelb_del(dp);
+ list_for_each_entry_safe(phy, temp, &priv->list, list)
+ fakelb_del(phy);
return 0;
}