To set the CCA_ED_THRES register the calculation for at86rf23x is different than for at86rf212. This patch adds a new callback for this calculation in chip data struct.
Signed-off-by: Alexander Aring <alex.ar...@gmail.com> --- drivers/net/ieee802154/at86rf2xx.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/net/ieee802154/at86rf2xx.c b/drivers/net/ieee802154/at86rf2xx.c index 24c5de0..ae01007 100644 --- a/drivers/net/ieee802154/at86rf2xx.c +++ b/drivers/net/ieee802154/at86rf2xx.c @@ -45,6 +45,7 @@ struct at86rf2xx_local; struct at86rf2xx_chip_data { int rssi_base_val; int (*set_channel)(struct at86rf2xx_local *, int, int); + int (*get_desense_steps)(struct at86rf2xx_local *, s32); }; struct at86rf2xx_local { @@ -818,17 +819,27 @@ at86rf2xx_set_cca_mode(struct ieee802154_dev *dev, u8 mode) } static int +at86rf212_get_desens_steps(struct at86rf2xx_local *lp, s32 level) +{ + return (level - lp->data->rssi_base_val) * 100 / 207; +} + +static int +at86rf23x_get_desens_steps(struct at86rf2xx_local *lp, s32 level) +{ + return (level - lp->data->rssi_base_val) / 2; +} + +static int at86rf2xx_set_cca_ed_level(struct ieee802154_dev *dev, s32 level) { struct at86rf2xx_local *lp = dev->priv; - int desens_steps; if (level < lp->data->rssi_base_val || level > 30) return -EINVAL; - desens_steps = (level - lp->data->rssi_base_val) * 100 / 207; - - return at86rf2xx_write_subreg(lp, SR_CCA_ED_THRES, desens_steps); + return at86rf2xx_write_subreg(lp, SR_CCA_ED_THRES, + lp->data->get_desense_steps(lp, level)); } static int @@ -886,18 +897,21 @@ static struct ieee802154_ops at86rf2xx_ops = { }; static struct at86rf2xx_chip_data at86rf233_data = { - .set_channel = at86rf23x_set_channel, .rssi_base_val = -91, + .set_channel = at86rf23x_set_channel, + .get_desense_steps = at86rf23x_get_desens_steps }; static struct at86rf2xx_chip_data at86rf231_data = { .set_channel = at86rf23x_set_channel, .rssi_base_val = -91, + .get_desense_steps = at86rf23x_get_desens_steps }; static struct at86rf2xx_chip_data at86rf212_data = { - .set_channel = at86rf212_set_channel, .rssi_base_val = -100, + .set_channel = at86rf212_set_channel, + .get_desense_steps = at86rf212_get_desens_steps }; static void at86rf2xx_irqwork(struct work_struct *work) -- 2.0.0 ------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems _______________________________________________ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel