Kernel module should prefer functions with nx/kmm prefix

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2020-05-02 22:30:58 +08:00 committed by Alin Jerpelea
parent 15480e51cf
commit 0536953ded
52 changed files with 207 additions and 262 deletions

View file

@ -805,7 +805,7 @@ DMA_HANDLE cxd56_dmachannel(int ch, ssize_t maxsize)
dmach->list = (dmac_lli_t *)kmm_malloc(n * sizeof(dmac_lli_t));
if (dmach->list == NULL)
{
dmainfo("Failed to malloc\n");
dmainfo("Failed to kmm_malloc\n");
goto err;
}

View file

@ -174,7 +174,7 @@ struct cxd56_gnss_dev_s
sem_t syncsem;
uint8_t num_open;
uint8_t notify_data;
FAR FILE * cepfp;
struct file cepfp;
FAR void * cepbuf;
FAR struct pollfd *fds[CONFIG_CXD56_GNSS_NPOLLWAITERS];
#if !defined(CONFIG_DISABLE_SIGNAL) && \
@ -906,7 +906,7 @@ static int cxd56_gnss_save_backup_data(FAR struct file *filep,
unsigned long arg)
{
FAR char *buf;
FAR FILE *fp;
int fd;
int n = 0;
int32_t offset = 0;
@ -916,11 +916,11 @@ static int cxd56_gnss_save_backup_data(FAR struct file *filep,
return -ENOMEM;
}
fp = fopen(CONFIG_CXD56_GNSS_BACKUP_FILENAME, "wb");
if (fp == NULL)
fd = nx_open(CONFIG_CXD56_GNSS_BACKUP_FILENAME, O_WRONLY | O_CREAT | O_TRUNC);
if (fd < 0)
{
kmm_free(buf);
return -ENOENT;
return fd;
}
do
@ -932,13 +932,13 @@ static int cxd56_gnss_save_backup_data(FAR struct file *filep,
break;
}
n = fwrite(buf, 1, n, fp);
n = nx_write(fd, buf, n);
offset += n;
}
while (n == CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE);
kmm_free(buf);
fclose(fp);
nx_close(fd);
return n < 0 ? n : 0;
}
@ -2155,11 +2155,11 @@ static int cxd56_gnss_wait_notify(FAR sem_t *sem, time_t waitsec)
*
****************************************************************************/
static FAR char *cxd56_gnss_read_cep_file(FAR FILE *fp, int32_t offset,
size_t len, FAR int *retval)
static FAR char *
cxd56_gnss_read_cep_file(FAR struct file *fp, int32_t offset,
size_t len, FAR int *retval)
{
FAR char *buf;
size_t n = 0;
int ret;
if (fp == NULL)
@ -2175,21 +2175,19 @@ static FAR char *cxd56_gnss_read_cep_file(FAR FILE *fp, int32_t offset,
goto _err0;
}
ret = fseek(fp, offset, SEEK_SET);
ret = file_seek(fp, offset, SEEK_SET);
if (ret < 0)
{
goto _err1;
}
n = fread(buf, 1, len, fp);
if (n <= 0)
ret = file_read(fp, buf, len);
if (ret <= 0)
{
ret = n < 0 ? n : ferror(fp) ? -errno : 0;
clearerr(fp);
goto _err1;
}
*retval = n;
*retval = ret;
cxd56_cpu1sigsend(CXD56_CPU1_DATA_TYPE_CEP, (uint32_t)buf);
return buf;
@ -2224,7 +2222,7 @@ static FAR char *cxd56_gnss_read_cep_file(FAR FILE *fp, int32_t offset,
static void cxd56_gnss_read_backup_file(FAR int *retval)
{
FAR char * buf;
FAR FILE * fp;
int fd;
int32_t offset = 0;
size_t n;
int ret = 0;
@ -2236,20 +2234,20 @@ static void cxd56_gnss_read_backup_file(FAR int *retval)
goto _err;
}
fp = fopen(CONFIG_CXD56_GNSS_BACKUP_FILENAME, "rb");
if (fp == NULL)
fd = nx_open(CONFIG_CXD56_GNSS_BACKUP_FILENAME, O_RDONLY);
if (fd < 0)
{
kmm_free(buf);
ret = -ENOENT;
ret = fd;
goto _err;
}
do
{
n = fread(buf, 1, CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE, fp);
n = nx_read(fd, buf, CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE);
if (n <= 0)
{
ret = n < 0 ? n : ferror(fp) ? -ENFILE : 0;
ret = n;
break;
}
@ -2263,7 +2261,7 @@ static void cxd56_gnss_read_backup_file(FAR int *retval)
}
while (n > 0);
fclose(fp);
nx_close(fd);
kmm_free(buf);
/* Notify the termination of backup sequence by write zero length data */
@ -2316,7 +2314,7 @@ static void cxd56_gnss_common_signalhandler(uint32_t data,
union sigval value;
value.sival_ptr = &sig->info;
sigqueue(sig->pid, sig->info.signo, value);
nxsig_queue(sig->pid, sig->info.signo, value);
issetmask = 1;
}
}
@ -2363,7 +2361,7 @@ static void cxd56_gnss_default_sighandler(uint32_t data, FAR void *userdata)
case CXD56_GNSS_NOTIFY_TYPE_REQCEPDAT:
{
priv->cepbuf = cxd56_gnss_read_cep_file(
priv->cepfp, priv->shared_info.argv[GNSS_ARGS_FILE_OFFSET],
&priv->cepfp, priv->shared_info.argv[GNSS_ARGS_FILE_OFFSET],
priv->shared_info.argv[GNSS_ARGS_FILE_LENGTH],
&priv->shared_info.retval);
return;
@ -2395,19 +2393,18 @@ static void cxd56_gnss_default_sighandler(uint32_t data, FAR void *userdata)
return;
case CXD56_GNSS_NOTIFY_TYPE_REQCEPOPEN:
if (priv->cepfp != NULL)
if (priv->cepfp.f_inode != NULL)
{
fclose(priv->cepfp);
file_close(&priv->cepfp);
}
priv->cepfp = fopen(CONFIG_CXD56_GNSS_CEP_FILENAME, "rb");
file_open(&priv->cepfp, CONFIG_CXD56_GNSS_CEP_FILENAME, O_RDONLY);
return;
case CXD56_GNSS_NOTIFY_TYPE_REQCEPCLOSE:
if (priv->cepfp != NULL)
if (priv->cepfp.f_inode != NULL)
{
fclose(priv->cepfp);
priv->cepfp = NULL;
file_close(&priv->cepfp);
}
return;

View file

@ -42,6 +42,7 @@
#include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h>
#include <nuttx/irq.h>
#include <nuttx/signal.h>
#include <nuttx/semaphore.h>
#include <queue.h>
@ -259,7 +260,7 @@ static int icc_irqhandler(int cpuid, uint32_t word[2])
union sigval value;
value.sival_ptr = priv->sigdata;
sigqueue(priv->pid, priv->signo, value);
nxsig_queue(priv->pid, priv->signo, value);
}
#endif

View file

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#include <nuttx/irq.h>
#include <nuttx/signal.h>
#include <nuttx/semaphore.h>
#include <stdio.h>
@ -1523,7 +1524,7 @@ static void seq_handlefifointr(FAR struct cxd56_scudev_s *priv,
DEBUGASSERT(notify->pid != 0);
value.sival_ptr = notify->ts;
sigqueue(notify->pid, notify->signo, value);
nxsig_queue(notify->pid, notify->signo, value);
#endif
}
}
@ -1614,7 +1615,7 @@ static void seq_handlemathfintr(FAR struct cxd56_scudev_s *priv,
DEBUGASSERT(notify->pid != 0);
value.sival_ptr = notify->arg;
sigqueue(notify->pid, notify->signo, value);
nxsig_queue(notify->pid, notify->signo, value);
detected = 0;
}
#endif

