Skip to content

Commit

Permalink
Merge branch 'ieee802154-for-davem-2018-07-11' of git://git.kernel.or…
Browse files Browse the repository at this point in the history
…g/pub/scm/linux/kernel/git/sschmidt/wpan

Stefan Schmidt says:

====================
pull-request: ieee802154 for net 2018-07-11

An update from ieee802154 for your *net* tree.

Build system fix for a missing include from Arnd Bergmann.
Setting the IFLA_LINK for the lowpan parent from Lubomir Rintel.
Fixes for some RX corner cases in adf7242 driver by Michael Hennerich.
And some small patches to cleanup our BUG_ON vs WARN_ON usage.
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Jul 12, 2018
2 parents 20c4515 + 58e9683 commit 672f5cc
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 14 deletions.
34 changes: 32 additions & 2 deletions drivers/net/ieee802154/adf7242.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ struct adf7242_local {
struct spi_message stat_msg;
struct spi_transfer stat_xfer;
struct dentry *debugfs_root;
struct delayed_work work;
struct workqueue_struct *wqueue;
unsigned long flags;
int tx_stat;
bool promiscuous;
Expand Down Expand Up @@ -575,10 +577,26 @@ static int adf7242_cmd_rx(struct adf7242_local *lp)
/* Wait until the ACK is sent */
adf7242_wait_status(lp, RC_STATUS_PHY_RDY, RC_STATUS_MASK, __LINE__);
adf7242_clear_irqstat(lp);
mod_delayed_work(lp->wqueue, &lp->work, msecs_to_jiffies(400));

return adf7242_cmd(lp, CMD_RC_RX);
}

static void adf7242_rx_cal_work(struct work_struct *work)
{
struct adf7242_local *lp =
container_of(work, struct adf7242_local, work.work);

/* Reissuing RC_RX every 400ms - to adjust for offset
* drift in receiver (datasheet page 61, OCL section)
*/

if (!test_bit(FLAG_XMIT, &lp->flags)) {
adf7242_cmd(lp, CMD_RC_PHY_RDY);
adf7242_cmd_rx(lp);
}
}

static int adf7242_set_txpower(struct ieee802154_hw *hw, int mbm)
{
struct adf7242_local *lp = hw->priv;
Expand Down Expand Up @@ -686,14 +704,15 @@ static int adf7242_start(struct ieee802154_hw *hw)
enable_irq(lp->spi->irq);
set_bit(FLAG_START, &lp->flags);

return adf7242_cmd(lp, CMD_RC_RX);
return adf7242_cmd_rx(lp);
}

static void adf7242_stop(struct ieee802154_hw *hw)
{
struct adf7242_local *lp = hw->priv;

disable_irq(lp->spi->irq);
cancel_delayed_work_sync(&lp->work);
adf7242_cmd(lp, CMD_RC_IDLE);
clear_bit(FLAG_START, &lp->flags);
adf7242_clear_irqstat(lp);
Expand All @@ -719,7 +738,10 @@ static int adf7242_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
adf7242_write_reg(lp, REG_CH_FREQ1, freq >> 8);
adf7242_write_reg(lp, REG_CH_FREQ2, freq >> 16);

return adf7242_cmd(lp, CMD_RC_RX);
if (test_bit(FLAG_START, &lp->flags))
return adf7242_cmd_rx(lp);
else
return adf7242_cmd(lp, CMD_RC_PHY_RDY);
}

