wireless/ieee802154: libaudio and libmac need to return the correct error codes.

This commit is contained in:
Gregory Nutt 2017-04-22 07:23:44 -06:00
parent 39568943ab
commit 8d671956e2
34 changed files with 119 additions and 81 deletions

View File

@ -61,10 +61,11 @@ int ieee802154_energydetect(int fd, FAR bool *energy)
ret = ioctl(fd, PHY802154IOC_ENERGYDETECT, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_ENERGYDETECT failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_ENERGYDETECT failed: %d\n", ret);
return ret;
}
*energy = arg.energy;
return ret;
return OK;
}

View File

@ -44,6 +44,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
@ -62,9 +63,11 @@ int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca)
ret = ioctl(fd, PHY802154IOC_GET_CCA, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_GET_CCA failed\n");
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_CCA failed\n", ret);
return ret;
}
memcpy(cca, &arg.cca, sizeof(struct ieee802154_cca_s));
return ret;
return OK;
}

View File

@ -39,12 +39,15 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <nuttx/fs/ioctl.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "wireless/ieee802154.h"
/****************************************************************************
@ -59,10 +62,11 @@ int ieee802154_getchan(int fd, FAR uint8_t *chan)
ret = ioctl(fd, PHY802154IOC_GET_CHAN, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_GET_CHAN failed\n");
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_CHAN failed: %d\n", ret);
return ret;
}
*chan = arg.channel;
return ret;
return OK;
}

View File

@ -61,10 +61,11 @@ int ieee802154_getdevmode(int fd, FAR uint8_t *devmode)
ret = ioctl(fd, PHY802154IOC_GET_DEVMODE, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_DEVMODE failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_DEVMODE failed: %d\n", ret);
return ret;
}
*devmode = arg.devmode;
return ret;
return OK;
}

View File

@ -62,10 +62,11 @@ int ieee802154_geteaddr(int fd, FAR uint8_t *eaddr)
ret = ioctl(fd, PHY802154IOC_GET_EADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_EADDR failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_EADDR failed: %d\n", ret);
return ret;
}
memcpy(eaddr, arg.eaddr, EADDR_SIZE);
return ret;
return OK;
}

View File

@ -61,10 +61,11 @@ int ieee802154_getpanid(int fd, FAR uint16_t *panid)
ret = ioctl(fd, PHY802154IOC_GET_PANID, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_PANID failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_PANID failed: %d\n", ret);
return ret;
}
*panid = arg.panid;
return ret;
return OK;
}

View File

@ -61,10 +61,11 @@ int ieee802154_getpromisc(int fd, FAR bool *promisc)
ret = ioctl(fd, PHY802154IOC_GET_PROMISC, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_PROMISC failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_PROMISC failed: %d\n", ret);
return ret;
}
*promisc = arg.promisc;
return ret;
return OK;
}

View File

@ -61,10 +61,11 @@ int ieee802154_getsaddr(int fd, FAR uint16_t *saddr)
ret = ioctl(fd, PHY802154IOC_GET_SADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_SADDR failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_SADDR failed: %d\n", ret);
return ret;
}
*saddr = arg.saddr;
return ret;
return OK;
}

View File

@ -61,10 +61,11 @@ int ieee802154_gettxpwr(int fd, FAR int32_t *txpwr)
ret = ioctl(fd, PHY802154IOC_GET_TXPWR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_TXPWR failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_TXPWR failed: %d\n", ret);
return ret;
}
*txpwr = arg.txpwr;
return ret;
return OK;
}

View File

@ -44,6 +44,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
@ -64,7 +65,8 @@ int ieee802154_setcca(int fd, FAR struct ieee802154_cca_s *cca)
ret = ioctl(fd, PHY802154IOC_SET_CCA, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_SET_CCA failed\n");
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_CCA failed: %d\n", ret);
}
return ret;

View File

@ -39,11 +39,15 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include "wireless/ieee802154.h"
/****************************************************************************
@ -60,7 +64,8 @@ int ieee802154_setchan(int fd, uint8_t chan)
ret = ioctl(fd, PHY802154IOC_SET_CHAN, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_SET_CHAN failed\n");
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_CHAN failed: %d\n", ret);
}
return ret;

View File

@ -43,6 +43,7 @@
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
@ -63,7 +64,8 @@ int ieee802154_setdevmode(int fd, uint8_t devmode)
ret = ioctl(fd, PHY802154IOC_SET_DEVMODE, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_SET_DEVMODE failed\n");
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_DEVMODE failed: %d\n", ret);
}
return ret;

View File

@ -44,6 +44,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
@ -64,7 +65,8 @@ int ieee802154_seteaddr(int fd, FAR const uint8_t *eaddr)
ret = ioctl(fd, PHY802154IOC_SET_EADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_SET_EADDR failed\n");
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_EADDR failed: %d\n", ret);
}
return ret;

View File

@ -43,6 +43,7 @@
#include <sys/ioctl.h>
#include <stdint.h>
#include <stdio.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
@ -63,7 +64,8 @@ int ieee802154_setpanid(int fd, uint16_t panid)
ret = ioctl(fd, PHY802154IOC_SET_PANID, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_SET_PANID failed\n");
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_PANID failed: %d\n", ret);
}
return ret;

View File

@ -44,6 +44,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <errno.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
@ -64,7 +65,8 @@ int ieee802154_setpromisc(int fd, bool promisc)
ret = ioctl(fd, PHY802154IOC_SET_PROMISC, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_SET_PROMISC failed\n");
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_PROMISC failed: %d\n", ret);
}
return ret;

View File

@ -64,8 +64,8 @@ int ieee802154_setsaddr(int fd, uint16_t saddr)
ret = ioctl(fd, PHY802154IOC_SET_SADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_SET_SADDR failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_SADDR failed: %d\n", ret);
}
return ret;

View File

@ -63,8 +63,8 @@ int ieee802154_settxpwr(int fd, int32_t txpwr)
ret = ioctl(fd, PHY802154IOC_SET_TXPWR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_SET_TXPWR failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_TXPWR failed: %d\n", ret);
}
return ret;

View File

@ -64,10 +64,11 @@ int sixlowpan_energydetect(int sock, FAR const char *ifname, FAR bool *energy)
ret = ioctl(sock, PHY802154IOC_ENERGYDETECT, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_ENERGYDETECT failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_ENERGYDETECT failed: %d\n", ret);
return ret;
}
*energy = arg.u.energy;
return ret;
return OK;
}

View File

@ -65,10 +65,11 @@ int sixlowpan_getcca(int sock, FAR const char *ifname,
ret = ioctl(sock, PHY802154IOC_GET_CCA, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_CCA failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_CCA failed: %d\n", ret);
return ret;
}
memcpy(cca, &arg.u.cca, sizeof(struct ieee802154_cca_s));
return ret;
return OK;
}

View File

@ -64,10 +64,11 @@ int sixlowpan_getchan(int sock, FAR const char *ifname, FAR uint8_t *chan)
ret = ioctl(sock, PHY802154IOC_GET_CHAN, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_CHAN failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_CHAN failed: %d\n", ret);
return ret;
}
*chan = arg.u.channel;
return ret;
return OK;
}

View File

@ -63,10 +63,11 @@ int sixlowpan_getdevmode(int sock, FAR const char *ifname,
ret = ioctl(sock, PHY802154IOC_GET_DEVMODE, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_DEVMODE failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_DEVMODE failed: %d\n", ret);
return ret;
}
*devmode = arg.u.devmode;
return ret;
return OK;
}

View File

@ -64,10 +64,11 @@ int sixlowpan_geteaddr(int sock, FAR const char *ifname, FAR uint8_t *eaddr)
ret = ioctl(sock, PHY802154IOC_GET_EADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_EADDR failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_EADDR failed: %d\n", ret);
return ret;
}
memcpy(eaddr, arg.u.eaddr, EADDR_SIZE);
return ret;
return OK;
}

View File

@ -64,10 +64,11 @@ int sixlowpan_getpanid(int sock, FAR const char *ifname, FAR uint16_t *panid)
ret = ioctl(sock, PHY802154IOC_GET_PANID, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_PANID failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_PANID failed: %d\n", ret);
return ret;
}
*panid = arg.u.panid;
return ret;
return OK;
}

View File

@ -64,10 +64,11 @@ int sixlowpan_getpromisc(int sock, FAR const char *ifname, FAR bool *promisc)
ret = ioctl(sock, PHY802154IOC_GET_PROMISC, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_PROMISC failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_PROMISC failed: %d\n", ret);
return ret;
}
*promisc = arg.u.promisc;
return ret;
return OK;
}

View File

@ -64,10 +64,11 @@ int sixlowpan_getsaddr(int sock, FAR const char *ifname, FAR uint16_t *saddr)
ret = ioctl(sock, PHY802154IOC_GET_SADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_SADDR failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_SADDR failed: %d\n", ret);
return ret;
}
*saddr = arg.u.saddr;
return ret;
return OK;
}

View File

@ -64,10 +64,11 @@ int sixlowpan_gettxpwr(int sock, FAR const char *ifname, FAR int32_t *txpwr)
ret = ioctl(sock, PHY802154IOC_GET_TXPWR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_GET_TXPWR failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_GET_TXPWR failed: %d\n", ret);
return ret;
}
*txpwr = arg.u.txpwr;
return ret;
return OK;
}

View File

@ -65,8 +65,8 @@ int sixlowpan_setcca(int sock, FAR const char *ifname, FAR struct ieee802154_cca
ret = ioctl(sock, PHY802154IOC_SET_CCA, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_SET_CCA failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_CCA failed: %d\n", ret);
}
return ret;

View File

@ -65,8 +65,8 @@ int sixlowpan_setchan(int sock, FAR const char *ifname, uint8_t chan)
ret = ioctl(sock, PHY802154IOC_SET_CHAN, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_SET_CHAN failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_CHAN failed: %d\n", ret);
}
return ret;

View File

@ -65,8 +65,8 @@ int sixlowpan_setdevmode(int sock, FAR const char *ifname, uint8_t devmode)
ret = ioctl(sock, PHY802154IOC_SET_DEVMODE, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_SET_DEVMODE failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_DEVMODE failed: %d\n", ret);
}
return ret;

View File

@ -65,8 +65,8 @@ int sixlowpan_seteaddr(int sock, FAR const char *ifname, FAR const uint8_t *eadd
ret = ioctl(sock, PHY802154IOC_SET_EADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_SET_EADDR failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_EADDR failed: %d\n", ret);
}
return ret;

View File

@ -65,8 +65,8 @@ int sixlowpan_setpanid(int sock, FAR const char *ifname, uint16_t panid)
ret = ioctl(sock, PHY802154IOC_SET_PANID, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_SET_PANID failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_PANID failed: %d\n", ret);
}
return ret;

View File

@ -66,8 +66,8 @@ int sixlowpan_setpromisc(int sock, FAR const char *ifname, bool promisc)
ret = ioctl(sock, PHY802154IOC_SET_PROMISC, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_SET_PROMISC failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_PROMISC failed: %d\n", ret);
}
return ret;

View File

@ -65,8 +65,8 @@ int sixlowpan_setsaddr(int sock, FAR const char *ifname, uint16_t saddr)
ret = ioctl(sock, PHY802154IOC_SET_SADDR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_SET_SADDR failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_SADDR failed: %d\n", ret);
}
return ret;

View File

@ -65,8 +65,8 @@ int sixlowpan_settxpwr(int sock, FAR const char *ifname, int32_t txpwr)
ret = ioctl(sock, PHY802154IOC_SET_TXPWR, (unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
int errcode = errno;
printf("PHY802154IOC_SET_TXPWR failed: %d\n", errcode);
ret = -errno;
fprintf(stderr, "PHY802154IOC_SET_TXPWR failed: %d\n", ret);
}
return ret;