View file

@ -63,6 +63,7 @@
#include <nuttx/fs/procfs.h>
#include <nuttx/irq.h>
#include <nuttx/signal.h>
#include <arch/chip/usbdev.h>
#include <arch/chip/pm.h>
@ -3404,7 +3405,7 @@ static void cxd56_notify_signal(uint16_t state, uint16_t power)
{
union sigval value;
value.sival_int = state << 16 | power;
sigqueue(priv->pid, priv->signo, value);
nxsig_queue(priv->pid, priv->signo, value);
}
}

View file

@ -616,55 +616,6 @@ static int msc_enable(int forced)
}
#endif
#ifdef CONFIG_LASTKMSG
/****************************************************************************
* Name: check_lastkmsg()
****************************************************************************/
void check_lastkmsg(void)
{
int ret;
FILE *fp;
if (g_lastksg_buf.sig != LASTKMSG_SIG)
{
return;
}
ret = mount(CONFIG_MTD_LOG_DEVPATH, "/log", "vfat", 0, NULL);
if (ret)
{
_info("mount: ret = %d\n", ret);
return;
}
/* log rotate */
unlink(LASTMSG_LOGPATH ".4");
rename(LASTMSG_LOGPATH ".3", LASTMSG_LOGPATH ".4");
rename(LASTMSG_LOGPATH ".2", LASTMSG_LOGPATH ".3");
rename(LASTMSG_LOGPATH ".1", LASTMSG_LOGPATH ".2");
rename(LASTMSG_LOGPATH ".0", LASTMSG_LOGPATH ".1");
fp = fopen(LASTMSG_LOGPATH ".0", "w");
if (fp)
{
lastkmsg_output(fp);
fflush(fp);
fclose(fp);
}
umount("/log");
/* XXX: workaround for logfile size = 0 */
nxsig_usleep(100000);
}
#endif /* CONFIG_LASTKMSG */
/****************************************************************************
* Name: ipl2_main()
****************************************************************************/

View file

@ -25,7 +25,6 @@
#include <nuttx/config.h>
#include <string.h>
#include <semaphore.h>
#include <errno.h>
#include <nuttx/arch.h>

View file

@ -3387,7 +3387,7 @@ struct i2s_dev_s *sam_ssc_initialize(int port)
}
/* Set up the initial state for this chip select structure. Other fields
* were zeroed by zalloc().
* were zeroed by kmm_zalloc().
*/
/* Initialize the common parts for the SSC device structure */

View file

@ -1814,7 +1814,7 @@ struct spi_dev_s *xmc4_spibus_initialize(int channel)
}
/* Set up the initial state for this chip select structure. Other fields
* were zeroed by zalloc().
* were zeroed by kmm_zalloc().
*/
#ifdef CONFIG_XMC4_SPI_DMA

View file

@ -33,7 +33,6 @@
# include <stdint.h>
# include <stdbool.h>
# include <arch/arch.h>
# include <semaphore.h>
# include <time.h>
# include <debug.h>
# include <nuttx/config.h>

View file