static int adf7242_set_hw_addr_filt(struct ieee802154_hw *hw,
Expand Down Expand Up @@ -814,6 +836,7 @@ static int adf7242_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
/* ensure existing instances of the IRQ handler have completed */
disable_irq(lp->spi->irq);
set_bit(FLAG_XMIT, &lp->flags);
cancel_delayed_work_sync(&lp->work);
reinit_completion(&lp->tx_complete);
adf7242_cmd(lp, CMD_RC_PHY_RDY);
adf7242_clear_irqstat(lp);
Expand Down Expand Up @@ -952,6 +975,7 @@ static irqreturn_t adf7242_isr(int irq, void *data)
unsigned int xmit;
u8 irq1;

mod_delayed_work(lp->wqueue, &lp->work, msecs_to_jiffies(400));
adf7242_read_reg(lp, REG_IRQ1_SRC1, &irq1);

if (!(irq1 & (IRQ_RX_PKT_RCVD | IRQ_CSMA_CA)))
Expand Down Expand Up @@ -1241,6 +1265,9 @@ static int adf7242_probe(struct spi_device *spi)
spi_message_add_tail(&lp->stat_xfer, &lp->stat_msg);

spi_set_drvdata(spi, lp);
INIT_DELAYED_WORK(&lp->work, adf7242_rx_cal_work);
lp->wqueue = alloc_ordered_workqueue(dev_name(&spi->dev),
WQ_MEM_RECLAIM);

ret = adf7242_hw_init(lp);
if (ret)
Expand Down Expand Up @@ -1284,6 +1311,9 @@ static int adf7242_remove(struct spi_device *spi)
if (!IS_ERR_OR_NULL(lp->debugfs_root))
debugfs_remove_recursive(lp->debugfs_root);

cancel_delayed_work_sync(&lp->work);
destroy_workqueue(lp->wqueue);

ieee802154_unregister_hw(lp->hw);
mutex_destroy(&lp->bmux);
ieee802154_free_hw(lp->hw);
Expand Down
15 changes: 5 additions & 10 deletions drivers/net/ieee802154/at86rf230.c
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
static int
at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
{
BUG_ON(!level);
WARN_ON(!level);
*level = 0xbe;
return 0;
}
Expand Down Expand Up @@ -1121,17 +1121,15 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
if (changed & IEEE802154_AFILT_SADDR_CHANGED) {
u16 addr = le16_to_cpu(filt->short_addr);

dev_vdbg(&lp->spi->dev,
"at86rf230_set_hw_addr_filt called for saddr\n");
dev_vdbg(&lp->spi->dev, "%s called for saddr\n", __func__);
__at86rf230_write(lp, RG_SHORT_ADDR_0, addr);
__at86rf230_write(lp, RG_SHORT_ADDR_1, addr >> 8);
}

if (changed & IEEE802154_AFILT_PANID_CHANGED) {
u16 pan = le16_to_cpu(filt->pan_id);

dev_vdbg(&lp->spi->dev,
"at86rf230_set_hw_addr_filt called for pan id\n");
dev_vdbg(&lp->spi->dev, "%s called for pan id\n", __func__);
__at86rf230_write(lp, RG_PAN_ID_0, pan);
__at86rf230_write(lp, RG_PAN_ID_1, pan >> 8);
}
Expand All @@ -1140,15 +1138,13 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
u8 i, addr[8];

memcpy(addr, &filt->ieee_addr, 8);
dev_vdbg(&lp->spi->dev,
"at86rf230_set_hw_addr_filt called for IEEE addr\n");
dev_vdbg(&lp->spi->dev, "%s called for IEEE addr\n", __func__);
for (i = 0; i < 8; i++)
__at86rf230_write(lp, RG_IEEE_ADDR_0 + i, addr[i]);
}

if (changed & IEEE802154_AFILT_PANC_CHANGED) {
dev_vdbg(&lp->spi->dev,
"at86rf230_set_hw_addr_filt called for panc change\n");
dev_vdbg(&lp->spi->dev, "%s called for panc change\n", __func__);
if (filt->pan_coord)
at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 1);
else
Expand Down Expand Up @@ -1252,7 +1248,6 @@ at86rf230_set_cca_mode(struct ieee802154_hw *hw,
return at86rf230_write_subreg(lp, SR_CCA_MODE, val);
}


static int
at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm)
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ieee802154/fakelb.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct fakelb_phy {

static int fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level)
{
BUG_ON(!level);
WARN_ON(!level);
*level = 0xbe;

return 0;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ieee802154/mcr20a.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/spi/spi.h>
#include <linux/workqueue.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/skbuff.h>
#include <linux/of_gpio.h>
#include <linux/regmap.h>
Expand Down
6 changes: 6 additions & 0 deletions net/ieee802154/6lowpan/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,18 @@ static int lowpan_neigh_construct(struct net_device *dev, struct neighbour *n)
return 0;
}

static int lowpan_get_iflink(const struct net_device *dev)
{
return lowpan_802154_dev(dev)->wdev->ifindex;
}

static const struct net_device_ops lowpan_netdev_ops = {
.ndo_init = lowpan_dev_init,
.ndo_start_xmit = lowpan_xmit,
.ndo_open = lowpan_open,
.ndo_stop = lowpan_stop,
.ndo_neigh_construct = lowpan_neigh_construct,
.ndo_get_iflink = lowpan_get_iflink,
};

static void lowpan_setup(struct net_device *ldev)
Expand Down

0 comments on commit 672f5cc

Please sign in to comment.