Skip to content

Commit

Permalink
ieee802154: rename ieee802154_dev to ieee802154_hw
Browse files Browse the repository at this point in the history
The identical struct of the wireless stack implementation is named
ieee80211_hw. This is useful to name the variable hw instead of get
confusing with netdev dev variable.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Cc: Alan Ott <alan@signal11.us>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Alexander Aring authored and Marcel Holtmann committed Oct 25, 2014
1 parent 3642648 commit 5a50439
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 179 deletions.
90 changes: 45 additions & 45 deletions drivers/net/ieee802154/at86rf230.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct at86rf230_state_change {
struct at86rf230_local {
struct spi_device *spi;

struct ieee802154_dev *dev;
struct ieee802154_hw *hw;
struct at86rf2xx_chip_data *data;
struct regmap *regmap;

Expand Down Expand Up @@ -808,7 +808,7 @@ at86rf230_rx(struct at86rf230_local *lp,
/* We do not put CRC into the frame */
skb_trim(skb, len - 2);

ieee802154_rx_irqsafe(lp->dev, skb, lqi);
ieee802154_rx_irqsafe(lp->hw, skb, lqi);
}

static void
Expand Down Expand Up @@ -969,9 +969,9 @@ at86rf230_xmit_tx_on(void *context)
}

static int
at86rf230_xmit(struct ieee802154_dev *dev, struct sk_buff *skb)
at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
{
struct at86rf230_local *lp = dev->priv;
struct at86rf230_local *lp = hw->priv;
struct at86rf230_state_change *ctx = &lp->tx;

void (*tx_complete)(void *context) = at86rf230_write_frame;
Expand Down Expand Up @@ -1012,7 +1012,7 @@ at86rf230_xmit(struct ieee802154_dev *dev, struct sk_buff *skb)
}

static int
at86rf230_ed(struct ieee802154_dev *dev, u8 *level)
at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
{
might_sleep();
BUG_ON(!level);
Expand All @@ -1021,15 +1021,15 @@ at86rf230_ed(struct ieee802154_dev *dev, u8 *level)
}

static int
at86rf230_start(struct ieee802154_dev *dev)
at86rf230_start(struct ieee802154_hw *hw)
{
return at86rf230_sync_state_change(dev->priv, STATE_RX_AACK_ON);
return at86rf230_sync_state_change(hw->priv, STATE_RX_AACK_ON);
}

static void
at86rf230_stop(struct ieee802154_dev *dev)
at86rf230_stop(struct ieee802154_hw *hw)
{
at86rf230_sync_state_change(dev->priv, STATE_FORCE_TRX_OFF);
at86rf230_sync_state_change(hw->priv, STATE_FORCE_TRX_OFF);
}

static int
Expand Down Expand Up @@ -1064,15 +1064,15 @@ at86rf212_set_channel(struct at86rf230_local *lp, int page, int channel)
}

static int
at86rf230_channel(struct ieee802154_dev *dev, int page, int channel)
at86rf230_channel(struct ieee802154_hw *hw, int page, int channel)
{
struct at86rf230_local *lp = dev->priv;
struct at86rf230_local *lp = hw->priv;
int rc;

might_sleep();

if (page < 0 || page > 31 ||
!(lp->dev->phy->channels_supported[page] & BIT(channel))) {
!(lp->hw->phy->channels_supported[page] & BIT(channel))) {
WARN_ON(1);
return -EINVAL;
}
Expand All @@ -1084,18 +1084,18 @@ at86rf230_channel(struct ieee802154_dev *dev, int page, int channel)
/* Wait for PLL */
usleep_range(lp->data->t_channel_switch,
lp->data->t_channel_switch + 10);
dev->phy->current_channel = channel;
dev->phy->current_page = page;
hw->phy->current_channel = channel;
hw->phy->current_page = page;

return 0;
}