@ -206,6 +206,7 @@ static int32_t esp_task_ms_to_tick(uint32_t ms);
static void *esp_task_get_current_task(void);
static int32_t esp_task_get_max_priority(void);
static void *esp_malloc(uint32_t size);
static void esp_free(void *ptr);
static uint32_t esp_rand(void);
static void esp_dport_access_stall_other_cpu_start(void);
static void esp_dport_access_stall_other_cpu_end(void);
@ -394,7 +395,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs =
._task_get_current_task = esp_task_get_current_task,
._task_get_max_priority = esp_task_get_max_priority,
._malloc = esp_malloc,
._free = free,
._free = esp_free,
._event_post = esp_event_post,
._get_free_heap_size = esp_get_free_heap_size,
._rand = esp_rand,
@ -898,7 +899,7 @@ static void *esp_semphr_create(uint32_t max, uint32_t init)
return NULL;
}
ret = sem_init(sem, 0, init);
ret = nxsem_init(sem, 0, init);
if (ret)
{
wlerr("ERROR: Failed to initialize sem error=%d\n", ret);
@ -927,7 +928,7 @@ static void esp_semphr_delete(void *semphr)
{
sem_t *sem = (sem_t *)semphr;
sem_destroy(sem);
nxsem_destroy(sem);
kmm_free(sem);
}
@ -954,7 +955,7 @@ static int32_t esp_semphr_take(void *semphr, uint32_t ticks)
if (ticks == OSI_FUNCS_TIME_BLOCKING)
{
ret = sem_wait(sem);
ret = nxsem_wait(sem);
if (ret)
{
wlerr("ERROR: Failed to wait sem\n");
@ -974,7 +975,7 @@ static int32_t esp_semphr_take(void *semphr, uint32_t ticks)
esp_update_time(&timeout, ticks);
}
ret = sem_timedwait(sem, &timeout);
ret = nxsem_timedwait(sem, &timeout);
if (ret)
{
wlerr("ERROR: Failed to wait sem in %d ticks\n", ticks);
@ -1003,7 +1004,7 @@ static int32_t esp_semphr_give(void *semphr)
int ret;
sem_t *sem = (sem_t *)semphr;
ret = sem_post(sem);
ret = nxsem_post(sem);
if (ret)
{
wlerr("ERROR: Failed to post sem error=%d\n", ret);
@ -1260,7 +1261,7 @@ static void *esp_queue_create(uint32_t queue_len, uint32_t item_size)
mq_adpt = kmm_malloc(sizeof(struct mq_adpt));
if (!mq_adpt)
{
wlerr("ERROR: Failed to malloc\n");
wlerr("ERROR: Failed to kmm_malloc\n");
return NULL;
}
@ -1763,7 +1764,7 @@ static void esp_task_delay(uint32_t tick)
{
useconds_t us = TICK2USEC(tick);
usleep(us);
nxsig_usleep(us);
}
/****************************************************************************
@ -1841,7 +1842,26 @@ static int32_t esp_task_get_max_priority(void)
static void *esp_malloc(uint32_t size)
{
return malloc(size);
return kmm_malloc(size);
}
/****************************************************************************
* Name: esp_free
*
* Description:
* Free a block of memory
*
* Input Parameters:
* ptr - memory block
*
* Returned Value:
* No
*
****************************************************************************/
static void esp_free(void *ptr)
{
kmm_free(ptr);
}
/****************************************************************************
@ -1933,10 +1953,10 @@ static void esp_evt_work_cb(FAR void *arg)
break;
case WIFI_ADPT_EVT_STA_CONNECT:
g_connected = true;
ret = sem_post(&g_connect_sem);
ret = nxsem_post(&g_connect_sem);
if (ret)
{
wlerr("ERROR: Failed to post sem error=%d\n", errno);
wlerr("ERROR: Failed to post sem error=%d\n", ret);
}
break;
case WIFI_ADPT_EVT_STA_DISCONNECT:
@ -1969,7 +1989,7 @@ static void esp_evt_work_cb(FAR void *arg)
esp_event_lock(false);
free(evt_adpt);
kmm_free(evt_adpt);
}
}
@ -2067,7 +2087,7 @@ int32_t esp_event_post(esp_event_base_t event_base,
}
size = event_data_size + sizeof(struct evt_adpt);
evt_adpt = malloc(size);
evt_adpt = kmm_malloc(size);
if (!evt_adpt)
{
wlerr("ERROR: Failed to alloc %d memory\n", size);
@ -2270,7 +2290,7 @@ static void wifi_phy_enable(void)
cal_data = kmm_zalloc(sizeof(esp_phy_calibration_data_t));
if (!cal_data)
{
wlerr("ERROR: Failed to malloc");
wlerr("ERROR: Failed to kmm_zalloc");
DEBUGASSERT(0);
}
@ -3023,7 +3043,7 @@ static int32_t esp_nvs_set_blob(uint32_t handle,
size_t length)
{
#ifdef CONFIG_ESP32_WIFI_SAVE_PARAM
int fd;
struct file file;
int ret;
char *dir;
struct nvs_adpt *nvs_adpt = (struct nvs_adpt *)handle;
@ -3036,36 +3056,36 @@ static int32_t esp_nvs_set_blob(uint32_t handle,
return -1;
}
ret = unlink(dir);
ret = nx_unlink(dir);
if (ret)
{
if (errno != ENOENT)
if (ret != -ENOENT)
{
wlerr("ERROR: Failed to unlink %s error=%d\n", dir, errno);
free(dir);
wlerr("ERROR: Failed to unlink %s error=%d\n", dir, ret);
kmm_free(dir);
return -1;
}
}
fd = open(dir, O_WRONLY | O_CREAT, NVS_FILE_MODE);
if (fd < 0)
ret = file_open(&file, dir, O_WRONLY | O_CREAT, NVS_FILE_MODE);
if (ret < 0)
{
wlerr("ERROR: Failed to set open %s\n", dir);
free(dir);
kmm_free(dir);
return -1;
}
ret = write(fd, value, length);
ret = file_write(&file, value, length);
if (ret < 0)
{
wlerr("ERROR: Failed to write to %s\n", dir);
free(dir);
close(fd);
kmm_free(dir);
file_close(&file);
return -1;
}
free(dir);
close(fd);
kmm_free(dir);
file_close(&file);
return 0;
#else
@ -3098,7 +3118,7 @@ static int32_t esp_nvs_get_blob(uint32_t handle,
size_t *length)
{
#ifdef CONFIG_ESP32_WIFI_SAVE_PARAM
int fd;
struct file file;
int ret;
char *dir;
struct nvs_adpt *nvs_adpt = (struct nvs_adpt *)handle;
@ -3111,26 +3131,26 @@ static int32_t esp_nvs_get_blob(uint32_t handle,
return -1;
}
fd = open(dir, O_RDONLY);
if (fd < 0)
ret = file_open(&file, dir, O_RDONLY);
if (ret < 0)
{
if (errno == ENOENT)
if (ret == -ENOENT)
{
wlinfo("INFO: No file %s\n", dir);
free(dir);
kmm_free(dir);
return ESP_ERR_NVS_NOT_FOUND;
}
wlerr("ERROR: Failed to get open %s\n", dir);
free(dir);
kmm_free(dir);
return -1;
}
ret = read(fd, out_value, *length);
ret = file_read(&file, out_value, *length);
if (ret <= 0)
{
wlerr("ERROR: Failed to write to %s\n", dir);
free(dir);
close(fd);
kmm_free(dir);
file_close(&file);
return -1;
}
else
@ -3138,8 +3158,8 @@ static int32_t esp_nvs_get_blob(uint32_t handle,
*length = ret;
}
free(dir);
close(fd);
kmm_free(dir);
file_close(&file);
return 0;
#else
@ -3179,15 +3199,15 @@ static int32_t esp_nvs_erase_key(uint32_t handle, const char *key)
return -1;
}
ret = unlink(dir);
ret = nx_unlink(dir);
if (ret < 0)
{
wlerr("ERROR: Failed to delete NVS file %s\n", dir);
free(dir);
kmm_free(dir);
return -1;
}
free(dir);
kmm_free(dir);
return 0;
#else
@ -3484,7 +3504,7 @@ static void *esp_zalloc_internal(size_t size)
static void *esp_wifi_malloc(size_t size)
{
return malloc(size);
return kmm_malloc(size);
}
/****************************************************************************
@ -3504,7 +3524,7 @@ static void *esp_wifi_malloc(size_t size)
static void *esp_wifi_realloc(void *ptr, size_t size)
{
return realloc(ptr, size);
return kmm_realloc(ptr, size);
}
/****************************************************************************
@ -3524,7 +3544,7 @@ static void *esp_wifi_realloc(void *ptr, size_t size)
static void *esp_wifi_calloc(size_t n, size_t size)
{
return calloc(n, size);
return kmm_calloc(n, size);
}
/****************************************************************************
@ -3543,7 +3563,7 @@ static void *esp_wifi_calloc(size_t n, size_t size)
static void *esp_wifi_zalloc(size_t size)
{
return zalloc(size);
return kmm_zalloc(size);
}
/****************************************************************************
@ -3568,7 +3588,7 @@ static void *esp_wifi_create_queue(int32_t queue_len, int32_t item_size)
wifi_queue = kmm_malloc(sizeof(wifi_static_queue_t));
if (!wifi_queue)
{
wlerr("ERROR: Failed to malloc\n");
wlerr("ERROR: Failed to kmm_malloc\n");
return NULL;
}
@ -4631,10 +4651,10 @@ int esp_wifi_connect_internal(void)
clock_gettime(CLOCK_REALTIME, &timeout);
timeout.tv_sec += WIFI_CONNECT_TIMEOUT;
ret = sem_timedwait(&g_connect_sem, &timeout);
ret = nxsem_timedwait(&g_connect_sem, &timeout);
if (ret)
{
wlerr("ERROR: Failed to wait sem error=%d\n", errno);
wlerr("ERROR: Failed to wait sem error=%d\n", ret);
esp_wifi_stop();
return -1;
}

View file

@ -107,13 +107,12 @@ static int builtin_loadbinary(struct binary_s *binp)
* the file using the FIOC_FILENAME ioctl() call.
*/
ret = ioctl(fd, FIOC_FILENAME, (unsigned long)((uintptr_t)&filename));
ret = nx_ioctl(fd, FIOC_FILENAME, (unsigned long)((uintptr_t)&filename));
if (ret < 0)
{
int errval = get_errno();
berr("ERROR: FIOC_FILENAME ioctl failed: %d\n", errval);
close(fd);
return -errval;
berr("ERROR: FIOC_FILENAME ioctl failed: %d\n", ret);
nx_close(fd);
return ret;
}
/* Other file systems may also support FIOC_FILENAME, so the real proof
@ -124,7 +123,7 @@ static int builtin_loadbinary(struct binary_s *binp)
if (index < 0)
{
berr("ERROR: %s is not a builtin application\n", filename);
close(fd);
nx_close(fd);
return index;
}
@ -136,7 +135,7 @@ static int builtin_loadbinary(struct binary_s *binp)
binp->entrypt = builtin->main;
binp->stacksize = builtin->stacksize;
binp->priority = builtin->priority;
close(fd);
nx_close(fd);
return OK;
}

View file

@ -98,12 +98,11 @@ static inline int elf_filelen(FAR struct elf_loadinfo_s *loadinfo,
/* Get the file stats */
ret = stat(filename, &buf);
ret = nx_stat(filename, &buf, 1);
if (ret < 0)
{
int errval = get_errno();
berr("Failed to stat file: %d\n", errval);
return -errval;
berr("Failed to stat file: %d\n", ret);
return ret;
}
/* Verify that it is a regular file */
@ -177,7 +176,7 @@ int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo)
if (ret < 0)
{
berr("Failed to read ELF header: %d\n", ret);
close(loadinfo->filfd);
nx_close(loadinfo->filfd);
return ret;
}
@ -197,7 +196,7 @@ int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo)
*/
berr("Bad ELF header: %d\n", ret);
close(loadinfo->filfd);
nx_close(loadinfo->filfd);
return ret;
}

View file

@ -123,13 +123,12 @@ int elf_read(FAR struct elf_loadinfo_s *loadinfo, FAR uint8_t *buffer,
{
/* Seek to the next read position */
rpos = lseek(loadinfo->filfd, offset, SEEK_SET);
rpos = nx_seek(loadinfo->filfd, offset, SEEK_SET);
if (rpos != offset)
{
int errval = get_errno();
berr("Failed to seek to position %lu: %d\n",
(unsigned long)offset, errval);
return -errval;
(unsigned long)offset, (int)rpos);
return rpos;
}
/* Read the file data at offset into the user buffer */

View file

@ -87,7 +87,7 @@ int elf_uninit(struct elf_loadinfo_s *loadinfo)
if (loadinfo->filfd >= 0)
{
close(loadinfo->filfd);
nx_close(loadinfo->filfd);
}
return OK;

View file

@ -124,7 +124,7 @@ int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo)
if (ret < 0)
{
berr("ERROR: Failed to read NXFLAT header: %d\n", ret);
close(loadinfo->filfd);
nx_close(loadinfo->filfd);
return ret;
}
@ -143,7 +143,7 @@ int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo)
*/
berr("ERROR: Bad NXFLAT header\n");
close(loadinfo->filfd);
nx_close(loadinfo->filfd);
return -ENOEXEC;
}

