static int numlbs = 2;
-struct fakelb_dev_priv {
+struct fakelb_phy {
struct ieee802154_hw *hw;
struct list_head list;
}
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, ¤t_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);
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 = {
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;
/* 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;
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;
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;
}
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;
}