static int
at86rf230_set_hw_addr_filt(struct ieee802154_dev *dev,
at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
struct ieee802154_hw_addr_filt *filt,
unsigned long changed)
{
struct at86rf230_local *lp = dev->priv;
struct at86rf230_local *lp = hw->priv;

if (changed & IEEE802154_AFILT_SADDR_CHANGED) {
u16 addr = le16_to_cpu(filt->short_addr);
Expand Down Expand Up @@ -1138,9 +1138,9 @@ at86rf230_set_hw_addr_filt(struct ieee802154_dev *dev,
}

static int
at86rf230_set_txpower(struct ieee802154_dev *dev, int db)
at86rf230_set_txpower(struct ieee802154_hw *hw, int db)
{
struct at86rf230_local *lp = dev->priv;
struct at86rf230_local *lp = hw->priv;

/* typical maximum output is 5dBm with RG_PHY_TX_PWR 0x60, lower five
* bits decrease power in 1dB steps. 0x60 represents extra PA gain of
Expand All @@ -1157,17 +1157,17 @@ at86rf230_set_txpower(struct ieee802154_dev *dev, int db)
}

static int
at86rf230_set_lbt(struct ieee802154_dev *dev, bool on)
at86rf230_set_lbt(struct ieee802154_hw *hw, bool on)
{
struct at86rf230_local *lp = dev->priv;
struct at86rf230_local *lp = hw->priv;

return at86rf230_write_subreg(lp, SR_CSMA_LBT_MODE, on);
}

static int
at86rf230_set_cca_mode(struct ieee802154_dev *dev, u8 mode)
at86rf230_set_cca_mode(struct ieee802154_hw *hw, u8 mode)
{
struct at86rf230_local *lp = dev->priv;
struct at86rf230_local *lp = hw->priv;

return at86rf230_write_subreg(lp, SR_CCA_MODE, mode);
}
Expand All @@ -1185,9 +1185,9 @@ at86rf23x_get_desens_steps(struct at86rf230_local *lp, s32 level)
}

static int
at86rf230_set_cca_ed_level(struct ieee802154_dev *dev, s32 level)
at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 level)
{
struct at86rf230_local *lp = dev->priv;
struct at86rf230_local *lp = hw->priv;

if (level < lp->data->rssi_base_val || level > 30)
return -EINVAL;
Expand All @@ -1197,10 +1197,10 @@ at86rf230_set_cca_ed_level(struct ieee802154_dev *dev, s32 level)
}

static int
at86rf230_set_csma_params(struct ieee802154_dev *dev, u8 min_be, u8 max_be,
at86rf230_set_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be,
u8 retries)
{
struct at86rf230_local *lp = dev->priv;
struct at86rf230_local *lp = hw->priv;
int rc;

if (min_be > max_be || max_be > 8 || retries > 5)
Expand All @@ -1218,9 +1218,9 @@ at86rf230_set_csma_params(struct ieee802154_dev *dev, u8 min_be, u8 max_be,
}

static int
at86rf230_set_frame_retries(struct ieee802154_dev *dev, s8 retries)
at86rf230_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
{
struct at86rf230_local *lp = dev->priv;
struct at86rf230_local *lp = hw->priv;
int rc = 0;

if (retries < -1 || retries > 15)
Expand Down Expand Up @@ -1409,8 +1409,8 @@ at86rf230_detect_device(struct at86rf230_local *lp)
return -EINVAL;
}

lp->dev->extra_tx_headroom = 0;
lp->dev->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AACK |
lp->hw->extra_tx_headroom = 0;
lp->hw->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AACK |
IEEE802154_HW_TXPOWER | IEEE802154_HW_CSMA;

switch (part) {
Expand All @@ -1421,23 +1421,23 @@ at86rf230_detect_device(struct at86rf230_local *lp)
case 3:
chip = "at86rf231";
lp->data = &at86rf231_data;
lp->dev->phy->channels_supported[0] = 0x7FFF800;
lp->hw->phy->channels_supported[0] = 0x7FFF800;
break;
case 7:
chip = "at86rf212";
if (version == 1) {
lp->data = &at86rf212_data;
lp->dev->flags |= IEEE802154_HW_LBT;
lp->dev->phy->channels_supported[0] = 0x00007FF;
lp->dev->phy->channels_supported[2] = 0x00007FF;
lp->hw->flags |= IEEE802154_HW_LBT;
lp->hw->phy->channels_supported[0] = 0x00007FF;
lp->hw->phy->channels_supported[2] = 0x00007FF;
} else {
rc = -ENOTSUPP;
}
break;
case 11:
chip = "at86rf233";
lp->data = &at86rf233_data;
lp->dev->phy->channels_supported[0] = 0x7FFF800;
lp->hw->phy->channels_supported[0] = 0x7FFF800;
break;
default:
chip = "unkown";
Expand Down Expand Up @@ -1478,7 +1478,7 @@ at86rf230_setup_spi_messages(struct at86rf230_local *lp)
static int at86rf230_probe(struct spi_device *spi)
{
struct at86rf230_platform_data *pdata;
struct ieee802154_dev *dev;
struct ieee802154_hw *hw;
struct at86rf230_local *lp;
unsigned int status;
int rc, irq_type;
Expand Down Expand Up @@ -1517,14 +1517,14 @@ static int at86rf230_probe(struct spi_device *spi)
usleep_range(120, 240);
}

dev = ieee802154_alloc_device(sizeof(*lp), &at86rf230_ops);
if (!dev)
hw = ieee802154_alloc_hw(sizeof(*lp), &at86rf230_ops);
if (!hw)
return -ENOMEM;

lp = dev->priv;
lp->dev = dev;
lp = hw->priv;
lp->hw = hw;
lp->spi = spi;
dev->parent = &spi->dev;
hw->parent = &spi->dev;

lp->regmap = devm_regmap_init_spi(spi, &at86rf230_regmap_spi_config);
if (IS_ERR(lp->regmap)) {
Expand Down Expand Up @@ -1564,14 +1564,14 @@ static int at86rf230_probe(struct spi_device *spi)
if (rc)
goto free_dev;

rc = ieee802154_register_device(lp->dev);
rc = ieee802154_register_hw(lp->hw);
if (rc)
goto free_dev;

return rc;

free_dev:
ieee802154_free_device(lp->dev);
ieee802154_free_hw(lp->hw);

return rc;
}
Expand All @@ -1582,8 +1582,8 @@ static int at86rf230_remove(struct spi_device *spi)

/* mask all at86rf230 irq's */
at86rf230_write_subreg(lp, SR_IRQ_MASK, 0);
ieee802154_unregister_device(lp->dev);
ieee802154_free_device(lp->dev);
ieee802154_unregister_hw(lp->hw);
ieee802154_free_hw(lp->hw);
dev_dbg(&spi->dev, "unregistered at86rf230\n");

return 0;
Expand Down
50 changes: 25 additions & 25 deletions drivers/net/ieee802154/cc2520.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
/* Driver private information */
struct cc2520_private {
struct spi_device *spi; /* SPI device structure */
struct ieee802154_dev *dev; /* IEEE-802.15.4 device */
struct ieee802154_hw *hw; /* IEEE-802.15.4 device */
u8 *buf; /* SPI TX/Rx data buffer */
struct mutex buffer_mutex; /* SPI buffer mutex */
bool is_tx; /* Flag for sync b/w Tx and Rx */
Expand Down Expand Up @@ -453,20 +453,20 @@ cc2520_read_rxfifo(struct cc2520_private *priv, u8 *data, u8 len, u8 *lqi)
return status;
}

static int cc2520_start(struct ieee802154_dev *dev)
static int cc2520_start(struct ieee802154_hw *hw)
{
return cc2520_cmd_strobe(dev->priv, CC2520_CMD_SRXON);
return cc2520_cmd_strobe(hw->priv, CC2520_CMD_SRXON);
}

static void cc2520_stop(struct ieee802154_dev *dev)
static void cc2520_stop(struct ieee802154_hw *hw)
{
cc2520_cmd_strobe(dev->priv, CC2520_CMD_SRFOFF);
cc2520_cmd_strobe(hw->priv, CC2520_CMD_SRFOFF);
}

static int
cc2520_tx(struct ieee802154_dev *dev, struct sk_buff *skb)
cc2520_tx(struct ieee802154_hw *hw, struct sk_buff *skb)
{
struct cc2520_private *priv = dev->priv;
struct cc2520_private *priv = hw->priv;
unsigned long flags;
int rc;
u8 status = 0;
Expand Down Expand Up @@ -536,17 +536,17 @@ static int cc2520_rx(struct cc2520_private *priv)

skb_trim(skb, skb->len - 2);

ieee802154_rx_irqsafe(priv->dev, skb, lqi);
ieee802154_rx_irqsafe(priv->hw, skb, lqi);

dev_vdbg(&priv->spi->dev, "RXFIFO: %x %x\n", len, lqi);

return 0;
}

static int
cc2520_ed(struct ieee802154_dev *dev, u8 *level)
cc2520_ed(struct ieee802154_hw *hw, u8 *level)
{
struct cc2520_private *priv = dev->priv;
struct cc2520_private *priv = hw->priv;
u8 status = 0xff;
u8 rssi;
int ret;
Expand All @@ -569,9 +569,9 @@ cc2520_ed(struct ieee802154_dev *dev, u8 *level)
}

static int
cc2520_set_channel(struct ieee802154_dev *dev, int page, int channel)
cc2520_set_channel(struct ieee802154_hw *hw, int page, int channel)
{
struct cc2520_private *priv = dev->priv;
struct cc2520_private *priv = hw->priv;
int ret;

might_sleep();
Expand All @@ -588,10 +588,10 @@ cc2520_set_channel(struct ieee802154_dev *dev, int page, int channel)
}

static int
cc2520_filter(struct ieee802154_dev *dev,
cc2520_filter(struct ieee802154_hw *hw,
struct ieee802154_hw_addr_filt *filt, unsigned long changed)
{
struct cc2520_private *priv = dev->priv;
struct cc2520_private *priv = hw->priv;

if (changed & IEEE802154_AFILT_PANID_CHANGED) {
u16 panid = le16_to_cpu(filt->pan_id);
Expand Down Expand Up @@ -645,27 +645,27 @@ static int cc2520_register(struct cc2520_private *priv)
{
int ret = -ENOMEM;

priv->dev = ieee802154_alloc_device(sizeof(*priv), &cc2520_ops);
if (!priv->dev)
priv->hw = ieee802154_alloc_hw(sizeof(*priv), &cc2520_ops);
if (!priv->hw)
goto err_ret;

priv->dev->priv = priv;
priv->dev->parent = &priv->spi->dev;
priv->dev->extra_tx_headroom = 0;
priv->hw->priv = priv;
priv->hw->parent = &priv->spi->dev;
priv->hw->extra_tx_headroom = 0;

/* We do support only 2.4 Ghz */
priv->dev->phy->channels_supported[0] = 0x7FFF800;
priv->dev->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AACK;
priv->hw->phy->channels_supported[0] = 0x7FFF800;
priv->hw->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AACK;

dev_vdbg(&priv->spi->dev, "registered cc2520\n");
ret = ieee802154_register_device(priv->dev);
ret = ieee802154_register_hw(priv->hw);
if (ret)
goto err_free_device;

return 0;

err_free_device:
ieee802154_free_device(priv->dev);
ieee802154_free_hw(priv->hw);
err_ret:
return ret;
}
Expand Down Expand Up @@ -1002,8 +1002,8 @@ static int cc2520_remove(struct spi_device *spi)
mutex_destroy(&priv->buffer_mutex);
flush_work(&priv->fifop_irqwork);

ieee802154_unregister_device(priv->dev);
ieee802154_free_device(priv->dev);
ieee802154_unregister_hw(priv->hw);
ieee802154_free_hw(priv->hw);

return 0;
}
Expand Down
Loading

0 comments on commit 5a50439

Please sign in to comment.