View file

@ -128,12 +128,11 @@ int nxflat_read(struct nxflat_loadinfo_s *loadinfo, char *buffer,
bytesleft = readsize;
do
{
rpos = lseek(loadinfo->filfd, offset, SEEK_SET);
rpos = nx_seek(loadinfo->filfd, offset, SEEK_SET);
if (rpos != offset)
{
int errval = get_errno();
berr("Failed to seek to position %d: %d\n", offset, errval);
return -errval;
berr("Failed to seek to position %d: %d\n", offset, (int)rpos);
return rpos;
}
/* Read the file data at offset into the user buffer */

View file

@ -78,7 +78,7 @@ int nxflat_uninit(struct nxflat_loadinfo_s *loadinfo)
{
if (loadinfo->filfd >= 0)
{
close(loadinfo->filfd);
nx_close(loadinfo->filfd);
}
return OK;

View file

@ -138,7 +138,7 @@ static void board_sdcard_enable(FAR void *arg)
/* If not initialize SD slot */
if (!stat("/dev/mmcsd0", &stat_sdio) == 0)
if (!nx_stat("/dev/mmcsd0", &stat_sdio, 1) == 0)
{
/* Now bind the SDHC interface to the MMC/SD driver */
@ -159,7 +159,7 @@ static void board_sdcard_enable(FAR void *arg)
cxd56_sdhci_mediachange(g_sdhci.sdhci);
if (stat("/dev/mmcsd0", &stat_sdio) == 0)
if (nx_stat("/dev/mmcsd0", &stat_sdio, 1) == 0)
{
if (S_ISBLK(stat_sdio.st_mode))
{

View file

@ -440,7 +440,7 @@ int up_fillpage(FAR struct tcb_s *tcb, FAR void *vpage)
/* Seek to that position */
pos = lseek(g_pgsrc.fd, offset, SEEK_SET);
pos = nx_seek(g_pgsrc.fd, offset, SEEK_SET);
DEBUGASSERT(pos != (off_t)-1);
/* And read the page data from that offset */

View file

@ -441,7 +441,7 @@ int up_fillpage(FAR struct tcb_s *tcb, FAR void *vpage)
/* Seek to that position */
pos = lseek(g_pgsrc.fd, offset, SEEK_SET);
pos = nx_seek(g_pgsrc.fd, offset, SEEK_SET);
DEBUGASSERT(pos != (off_t)-1);
/* And read the page data from that offset */

View file

@ -487,7 +487,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0);
usleep(100);
nxsig_usleep(100);
#endif
#ifdef HIGHPRI_HAVE_INJECTED
@ -495,7 +495,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0);
usleep(100);
nxsig_usleep(100);
#endif
/* Lock global data */

View file

@ -529,7 +529,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0);
usleep(100);
nxsig_usleep(100);
#endif
#ifdef HIGHPRI_HAVE_INJECTED
@ -537,7 +537,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0);
usleep(100);
nxsig_usleep(100);
#endif
/* Lock global data */

View file

@ -174,7 +174,7 @@ int stm32_rgbled_setup(void)
/* Initialize led off */
nx_write(fd, "#000000", 8);
close(fd);
nx_close(fd);
/* Now we are initialized */

View file

@ -478,7 +478,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_REG, 0);
usleep(100);
nxsig_usleep(100);
#endif
#ifdef HIGHPRI_HAVE_INJECTED
@ -486,7 +486,7 @@ int highpri_main(int argc, char *argv[])
adc1->ad_ops->ao_ioctl(adc1, IO_TRIGGER_INJ, 0);
usleep(100);
nxsig_usleep(100);
#endif
/* Lock global data */

View file

@ -688,7 +688,7 @@ static int w25_wait_keypress(FAR char *keyset, int nseconds)
/* Delay 50 Milliseconds */
usleep(50 * 1000);
nxsig_usleep(50 * 1000);
/* Output a dot to stdout every 10 * 50 = 500 milliseconds */

View file

@ -28,7 +28,6 @@
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <semaphore.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>

View file

@ -741,7 +741,7 @@ static int tda19988_fetch_edid(struct tda1988_dev_s *priv)
if (edid == NULL)
{
lcderr("ERROR: Failed to realloc EDID\n");
lcderr("ERROR: Failed to kmm_realloc EDID\n");
ret = -ENOMEM;
goto done;
}

View file

@ -344,11 +344,11 @@ int losetup(FAR const char *devname, FAR const char *filename,
/* Get the size of the file */
ret = stat(filename, &sb);
ret = nx_stat(filename, &sb, 1);
if (ret < 0)
{
ferr("ERROR: Failed to stat %s: %d\n", filename, get_errno());
return -get_errno();
ferr("ERROR: Failed to stat %s: %d\n", filename, ret);
return ret;
}
/* Check if the file system is big enough for one block */

View file

@ -1658,7 +1658,7 @@ static void xfer_task_init(FAR struct altmdm_dev_s *priv)
sigset_t mask;
sigfillset(&mask);
sigprocmask(SIG_SETMASK, &mask, NULL);
nxsig_procmask(SIG_SETMASK, &mask, NULL);
init_svtimer(priv);
}

View file

@ -671,10 +671,10 @@ timer_t altmdm_sys_starttimer(int first_ms, int interval_ms,
sigemptyset(&mask);
nxsig_addset(&mask, MY_TIMER_SIGNAL);
ret = sigprocmask(SIG_UNBLOCK, &mask, NULL);
ret = nxsig_procmask(SIG_UNBLOCK, &mask, NULL);
if (ret != OK)
{
m_err("sigprocmask() failed:%d\n", ret);
m_err("nxsig_procmask() failed:%d\n", ret);
return NULL;
}
@ -683,10 +683,10 @@ timer_t altmdm_sys_starttimer(int first_ms, int interval_ms,
sigfillset(&sa.sa_mask);
nxsig_delset(&sa.sa_mask, MY_TIMER_SIGNAL);
ret = sigaction(MY_TIMER_SIGNAL, &sa, NULL);
ret = nxsig_action(MY_TIMER_SIGNAL, &sa, NULL, false);
if (ret != OK)
{
m_err("sigaction() failed:%d\n", ret);
m_err("nxsig_action() failed:%d\n", ret);
return NULL;
}
@ -760,7 +760,7 @@ void altmdm_sys_stoptimer(timer_t timerid)
timer_delete(timerid);
sigfillset(&mask);
sigprocmask(SIG_SETMASK, &mask, NULL);
nxsig_procmask(SIG_SETMASK, &mask, NULL);
}
#endif

View file

@ -625,10 +625,10 @@ FAR struct mtd_dev_s *filemtd_initialize(FAR const char *path, size_t offset,
/* Stat the file */
ret = stat(path, &sb);
ret = nx_stat(path, &sb, 1);
if (ret < 0)
{
ferr("ERROR: Failed to stat %s: %d\n", path, get_errno());
ferr("ERROR: Failed to stat %s: %d\n", path, ret);
return NULL;
}

View file

@ -6362,8 +6362,8 @@ static int smart_losetup(int minor, FAR const char *filename,
for (x = 0; x < 256; x++)
{
snprintf(devpath, sizeof(devpath), "/dev/smart%d", x);
ret = stat(devpath, &sb);
if (ret != 0)
ret = nx_stat(devpath, &sb, 1);
if (ret < 0)
{
/* We can use this minor number */

View file

@ -1637,7 +1637,7 @@ static int bq769x0_getcurrent(FAR struct bq769x0_dev_s *priv,
/* Sample is not complete, wait and try again */
usleep(BQ769X0_CC_POLL_INTERVAL * USEC_PER_MSEC);
nxsig_usleep(BQ769X0_CC_POLL_INTERVAL * USEC_PER_MSEC);
}
/* CC value didn't become available in the expected amount of time */

View file

@ -404,7 +404,7 @@ void uart_recvchars_done(FAR uart_dev_t *dev)
if (signo != 0)
{
kill(dev->pid, signo);
nxsig_kill(dev->pid, signo);
uart_reset_sem(dev);
}
#endif

View file

@ -46,9 +46,9 @@
#include <sys/types.h>
#include <stdint.h>
#include <signal.h>
#include <debug.h>
#include <nuttx/signal.h>
#include <nuttx/serial/serial.h>
/****************************************************************************
@ -297,7 +297,7 @@ void uart_recvchars(FAR uart_dev_t *dev)
if (signo != 0)
{
kill(dev->pid, signo);
nxsig_kill(dev->pid, signo);
uart_reset_sem(dev);
}
#endif

View file

@ -448,9 +448,7 @@ FAR struct ieee802154_radio_s *
if (lower->attach(lower, mrf24j40_interrupt, dev) != OK)
{
#if 0
kmm_free(dev);
#endif
return NULL;
}

View file

@ -100,10 +100,10 @@ static FAR char *unique_blkdev(void)
/* Make sure that file name is not in use */
ret = stat(devbuf, &statbuf);
ret = nx_stat(devbuf, &statbuf, 1);
if (ret < 0)
{
DEBUGASSERT(errno == ENOENT);
DEBUGASSERT(ret == -ENOENT);
return strdup(devbuf);
}

View file

@ -560,12 +560,8 @@ static int hostfs_rpmsg_stat_handler(FAR struct rpmsg_endpoint *ept,
struct stat buf;
int ret;
ret = stat(msg->pathname, &buf);
if (ret)
{
ret = -get_errno();
}
else
ret = nx_stat(msg->pathname, &buf, 1);
if (ret >= 0)
{
msg->buf = buf;
}

View file

@ -127,7 +127,6 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
int fd, off_t offset)
{
FAR void *addr;
int errcode;
int ret = -1;
/* Since only a tiny subset of mmap() functionality, we have to verify many
@ -144,7 +143,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
(flags & (MAP_FIXED | MAP_DENYWRITE)) != 0)
{
ferr("ERROR: Unsupported options, prot=%x flags=%04x\n", prot, flags);
errcode = ENOSYS;
ret = -ENOSYS;
goto errout;
}
@ -153,7 +152,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
if (length == 0)
{
ferr("ERROR: Invalid length, length=%zu\n", length);
errcode = EINVAL;
ret = -EINVAL;
goto errout;
}
#endif
@ -178,7 +177,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
if (alloc == NULL)
{
ferr("ERROR: kumm_alloc() failed: %d\n", ret);
errcode = ENOMEM;
ret = -ENOMEM;
goto errout;
}
@ -193,7 +192,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
if ((flags & MAP_PRIVATE) == 0)
{
ret = ioctl(fd, FIOC_MMAP, (unsigned long)((uintptr_t)&addr));
ret = nx_ioctl(fd, FIOC_MMAP, (unsigned long)((uintptr_t)&addr));
}
if (ret < 0)
@ -211,8 +210,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
#else
/* Error out. The errno value was already set by ioctl() */
ferr("ERROR: ioctl(FIOC_MMAP) failed: %d\n", get_errno());
errcode = ENOSYS;
ferr("ERROR: ioctl(FIOC_MMAP) failed: %d\n", ret);
goto errout;
#endif
}
@ -222,6 +220,6 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
return (FAR void *)(((FAR uint8_t *)addr) + offset);
errout:
set_errno(errcode);
set_errno(-ret);
return MAP_FAILED;
}

View file

@ -122,7 +122,6 @@ FAR void *rammap(int fd, size_t length, off_t offset)
FAR uint8_t *rdbuffer;
ssize_t nread;
off_t fpos;
int errcode;
int ret;
/* There is a major design flaw that I have not yet thought of fix for:
@ -144,7 +143,7 @@ FAR void *rammap(int fd, size_t length, off_t offset)
if (!alloc)
{
ferr("ERROR: Region allocation failed, length: %d\n", (int)length);
errcode = ENOMEM;
ret = -ENOMEM;
goto errout;
}
@ -158,15 +157,15 @@ FAR void *rammap(int fd, size_t length, off_t offset)
/* Seek to the specified file offset */
fpos = lseek(fd, offset, SEEK_SET);
if (fpos == (off_t)-1)
fpos = nx_seek(fd, offset, SEEK_SET);
if (fpos < 0)
{
/* Seek failed... errno has already been set, but EINVAL is probably
* the correct response.
*/
ferr("ERROR: Seek to position %d failed\n", (int)offset);
errcode = EINVAL;
ret = fpos;
goto errout_with_region;
}
@ -189,7 +188,7 @@ FAR void *rammap(int fd, size_t length, off_t offset)
ferr("ERROR: Read failed: offset=%d errno=%d\n",
(int)offset, (int)nread);
errcode = (int)-nread;
ret = nread;
goto errout_with_region;
}
}
@ -217,11 +216,10 @@ FAR void *rammap(int fd, size_t length, off_t offset)
ret = nxsem_wait(&g_rammaps.exclsem);
if (ret < 0)
{
errcode = -ret;
goto errout_with_region;
}
map->flink = g_rammaps.head;
map->flink = g_rammaps.head;
g_rammaps.head = map;
nxsem_post(&g_rammaps.exclsem);
@ -231,7 +229,7 @@ errout_with_region:
kumm_free(alloc);
errout:
set_errno(errcode);
set_errno(-ret);
return MAP_FAILED;
}

View file

@ -198,12 +198,12 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
/* Then let poll do all of the real work. */
ret = poll(pollset, npfds, msec);
ret = nx_poll(pollset, npfds, msec);
if (ret < 0)
{
/* poll() failed! Save the errno value */
errcode = get_errno();
errcode = -ret;
}
/* Now set up the return values */

View file

@ -80,7 +80,7 @@ static inline void nxmu_disconnect(FAR struct nxmu_conn_s *conn)
/* Close the outgoing client message queue */
mq_close(conn->swrmq);
nxmq_close(conn->swrmq);
}
/****************************************************************************
@ -101,10 +101,10 @@ static inline void nxmu_connect(FAR struct nxmu_conn_s *conn)
* client
*/
conn->swrmq = mq_open(mqname, O_WRONLY);
if (conn->swrmq == (mqd_t)-1)
ret = nxmq_open(mqname, O_WRONLY, 0, NULL, &conn->swrmq);
if (ret < 0)
{
gerr("ERROR: mq_open(%s) failed: %d\n", mqname, errno);
gerr("ERROR: nxmq_open(%s) failed: %d\n", mqname, ret);
outmsg.msgid = NX_CLIMSG_DISCONNECTED;
}
@ -205,12 +205,11 @@ static inline int nxmu_setup(FAR const char *mqname, FAR NX_DRIVERTYPE *dev,
attr.mq_msgsize = NX_MXSVRMSGLEN;
attr.mq_flags = 0;
nxmu->conn.crdmq = mq_open(mqname, O_RDONLY | O_CREAT, 0666, &attr);
if (nxmu->conn.crdmq == (mqd_t)-1)
ret = nxmq_open(mqname, O_RDONLY | O_CREAT, 0666, &attr, &nxmu->conn.crdmq);
if (ret < 0)
{
int errcode = get_errno();
gerr("ERROR: mq_open(%s) failed: %d\n", mqname, errcode);
return -errcode;
gerr("ERROR: nxmq_open(%s) failed: %d\n", mqname, ret);
return ret;
}
/* NOTE that the outgoing client MQ (cwrmq) is not initialized. The
@ -222,13 +221,12 @@ static inline int nxmu_setup(FAR const char *mqname, FAR NX_DRIVERTYPE *dev,
* the server message loop.
*/
nxmu->conn.swrmq = mq_open(mqname, O_WRONLY);
if (nxmu->conn.swrmq == (mqd_t)-1)
ret = nxmq_open(mqname, O_WRONLY, 0, NULL, &nxmu->conn.swrmq);
if (ret < 0)
{
int errcode = get_errno();
gerr("ERROR: mq_open(%s) failed: %d\n", mqname, errcode);
mq_close(nxmu->conn.crdmq);
return -errcode;
gerr("ERROR: nxmq_open(%s) failed: %d\n", mqname, ret);
nxmq_close(nxmu->conn.crdmq);
return ret;
}
/* The server is now "connected" to itself via the background window */

View file

@ -31,9 +31,10 @@
#include <stdbool.h>
#include <stdint.h>
#include <semaphore.h>
#include <fixedmath.h>
#include <nuttx/semaphore.h>
#ifdef CONFIG_BATTERY_MONITOR
/****************************************************************************

View file

@ -82,7 +82,7 @@ struct i2c_master_s;
* Or, if using dynamic memory allocation and I2C:
*
* struct mpu_config_s* mpuc;
* mpuc = malloc(sizeof(*mpuc));
* mpuc = kmm_malloc(sizeof(*mpuc));
* memset(mpuc, 0, sizeof(*mpuc)); * sets spi to NULL, if present *
* mpuc.i2c = ...;
*

View file

@ -89,8 +89,8 @@
# define EP_ALLOCBUFFER(ep,nb) (ep)->ops->allocbuffer(ep,nb)
# define EP_FREEBUFFER(ep,buf) (ep)->ops->freebuffer(ep,buf)
#else
# define EP_ALLOCBUFFER(ep,nb) malloc(nb)
# define EP_FREEBUFFER(ep,buf) free(buf)
# define EP_ALLOCBUFFER(ep,nb) kmm_malloc(nb)
# define EP_FREEBUFFER(ep,buf) kmm_free(buf)
#endif
/* Submit an I/O request to the endpoint */

View file

@ -155,7 +155,7 @@ static bool local_fifo_exists(FAR const char *path)
/* Create the client-to-server FIFO */
ret = stat(path, &buf);
ret = nx_stat(path, &buf, 1);
if (ret < 0)
{
return false;

View file

@ -434,7 +434,7 @@ netlink_get_response(FAR struct netlink_conn_s *conn)
/* Set up a semaphore to notify us when a response is queued. */
sem_init(&waitsem, 0, 0);
nxsem_init(&waitsem, 0, 0);
nxsem_set_protocol(&waitsem, SEM_PRIO_NONE);
/* Set up a notifier to post the semaphore when a response is
@ -456,7 +456,7 @@ netlink_get_response(FAR struct netlink_conn_s *conn)
/* Clean-up the semaphore */
sem_destroy(&waitsem);
nxsem_destroy(&waitsem);
netlink_notifier_teardown(conn);
/* Check for any failures */

View file

@ -146,17 +146,14 @@ int net_routesize(FAR const char *path, size_t entrysize)
/* Get information about the file */
ret = stat(path, &buf);
ret = nx_stat(path, &buf, 1);
if (ret < 0)
{
int errcode;
/* stat() failed, but is that because the routing table has not been
/* nx_stat() failed, but is that because the routing table has not been
* created yet?
*/
errcode = get_errno();
if (errcode == ENOENT)
if (ret == -ENOENT)
{
/* The routing table file has not been created. Return size zero. */
@ -165,7 +162,7 @@ int net_routesize(FAR const char *path, size_t entrysize)
/* Some other error */
return -errcode;
return ret;
}
/* The directory entry at this path must be a regular file */

View file

@ -415,10 +415,9 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path,
* for use within the OS.
*/
ret = waitpid(proxy, &status, 0);
ret = nx_waitpid(proxy, &status, 0);
if (ret < 0)
{
ret = -get_errno();
serr("ERROR: waitpid() failed: %d\n", ret);
goto errout_with_lock;
}

View file

@ -416,10 +416,9 @@ int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry,
* for use within the OS.
*/
ret = waitpid(proxy, &status, 0);
ret = nx_waitpid(proxy, &status, 0);
if (ret < 0)
{
ret = -get_errno();
serr("ERROR: waitpid() failed: %d\n", ret);
goto errout_with_lock;
}

View file

@ -84,13 +84,11 @@ static inline int nxspawn_dup2(FAR struct spawn_dup2_file_action_s *action)
sinfo("Dup'ing %d->%d\n", action->fd1, action->fd2);
ret = dup2(action->fd1, action->fd2);
ret = nx_dup2(action->fd1, action->fd2);
if (ret < 0)
{
int errcode = get_errno();
serr("ERROR: dup2 failed: %d\n", errcode);
return -errcode;
serr("ERROR: dup2 failed: %d\n", ret);
return ret;
}
return OK;
@ -123,10 +121,9 @@ static inline int nxspawn_open(FAR struct spawn_open_file_action_s *action)
sinfo("Dup'ing %d->%d\n", fd, action->fd);
ret = dup2(fd, action->fd);
ret = nx_dup2(fd, action->fd);
if (ret < 0)
{
ret = get_errno();
serr("ERROR: dup2 failed: %d\n", ret);
}