Skip to content

Commit

Permalink
at86rf2xx: fix option setting
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Apr 20, 2016
1 parent c838f3d commit b2cd777
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions drivers/at86rf2xx/at86rf2xx_netdev.c
Expand Up @@ -383,7 +383,7 @@ static int _set(netdev2_t *netdev, netopt_t opt, void *val, size_t len)
{
at86rf2xx_t *dev = (at86rf2xx_t *) netdev;
uint8_t old_state = at86rf2xx_get_status(dev);
int res = 0;
int res = -ENOTSUP;

if (dev == NULL) {
return -ENODEV;
Expand Down Expand Up @@ -433,7 +433,7 @@ static int _set(netdev2_t *netdev, netopt_t opt, void *val, size_t len)
uint8_t chan = ((uint8_t *)val)[0];
if (chan < AT86RF2XX_MIN_CHANNEL ||
chan > AT86RF2XX_MAX_CHANNEL) {
res = -ENOTSUP;
res = -EINVAL;
break;
}
at86rf2xx_set_chan(dev, chan);
Expand All @@ -449,7 +449,7 @@ static int _set(netdev2_t *netdev, netopt_t opt, void *val, size_t len)
uint8_t page = ((uint8_t *)val)[0];
#ifdef MODULE_AT86RF212B
if ((page != 0) && (page != 2)) {
res = -ENOTSUP;
res = -EINVAL;
}
else {
at86rf2xx_set_page(dev, page);
Expand All @@ -458,7 +458,7 @@ static int _set(netdev2_t *netdev, netopt_t opt, void *val, size_t len)
#else
/* rf23x only supports page 0, no need to configure anything in the driver. */
if (page != 0) {
res = -ENOTSUP;
res = -EINVAL;
}
else {
res = sizeof(uint16_t);
Expand Down Expand Up @@ -549,11 +549,8 @@ static int _set(netdev2_t *netdev, netopt_t opt, void *val, size_t len)
(*((uint8_t *)val) > 5)) {
res = -EOVERFLOW;
}
else if (!(dev->netdev.flags & AT86RF2XX_OPT_CSMA)) {
/* If CSMA is disabled, don't allow setting retries */
res = -ENOTSUP;
}
else {
else if (dev->netdev.flags & AT86RF2XX_OPT_CSMA) {
/* only set if CSMA is enabled */
at86rf2xx_set_csma_max_retries(dev, *((uint8_t *)val));
res = sizeof(uint8_t);
}
Expand All @@ -570,7 +567,7 @@ static int _set(netdev2_t *netdev, netopt_t opt, void *val, size_t len)
break;

default:
res = -ENOTSUP;
break;
}

/* go back to sleep if were sleeping and state hasn't been changed */
Expand Down

0 comments on commit b2cd777

Please sign in to comment.