Commit 672f5cce authored by David S. Miller's avatar David S. Miller

Merge branch 'ieee802154-for-davem-2018-07-11' of...

Merge branch 'ieee802154-for-davem-2018-07-11' of git://git.kernel.org/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: default avatarDavid S. Miller <davem@davemloft.net>
parents 20c4515a 58e9683d
...@@ -275,6 +275,8 @@ struct adf7242_local { ...@@ -275,6 +275,8 @@ struct adf7242_local {
struct spi_message stat_msg; struct spi_message stat_msg;
struct spi_transfer stat_xfer; struct spi_transfer stat_xfer;
struct dentry *debugfs_root; struct dentry *debugfs_root;
struct delayed_work work;
struct workqueue_struct *wqueue;
unsigned long flags; unsigned long flags;
int tx_stat; int tx_stat;
bool promiscuous; bool promiscuous;
...@@ -575,10 +577,26 @@ static int adf7242_cmd_rx(struct adf7242_local *lp) ...@@ -575,10 +577,26 @@ static int adf7242_cmd_rx(struct adf7242_local *lp)
/* Wait until the ACK is sent */ /* Wait until the ACK is sent */
adf7242_wait_status(lp, RC_STATUS_PHY_RDY, RC_STATUS_MASK, __LINE__); adf7242_wait_status(lp, RC_STATUS_PHY_RDY, RC_STATUS_MASK, __LINE__);
adf7242_clear_irqstat(lp); adf7242_clear_irqstat(lp);
mod_delayed_work(lp->wqueue, &lp->work, msecs_to_jiffies(400));
return adf7242_cmd(lp, CMD_RC_RX); 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) static int adf7242_set_txpower(struct ieee802154_hw *hw, int mbm)
{ {
struct adf7242_local *lp = hw->priv; struct adf7242_local *lp = hw->priv;
...@@ -686,7 +704,7 @@ static int adf7242_start(struct ieee802154_hw *hw) ...@@ -686,7 +704,7 @@ static int adf7242_start(struct ieee802154_hw *hw)
enable_irq(lp->spi->irq); enable_irq(lp->spi->irq);
set_bit(FLAG_START, &lp->flags); 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) static void adf7242_stop(struct ieee802154_hw *hw)
...@@ -694,6 +712,7 @@ static void adf7242_stop(struct ieee802154_hw *hw) ...@@ -694,6 +712,7 @@ static void adf7242_stop(struct ieee802154_hw *hw)
struct adf7242_local *lp = hw->priv; struct adf7242_local *lp = hw->priv;
disable_irq(lp->spi->irq); disable_irq(lp->spi->irq);
cancel_delayed_work_sync(&lp->work);
adf7242_cmd(lp, CMD_RC_IDLE); adf7242_cmd(lp, CMD_RC_IDLE);
clear_bit(FLAG_START, &lp->flags); clear_bit(FLAG_START, &lp->flags);
adf7242_clear_irqstat(lp); adf7242_clear_irqstat(lp);
...@@ -719,7 +738,10 @@ static int adf7242_channel(struct ieee802154_hw *hw, u8 page, u8 channel) ...@@ -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_FREQ1, freq >> 8);
adf7242_write_reg(lp, REG_CH_FREQ2, freq >> 16); 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, static int adf7242_set_hw_addr_filt(struct ieee802154_hw *hw,
...@@ -814,6 +836,7 @@ static int adf7242_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) ...@@ -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 */ /* ensure existing instances of the IRQ handler have completed */
disable_irq(lp->spi->irq); disable_irq(lp->spi->irq);
set_bit(FLAG_XMIT, &lp->flags); set_bit(FLAG_XMIT, &lp->flags);
cancel_delayed_work_sync(&lp->work);
reinit_completion(&lp->tx_complete); reinit_completion(&lp->tx_complete);
adf7242_cmd(lp, CMD_RC_PHY_RDY); adf7242_cmd(lp, CMD_RC_PHY_RDY);
adf7242_clear_irqstat(lp); adf7242_clear_irqstat(lp);
...@@ -952,6 +975,7 @@ static irqreturn_t adf7242_isr(int irq, void *data) ...@@ -952,6 +975,7 @@ static irqreturn_t adf7242_isr(int irq, void *data)
unsigned int xmit; unsigned int xmit;
u8 irq1; u8 irq1;
mod_delayed_work(lp->wqueue, &lp->work, msecs_to_jiffies(400));
adf7242_read_reg(lp, REG_IRQ1_SRC1, &irq1); adf7242_read_reg(lp, REG_IRQ1_SRC1, &irq1);
if (!(irq1 & (IRQ_RX_PKT_RCVD | IRQ_CSMA_CA))) if (!(irq1 & (IRQ_RX_PKT_RCVD | IRQ_CSMA_CA)))
...@@ -1241,6 +1265,9 @@ static int adf7242_probe(struct spi_device *spi) ...@@ -1241,6 +1265,9 @@ static int adf7242_probe(struct spi_device *spi)
spi_message_add_tail(&lp->stat_xfer, &lp->stat_msg); spi_message_add_tail(&lp->stat_xfer, &lp->stat_msg);
spi_set_drvdata(spi, lp); 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); ret = adf7242_hw_init(lp);
if (ret) if (ret)
...@@ -1284,6 +1311,9 @@ static int adf7242_remove(struct spi_device *spi) ...@@ -1284,6 +1311,9 @@ static int adf7242_remove(struct spi_device *spi)
if (!IS_ERR_OR_NULL(lp->debugfs_root)) if (!IS_ERR_OR_NULL(lp->debugfs_root))
debugfs_remove_recursive(lp->debugfs_root); debugfs_remove_recursive(lp->debugfs_root);
cancel_delayed_work_sync(&lp->work);
destroy_workqueue(lp->wqueue);
ieee802154_unregister_hw(lp->hw); ieee802154_unregister_hw(lp->hw);
mutex_destroy(&lp->bmux); mutex_destroy(&lp->bmux);
ieee802154_free_hw(lp->hw); ieee802154_free_hw(lp->hw);
......
...@@ -940,7 +940,7 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) ...@@ -940,7 +940,7 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
static int static int
at86rf230_ed(struct ieee802154_hw *hw, u8 *level) at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
{ {
BUG_ON(!level); WARN_ON(!level);
*level = 0xbe; *level = 0xbe;
return 0; return 0;
} }
...@@ -1121,8 +1121,7 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw, ...@@ -1121,8 +1121,7 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
if (changed & IEEE802154_AFILT_SADDR_CHANGED) { if (changed & IEEE802154_AFILT_SADDR_CHANGED) {
u16 addr = le16_to_cpu(filt->short_addr); u16 addr = le16_to_cpu(filt->short_addr);
dev_vdbg(&lp->spi->dev, dev_vdbg(&lp->spi->dev, "%s called for saddr\n", __func__);
"at86rf230_set_hw_addr_filt called for saddr\n");
__at86rf230_write(lp, RG_SHORT_ADDR_0, addr); __at86rf230_write(lp, RG_SHORT_ADDR_0, addr);
__at86rf230_write(lp, RG_SHORT_ADDR_1, addr >> 8); __at86rf230_write(lp, RG_SHORT_ADDR_1, addr >> 8);
} }
...@@ -1130,8 +1129,7 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw, ...@@ -1130,8 +1129,7 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
if (changed & IEEE802154_AFILT_PANID_CHANGED) { if (changed & IEEE802154_AFILT_PANID_CHANGED) {
u16 pan = le16_to_cpu(filt->pan_id); u16 pan = le16_to_cpu(filt->pan_id);
dev_vdbg(&lp->spi->dev, dev_vdbg(&lp->spi->dev, "%s called for pan id\n", __func__);
"at86rf230_set_hw_addr_filt called for pan id\n");
__at86rf230_write(lp, RG_PAN_ID_0, pan); __at86rf230_write(lp, RG_PAN_ID_0, pan);
__at86rf230_write(lp, RG_PAN_ID_1, pan >> 8); __at86rf230_write(lp, RG_PAN_ID_1, pan >> 8);
} }
...@@ -1140,15 +1138,13 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw, ...@@ -1140,15 +1138,13 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
u8 i, addr[8]; u8 i, addr[8];
memcpy(addr, &filt->ieee_addr, 8); memcpy(addr, &filt->ieee_addr, 8);
dev_vdbg(&lp->spi->dev, dev_vdbg(&lp->spi->dev, "%s called for IEEE addr\n", __func__);
"at86rf230_set_hw_addr_filt called for IEEE addr\n");
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
__at86rf230_write(lp, RG_IEEE_ADDR_0 + i, addr[i]); __at86rf230_write(lp, RG_IEEE_ADDR_0 + i, addr[i]);
} }
if (changed & IEEE802154_AFILT_PANC_CHANGED) { if (changed & IEEE802154_AFILT_PANC_CHANGED) {
dev_vdbg(&lp->spi->dev, dev_vdbg(&lp->spi->dev, "%s called for panc change\n", __func__);
"at86rf230_set_hw_addr_filt called for panc change\n");
if (filt->pan_coord) if (filt->pan_coord)
at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 1); at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 1);
else else
...@@ -1252,7 +1248,6 @@ at86rf230_set_cca_mode(struct ieee802154_hw *hw, ...@@ -1252,7 +1248,6 @@ at86rf230_set_cca_mode(struct ieee802154_hw *hw,
return at86rf230_write_subreg(lp, SR_CCA_MODE, val); return at86rf230_write_subreg(lp, SR_CCA_MODE, val);
} }
static int static int
at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm) at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm)
{ {
......
...@@ -49,7 +49,7 @@ struct fakelb_phy { ...@@ -49,7 +49,7 @@ struct fakelb_phy {
static int fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level) static int fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level)
{ {
BUG_ON(!level); WARN_ON(!level);
*level = 0xbe; *level = 0xbe;
return 0; return 0;
......
...@@ -15,10 +15,11 @@ ...@@ -15,10 +15,11 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/regmap.h> #include <linux/regmap.h>
......
...@@ -90,12 +90,18 @@ static int lowpan_neigh_construct(struct net_device *dev, struct neighbour *n) ...@@ -90,12 +90,18 @@ static int lowpan_neigh_construct(struct net_device *dev, struct neighbour *n)
return 0; 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 = { static const struct net_device_ops lowpan_netdev_ops = {
.ndo_init = lowpan_dev_init, .ndo_init = lowpan_dev_init,
.ndo_start_xmit = lowpan_xmit, .ndo_start_xmit = lowpan_xmit,
.ndo_open = lowpan_open, .ndo_open = lowpan_open,
.ndo_stop = lowpan_stop, .ndo_stop = lowpan_stop,
.ndo_neigh_construct = lowpan_neigh_construct, .ndo_neigh_construct = lowpan_neigh_construct,
.ndo_get_iflink = lowpan_get_iflink,
}; };
static void lowpan_setup(struct net_device *ldev) static void lowpan_setup(struct net_device *ldev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment