This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push: new 68902d8 pid_t: unify usage of special task IDs 68902d8 is described below commit 68902d8732182ad8a6deedd60c5233d76108e6d3 Author: Petro Karashchenko <petro.karashche...@gmail.com> AuthorDate: Mon Mar 21 23:47:09 2022 +0100 pid_t: unify usage of special task IDs Signed-off-by: Petro Karashchenko <petro.karashche...@gmail.com> --- arch/arm/include/cxd56xx/crashdump.h | 2 +- arch/arm/src/arm/arm_initialstate.c | 2 +- arch/arm/src/armv6-m/arm_initialstate.c | 2 +- arch/arm/src/armv7-a/arm_initialstate.c | 2 +- arch/arm/src/armv7-m/arm_initialstate.c | 2 +- arch/arm/src/armv7-r/arm_initialstate.c | 2 +- arch/arm/src/armv8-m/arm_initialstate.c | 2 +- arch/arm/src/cxd56xx/cxd56_cpu1signal.c | 19 ++++++++++------- arch/arm/src/cxd56xx/cxd56_gnss.c | 4 ++-- arch/arm/src/cxd56xx/cxd56_icc.c | 2 +- arch/arm/src/cxd56xx/cxd56_scu.c | 4 ++-- arch/arm/src/cxd56xx/cxd56_usbdev.c | 2 +- arch/arm/src/rtl8720c/amebaz_depend.c | 2 +- arch/arm/src/rtl8720c/amebaz_depend.h | 2 +- arch/arm/src/tiva/common/tiva_can.c | 4 ++-- arch/avr/src/avr/up_initialstate.c | 2 +- arch/avr/src/avr32/up_initialstate.c | 2 +- arch/ceva/src/common/up_assert.c | 2 +- arch/ceva/src/xc5/up_initialstate.c | 2 +- arch/ceva/src/xm6/up_initialstate.c | 2 +- arch/hc/src/m9s12/m9s12_initialstate.c | 2 +- arch/mips/src/mips32/mips_initialstate.c | 2 +- arch/misoc/src/lm32/lm32_initialstate.c | 2 +- arch/misoc/src/minerva/minerva_initialstate.c | 2 +- arch/or1k/src/common/up_initialstate.c | 2 +- arch/renesas/src/m16c/m16c_initialstate.c | 2 +- arch/renesas/src/rx65n/rx65n_initialstate.c | 2 +- arch/renesas/src/sh1/sh1_initialstate.c | 2 +- arch/risc-v/src/bl602/bl602_os_hal.c | 8 +++++--- arch/risc-v/src/common/riscv_initialstate.c | 2 +- arch/risc-v/src/esp32c3/esp32c3_ble_adapter.c | 2 +- arch/risc-v/src/esp32c3/esp32c3_rt_timer.c | 10 ++++----- arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c | 2 +- arch/sim/src/sim/up_initialstate.c | 2 +- arch/sparc/src/sparc_v8/up_dumpstate.c | 2 +- arch/sparc/src/sparc_v8/up_initialstate.c | 2 +- arch/x86/src/i486/up_initialstate.c | 2 +- arch/x86_64/src/intel64/up_initialstate.c | 2 +- arch/xtensa/src/common/xtensa_initialstate.c | 2 +- arch/xtensa/src/esp32/esp32_ble_adapter.c | 2 +- arch/xtensa/src/esp32/esp32_rt_timer.c | 16 +++++++++++---- arch/xtensa/src/esp32/esp32_wifi_adapter.c | 2 +- arch/xtensa/src/esp32s2/esp32s2_rt_timer.c | 10 ++++----- arch/xtensa/src/esp32s3/esp32s3_rt_timer.c | 10 ++++----- arch/z80/src/z180/z180_initialstate.c | 2 +- arch/z80/src/z80/z80_initialstate.c | 2 +- boards/arm/imxrt/imxrt1020-evk/src/imxrt_usbhost.c | 5 ++--- boards/arm/imxrt/imxrt1060-evk/src/imxrt_usbhost.c | 5 ++--- boards/arm/imxrt/imxrt1064-evk/src/imxrt_usbhost.c | 5 ++--- .../arm/kinetis/freedom-k28f/src/k28_usbhshost.c | 5 ++--- boards/arm/kinetis/twr-k64f120m/README.txt | 2 +- .../lpc4088-devkit/src/lpc17_40_bringup.c | 5 ++--- .../lpc4088-quickstart/src/lpc17_40_bringup.c | 5 ++--- .../arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c | 5 ++--- .../lpc17xx_40xx/mcb1700/src/lpc17_40_bringup.c | 5 ++--- .../olimex-lpc1766stk/src/lpc17_40_bringup.c | 5 ++--- .../lpc17xx_40xx/open1788/src/lpc17_40_bringup.c | 5 ++--- boards/arm/lpc31xx/ea3131/src/lpc31_usbhost.c | 5 ++--- .../lpc31xx/olimex-lpc-h3131/src/lpc31_usbhost.c | 5 ++--- boards/arm/sama5/giant-board/src/sam_usb.c | 9 ++++---- boards/arm/sama5/sama5d2-xult/src/sam_usb.c | 9 ++++---- boards/arm/sama5/sama5d3-xplained/src/sam_usb.c | 9 ++++---- boards/arm/sama5/sama5d3x-ek/src/sam_usb.c | 9 ++++---- boards/arm/sama5/sama5d4-ek/src/sam_usb.c | 9 ++++---- boards/arm/samd5e5/metro-m4/src/sam_usbhost.c | 10 ++++----- boards/arm/stm32/axoloti/src/stm32_usbhost.c | 10 ++++----- boards/arm/stm32/cloudctrl/src/stm32_usb.c | 5 ++--- boards/arm/stm32/mikroe-stm32f4/src/stm32_usb.c | 5 ++--- boards/arm/stm32/nucleo-f207zg/src/stm32_usb.c | 8 ++------ boards/arm/stm32/nucleo-f412zg/src/stm32_usb.c | 9 ++------ boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c | 2 +- boards/arm/stm32/nucleo-f429zi/src/stm32_usb.c | 8 ++------ boards/arm/stm32/olimex-stm32-e407/src/stm32_usb.c | 8 ++------ boards/arm/stm32/olimex-stm32-h407/src/stm32_usb.c | 5 ++--- boards/arm/stm32/olimex-stm32-p207/src/stm32_usb.c | 7 ++----- boards/arm/stm32/olimex-stm32-p407/src/stm32_usb.c | 7 ++----- boards/arm/stm32/omnibusf4/src/stm32_usb.c | 13 ++++-------- boards/arm/stm32/shenzhou/src/stm32_usb.c | 5 ++--- boards/arm/stm32/stm3220g-eval/src/stm32_usb.c | 5 ++--- boards/arm/stm32/stm3240g-eval/src/stm32_usb.c | 9 ++++---- boards/arm/stm32/stm32f411-minimum/src/stm32_usb.c | 9 ++------ boards/arm/stm32/stm32f411e-disco/src/stm32_usb.c | 9 ++------ boards/arm/stm32/stm32f429i-disco/src/stm32_usb.c | 5 ++--- boards/arm/stm32/stm32f4discovery/src/stm32_usb.c | 13 ++++-------- .../stm32/viewtool-stm32f107/src/stm32_max3421e.c | 13 ++++++------ boards/arm/stm32f7/nucleo-144/src/stm32_usb.c | 8 ++------ boards/arm/stm32f7/stm32f746-ws/src/stm32_usb.c | 8 ++------ boards/arm/stm32h7/nucleo-h743zi/src/stm32_usb.c | 8 ++------ boards/arm/stm32h7/nucleo-h743zi2/src/stm32_usb.c | 8 ++------ .../arm/stm32h7/stm32h747i-disco/src/stm32_usb.c | 8 ++------ boards/arm/stm32l4/nucleo-l496zg/src/stm32_usb.c | 8 ++------ .../arm/stm32l4/stm32l476vg-disco/src/stm32_usb.c | 8 ++------ .../arm/stm32l4/stm32l4r9ai-disco/src/stm32_usb.c | 8 ++------ .../pic32mx-starterkit/src/pic32mx_appinit.c | 5 ++--- .../mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c | 5 ++--- .../pic32mx/sure-pic32mx/src/pic32mx_appinit.c | 5 ++--- .../renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c | 7 +++---- .../renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c | 2 +- .../renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c | 7 +++---- .../renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c | 2 +- drivers/1wire/1wire.c | 2 +- drivers/lcd/ft80x.h | 2 +- drivers/net/phy_notify.c | 4 ++-- drivers/net/slip.c | 24 +++++++++++++--------- drivers/net/telnet.c | 17 ++++++++------- drivers/rptun/rptun.c | 11 ++++------ drivers/sensors/fakesensor.c | 3 ++- drivers/serial/serial.c | 4 ++-- drivers/syslog/syslog_device.c | 8 ++++---- drivers/usbdev/usbmsc.c | 13 ++++++------ drivers/usbhost/usbhost_hidkbd.c | 12 +++++------ drivers/usbhost/usbhost_hidmouse.c | 12 +++++------ drivers/usbhost/usbhost_max3421e.c | 6 ++++-- drivers/usbhost/usbhost_xboxcontroller.c | 13 ++++++------ drivers/usbmonitor/usbmonitor.c | 2 +- drivers/video/vnc/vnc_fbdev.c | 10 ++++----- drivers/wireless/bluetooth/bt_uart_shim.c | 12 ++++++----- drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.c | 2 +- drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.h | 2 +- fs/aio/aio_initialize.c | 20 ++++-------------- fs/inode/fs_inode.c | 2 +- fs/procfs/fs_procfsmeminfo.c | 6 +++--- fs/spiffs/src/spiffs.h | 2 +- graphics/nxmu/nxmu_start.c | 6 +++--- graphics/nxterm/nxterm.h | 2 +- include/nuttx/sched.h | 2 +- libs/libc/modlib/modlib_registry.c | 2 +- mm/mm_heap/mm.h | 4 ++-- net/route/net_fileroute.c | 2 +- net/utils/net_lock.c | 3 ++- sched/mqueue/mq_notify.c | 2 +- sched/pthread/pthread_cancel.c | 2 +- sched/pthread/pthread_condclockwait.c | 2 +- sched/pthread/pthread_condwait.c | 2 +- sched/pthread/pthread_create.c | 2 +- sched/pthread/pthread_mutexconsistent.c | 2 +- sched/pthread/pthread_mutexdestroy.c | 4 ++-- sched/pthread/pthread_mutexinit.c | 2 +- sched/pthread/pthread_mutextimedlock.c | 2 +- sched/pthread/pthread_mutextrylock.c | 2 +- sched/pthread/pthread_mutexunlock.c | 2 +- sched/sched/sched_idletask.c | 2 +- sched/sched/sched_wait.c | 8 ++++---- sched/sched/sched_waitpid.c | 16 +++++++-------- sched/task/task_getpid.c | 2 +- sched/task/task_getppid.c | 2 +- sched/task/task_posixspawn.c | 4 ++-- sched/task/task_vfork.c | 2 +- wireless/bluetooth/bt_conn.c | 9 ++++---- wireless/bluetooth/bt_hcicore.c | 8 +++----- 150 files changed, 359 insertions(+), 456 deletions(-) diff --git a/arch/arm/include/cxd56xx/crashdump.h b/arch/arm/include/cxd56xx/crashdump.h index cabdf1c..e6b7dd1 100644 --- a/arch/arm/include/cxd56xx/crashdump.h +++ b/arch/arm/include/cxd56xx/crashdump.h @@ -104,7 +104,7 @@ typedef struct fault_flags_t flags; /* What is in the dump */ uintptr_t current_regs; /* Used to validate the dump */ int lineno; /* __LINE__ to up_assert */ - int pid; /* Process ID */ + pid_t pid; /* Process ID */ uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */ stack_t stacks; /* Stack info */ #if CONFIG_TASK_NAME_SIZE > 0 diff --git a/arch/arm/src/arm/arm_initialstate.c b/arch/arm/src/arm/arm_initialstate.c index 6a49db4..e4e0c74 100644 --- a/arch/arm/src/arm/arm_initialstate.c +++ b/arch/arm/src/arm/arm_initialstate.c @@ -61,7 +61,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { tcb->stack_alloc_ptr = (void *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/arm/src/armv6-m/arm_initialstate.c b/arch/arm/src/armv6-m/arm_initialstate.c index 59482b9..b3e068f 100644 --- a/arch/arm/src/armv6-m/arm_initialstate.c +++ b/arch/arm/src/armv6-m/arm_initialstate.c @@ -62,7 +62,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { tcb->stack_alloc_ptr = (void *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/arm/src/armv7-a/arm_initialstate.c b/arch/arm/src/armv7-a/arm_initialstate.c index 9489b51..36650eb 100644 --- a/arch/arm/src/armv7-a/arm_initialstate.c +++ b/arch/arm/src/armv7-a/arm_initialstate.c @@ -61,7 +61,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { tcb->stack_alloc_ptr = (void *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/arm/src/armv7-m/arm_initialstate.c b/arch/arm/src/armv7-m/arm_initialstate.c index 2c51446..e57cdb9 100644 --- a/arch/arm/src/armv7-m/arm_initialstate.c +++ b/arch/arm/src/armv7-m/arm_initialstate.c @@ -63,7 +63,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { tcb->stack_alloc_ptr = (void *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/arm/src/armv7-r/arm_initialstate.c b/arch/arm/src/armv7-r/arm_initialstate.c index 41d173a..1c40415 100644 --- a/arch/arm/src/armv7-r/arm_initialstate.c +++ b/arch/arm/src/armv7-r/arm_initialstate.c @@ -61,7 +61,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { tcb->stack_alloc_ptr = (void *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/arm/src/armv8-m/arm_initialstate.c b/arch/arm/src/armv8-m/arm_initialstate.c index 3b2714b..bb92eb1 100644 --- a/arch/arm/src/armv8-m/arm_initialstate.c +++ b/arch/arm/src/armv8-m/arm_initialstate.c @@ -63,7 +63,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { tcb->stack_alloc_ptr = (void *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/arm/src/cxd56xx/cxd56_cpu1signal.c b/arch/arm/src/cxd56xx/cxd56_cpu1signal.c index 1dcccc6..d7b70a0 100644 --- a/arch/arm/src/cxd56xx/cxd56_cpu1signal.c +++ b/arch/arm/src/cxd56xx/cxd56_cpu1signal.c @@ -26,6 +26,7 @@ #include <stdlib.h> #include <errno.h> #include <sched.h> +#include <nuttx/sched.h> #include <nuttx/kthread.h> #include <debug.h> @@ -59,7 +60,7 @@ struct cxd56_sigtype_s struct cxd56cpu1_info_s { - int workerpid; + pid_t workerpid; int ndev; struct cxd56_sigtype_s sigtype[CXD56_CPU1_DATA_TYPE_MAX]; }; @@ -70,7 +71,11 @@ struct cxd56cpu1_info_s static struct cxd56cpu1_info_s g_cpu1_info = { - 0 + INVALID_PROCESS_ID, + 0, + { + 0 + } }; /**************************************************************************** @@ -193,9 +198,9 @@ int cxd56_cpu1siginit(uint8_t sigtype, FAR void *data) } pid = kthread_create("gnss_receiver", - CONFIG_CXD56CPU1_WORKER_THREAD_PRIORITY, - CONFIG_CXD56CPU1_WORKER_STACKSIZE, cxd56cpu1_worker, - (FAR char * const *) NULL); + CONFIG_CXD56CPU1_WORKER_THREAD_PRIORITY, + CONFIG_CXD56CPU1_WORKER_STACKSIZE, cxd56cpu1_worker, + (FAR char * const *) NULL); if (pid < 0) { @@ -221,7 +226,7 @@ err1: int cxd56_cpu1siguninit(uint8_t sigtype) { struct cxd56cpu1_info_s *priv = &g_cpu1_info; - int pid; + pid_t pid; int ret; if (sigtype >= CXD56_CPU1_DATA_TYPE_MAX) @@ -249,7 +254,7 @@ int cxd56_cpu1siguninit(uint8_t sigtype) } pid = priv->workerpid; - priv->workerpid = 0; + priv->workerpid = INVALID_PROCESS_ID; sched_unlock(); diff --git a/arch/arm/src/cxd56xx/cxd56_gnss.c b/arch/arm/src/cxd56xx/cxd56_gnss.c index eadea75..ade0ec2 100644 --- a/arch/arm/src/cxd56xx/cxd56_gnss.c +++ b/arch/arm/src/cxd56xx/cxd56_gnss.c @@ -135,7 +135,7 @@ extern int fw_pm_sleepcpu(int cpuid, int mode); struct cxd56_gnss_sig_s { uint8_t enable; - int pid; + pid_t pid; FAR struct cxd56_gnss_signal_info_s info; }; @@ -1466,7 +1466,7 @@ static int cxd56_gnss_set_signal(FAR struct file *filep, unsigned long arg) FAR struct cxd56_gnss_signal_setting_s *setting; FAR struct cxd56_gnss_sig_s *sig; FAR struct cxd56_gnss_sig_s *checksig; - int pid; + pid_t pid; int i; if (!arg) diff --git a/arch/arm/src/cxd56xx/cxd56_icc.c b/arch/arm/src/cxd56xx/cxd56_icc.c index 7f4f9c7..b2c2c5e 100644 --- a/arch/arm/src/cxd56xx/cxd56_icc.c +++ b/arch/arm/src/cxd56xx/cxd56_icc.c @@ -116,7 +116,7 @@ struct iccdev_s /* for POSIX signal */ int signo; - int pid; + pid_t pid; FAR void *sigdata; struct sq_queue_s recvq; diff --git a/arch/arm/src/cxd56xx/cxd56_scu.c b/arch/arm/src/cxd56xx/cxd56_scu.c index 52cf197..f84e7a4 100644 --- a/arch/arm/src/cxd56xx/cxd56_scu.c +++ b/arch/arm/src/cxd56xx/cxd56_scu.c @@ -113,7 +113,7 @@ struct ev_notify_s { int signo; /* Signal number */ - int pid; /* Target PID */ + pid_t pid; /* Target PID */ struct scuev_arg_s *arg; /* Event argument */ struct scufifo_s *fifo; /* Reverse reference to FIFO */ }; @@ -121,7 +121,7 @@ struct ev_notify_s struct wm_notify_s { int signo; /* Signal number */ - int pid; /* Target PID */ + pid_t pid; /* Target PID */ struct scutimestamp_s *ts; /* Event argument */ struct scufifo_s *fifo; /* Reverse reference to FIFO */ }; diff --git a/arch/arm/src/cxd56xx/cxd56_usbdev.c b/arch/arm/src/cxd56xx/cxd56_usbdev.c index c78f35a..9ca79ad 100644 --- a/arch/arm/src/cxd56xx/cxd56_usbdev.c +++ b/arch/arm/src/cxd56xx/cxd56_usbdev.c @@ -380,7 +380,7 @@ struct cxd56_usbdev_s /* signal */ int signo; - int pid; + pid_t pid; }; /* For maintaining tables of endpoint info */ diff --git a/arch/arm/src/rtl8720c/amebaz_depend.c b/arch/arm/src/rtl8720c/amebaz_depend.c index 0432bac..9143cee 100644 --- a/arch/arm/src/rtl8720c/amebaz_depend.c +++ b/arch/arm/src/rtl8720c/amebaz_depend.c @@ -661,7 +661,7 @@ int rtw_create_task(struct task_struct *task, const char *name, return pid; } - wrap->pid = pid; + wrap->pid = (pid_t)pid; return 1; } diff --git a/arch/arm/src/rtl8720c/amebaz_depend.h b/arch/arm/src/rtl8720c/amebaz_depend.h index dac328f..d3d9794 100644 --- a/arch/arm/src/rtl8720c/amebaz_depend.h +++ b/arch/arm/src/rtl8720c/amebaz_depend.h @@ -66,7 +66,7 @@ struct task_struct }; struct nthread_wrapper { - int pid; + pid_t pid; thread_func_t func; void *thctx; }; diff --git a/arch/arm/src/tiva/common/tiva_can.c b/arch/arm/src/tiva/common/tiva_can.c index 0221f57..66e904b 100644 --- a/arch/arm/src/tiva/common/tiva_can.c +++ b/arch/arm/src/tiva/common/tiva_can.c @@ -141,7 +141,7 @@ struct tiva_canmod_s /* kthread message handler thread ID */ - int kthd_id; + pid_t kthd_id; #ifdef CONFIG_CAN_ERRORS /* Asynchronously report errors when status interrupts are disabled */ @@ -438,7 +438,7 @@ static int tivacan_setup(FAR struct can_dev_s *dev) } else { - canmod->kthd_id = ret; + canmod->kthd_id = (pid_t)ret; } #ifdef CONFIG_CAN_EXTID diff --git a/arch/avr/src/avr/up_initialstate.c b/arch/avr/src/avr/up_initialstate.c index 92f31b1..84de3f0 100644 --- a/arch/avr/src/avr/up_initialstate.c +++ b/arch/avr/src/avr/up_initialstate.c @@ -58,7 +58,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { char *stack_ptr = (char *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/avr/src/avr32/up_initialstate.c b/arch/avr/src/avr32/up_initialstate.c index f2555a5..58d99b9 100644 --- a/arch/avr/src/avr32/up_initialstate.c +++ b/arch/avr/src/avr32/up_initialstate.c @@ -55,7 +55,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { char *stack_ptr = (char *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/ceva/src/common/up_assert.c b/arch/ceva/src/common/up_assert.c index 4f13cb2..c5a5d23 100644 --- a/arch/ceva/src/common/up_assert.c +++ b/arch/ceva/src/common/up_assert.c @@ -296,7 +296,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (CURRENT_REGS || running_task()->pid == 0) + if (up_interrupt_context() || sched_idletask()) { up_irq_save(); for (; ; ) diff --git a/arch/ceva/src/xc5/up_initialstate.c b/arch/ceva/src/xc5/up_initialstate.c index bdd62bd..14e37dc 100644 --- a/arch/ceva/src/xc5/up_initialstate.c +++ b/arch/ceva/src/xc5/up_initialstate.c @@ -55,7 +55,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { tcb->stack_alloc_ptr = g_idle_basestack; tcb->stack_base_ptr = tcb->stack_alloc_ptr; diff --git a/arch/ceva/src/xm6/up_initialstate.c b/arch/ceva/src/xm6/up_initialstate.c index d7207cb..4677c19 100644 --- a/arch/ceva/src/xm6/up_initialstate.c +++ b/arch/ceva/src/xm6/up_initialstate.c @@ -61,7 +61,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { tcb->stack_alloc_ptr = g_idle_basestack; tcb->stack_base_ptr = tcb->stack_alloc_ptr; diff --git a/arch/hc/src/m9s12/m9s12_initialstate.c b/arch/hc/src/m9s12/m9s12_initialstate.c index d2ffa75..a91c2e5 100644 --- a/arch/hc/src/m9s12/m9s12_initialstate.c +++ b/arch/hc/src/m9s12/m9s12_initialstate.c @@ -56,7 +56,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { char *stack_ptr = (char *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/mips/src/mips32/mips_initialstate.c b/arch/mips/src/mips32/mips_initialstate.c index 9ad52f1..2b83e0c 100644 --- a/arch/mips/src/mips32/mips_initialstate.c +++ b/arch/mips/src/mips32/mips_initialstate.c @@ -59,7 +59,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { char *stack_ptr = (char *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/misoc/src/lm32/lm32_initialstate.c b/arch/misoc/src/lm32/lm32_initialstate.c index da5a228..42ccb3d 100644 --- a/arch/misoc/src/lm32/lm32_initialstate.c +++ b/arch/misoc/src/lm32/lm32_initialstate.c @@ -57,7 +57,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { char *stack_ptr = (char *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/misoc/src/minerva/minerva_initialstate.c b/arch/misoc/src/minerva/minerva_initialstate.c index e0f5d97..ab1184a 100644 --- a/arch/misoc/src/minerva/minerva_initialstate.c +++ b/arch/misoc/src/minerva/minerva_initialstate.c @@ -61,7 +61,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { char *stack_ptr = (char *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/or1k/src/common/up_initialstate.c b/arch/or1k/src/common/up_initialstate.c index 502f04d..f0d010d 100644 --- a/arch/or1k/src/common/up_initialstate.c +++ b/arch/or1k/src/common/up_initialstate.c @@ -74,7 +74,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { tcb->stack_alloc_ptr = (void *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/renesas/src/m16c/m16c_initialstate.c b/arch/renesas/src/m16c/m16c_initialstate.c index 600cb9e..6b7e386 100644 --- a/arch/renesas/src/m16c/m16c_initialstate.c +++ b/arch/renesas/src/m16c/m16c_initialstate.c @@ -57,7 +57,7 @@ void up_initial_state(FAR struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { char *stack_ptr = (char *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/renesas/src/rx65n/rx65n_initialstate.c b/arch/renesas/src/rx65n/rx65n_initialstate.c index cd07fb3..65a3b93 100644 --- a/arch/renesas/src/rx65n/rx65n_initialstate.c +++ b/arch/renesas/src/rx65n/rx65n_initialstate.c @@ -62,7 +62,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { char *stack_ptr = (char *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/renesas/src/sh1/sh1_initialstate.c b/arch/renesas/src/sh1/sh1_initialstate.c index 3b69150..abbda04 100644 --- a/arch/renesas/src/sh1/sh1_initialstate.c +++ b/arch/renesas/src/sh1/sh1_initialstate.c @@ -74,7 +74,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { char *stack_ptr = (char *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/risc-v/src/bl602/bl602_os_hal.c b/arch/risc-v/src/bl602/bl602_os_hal.c index 08056fc..e2c3fdb 100644 --- a/arch/risc-v/src/bl602/bl602_os_hal.c +++ b/arch/risc-v/src/bl602/bl602_os_hal.c @@ -340,9 +340,9 @@ int bl_os_task_create(const char *name, void bl_os_task_delete(void *task_handle) { - pid_t task = (int)task_handle; + pid_t pid = (pid_t)((uintptr_t)task_handle); - task_delete((pid_t)task); + task_delete(pid); } /**************************************************************************** @@ -358,7 +358,9 @@ void bl_os_task_delete(void *task_handle) void *bl_os_task_get_current_task(void) { - return (void *)0; + pid_t pid = getpid(); + + return (void *)((uintptr_t)pid); } /**************************************************************************** diff --git a/arch/risc-v/src/common/riscv_initialstate.c b/arch/risc-v/src/common/riscv_initialstate.c index f83eeb3..6f58129 100644 --- a/arch/risc-v/src/common/riscv_initialstate.c +++ b/arch/risc-v/src/common/riscv_initialstate.c @@ -57,7 +57,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { tcb->stack_alloc_ptr = (void *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/risc-v/src/esp32c3/esp32c3_ble_adapter.c b/arch/risc-v/src/esp32c3/esp32c3_ble_adapter.c index dba1b98..ceaa9bc 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_ble_adapter.c +++ b/arch/risc-v/src/esp32c3/esp32c3_ble_adapter.c @@ -553,7 +553,7 @@ static int32_t esp_task_create_pinned_to_core(void *entry, wlerr("Failed to create task\n"); } - return pid > 0 ? true : false; + return pid > 0; } /**************************************************************************** diff --git a/arch/risc-v/src/esp32c3/esp32c3_rt_timer.c b/arch/risc-v/src/esp32c3/esp32c3_rt_timer.c index f7c148a..3ea81a3 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_rt_timer.c +++ b/arch/risc-v/src/esp32c3/esp32c3_rt_timer.c @@ -68,7 +68,7 @@ struct esp32c3_rt_priv_s { - int pid; + pid_t pid; sem_t toutsem; struct list_node runlist; struct list_node toutlist; @@ -81,7 +81,7 @@ struct esp32c3_rt_priv_s static struct esp32c3_rt_priv_s g_rt_priv = { - .pid = -EINVAL, + .pid = INVALID_PROCESS_ID, }; /**************************************************************************** @@ -736,7 +736,7 @@ int esp32c3_rt_timer_init(void) list_initialize(&priv->runlist); list_initialize(&priv->toutlist); - priv->pid = pid; + priv->pid = (pid_t)pid; flags = enter_critical_section(); @@ -789,10 +789,10 @@ void esp32c3_rt_timer_deinit(void) leave_critical_section(flags); - if (priv->pid != -EINVAL) + if (priv->pid != INVALID_PROCESS_ID) { kthread_delete(priv->pid); - priv->pid = -EINVAL; + priv->pid = INVALID_PROCESS_ID; } nxsem_destroy(&priv->toutsem); diff --git a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c index 343c8aa..321d196 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c +++ b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c @@ -1997,7 +1997,7 @@ static int32_t esp_task_create_pinned_to_core(void *entry, wlerr("ERROR: Failed to create task\n"); } - return pid > 0 ? true : false; + return pid > 0; } /**************************************************************************** diff --git a/arch/sim/src/sim/up_initialstate.c b/arch/sim/src/sim/up_initialstate.c index a257b5d..408c880 100644 --- a/arch/sim/src/sim/up_initialstate.c +++ b/arch/sim/src/sim/up_initialstate.c @@ -54,7 +54,7 @@ void up_initial_state(struct tcb_s *tcb) { - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { tcb->stack_alloc_ptr = (void *)(up_getsp() - CONFIG_IDLETHREAD_STACKSIZE - diff --git a/arch/sparc/src/sparc_v8/up_dumpstate.c b/arch/sparc/src/sparc_v8/up_dumpstate.c index 75f7b1e..d31a70d 100644 --- a/arch/sparc/src/sparc_v8/up_dumpstate.c +++ b/arch/sparc/src/sparc_v8/up_dumpstate.c @@ -108,7 +108,7 @@ void up_dumpstate(void) /* Get the limits on the user stack memory */ - if (rtcb->pid == 0) /* Check for CPU0 IDLE thread */ + if (rtcb->pid == IDLE_PROCESS_ID) /* Check for CPU0 IDLE thread */ { ustackbase = g_idle_topstack - 4; ustacksize = CONFIG_IDLETHREAD_STACKSIZE; diff --git a/arch/sparc/src/sparc_v8/up_initialstate.c b/arch/sparc/src/sparc_v8/up_initialstate.c index 46ee07c..6ef0754 100644 --- a/arch/sparc/src/sparc_v8/up_initialstate.c +++ b/arch/sparc/src/sparc_v8/up_initialstate.c @@ -68,7 +68,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { tcb->stack_alloc_ptr = (void *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/x86/src/i486/up_initialstate.c b/arch/x86/src/i486/up_initialstate.c index 1f5b9b5..41d8dd3 100644 --- a/arch/x86/src/i486/up_initialstate.c +++ b/arch/x86/src/i486/up_initialstate.c @@ -55,7 +55,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { char *stack_ptr = (char *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/x86_64/src/intel64/up_initialstate.c b/arch/x86_64/src/intel64/up_initialstate.c index dea0256..66f61f9 100644 --- a/arch/x86_64/src/intel64/up_initialstate.c +++ b/arch/x86_64/src/intel64/up_initialstate.c @@ -56,7 +56,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { char *stack_ptr = (char *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); diff --git a/arch/xtensa/src/common/xtensa_initialstate.c b/arch/xtensa/src/common/xtensa_initialstate.c index 9b5157a..b059d62 100644 --- a/arch/xtensa/src/common/xtensa_initialstate.c +++ b/arch/xtensa/src/common/xtensa_initialstate.c @@ -60,7 +60,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { tcb->stack_alloc_ptr = g_idlestack; tcb->stack_base_ptr = tcb->stack_alloc_ptr; diff --git a/arch/xtensa/src/esp32/esp32_ble_adapter.c b/arch/xtensa/src/esp32/esp32_ble_adapter.c index ab7c332..681de7c 100644 --- a/arch/xtensa/src/esp32/esp32_ble_adapter.c +++ b/arch/xtensa/src/esp32/esp32_ble_adapter.c @@ -802,7 +802,7 @@ static int32_t esp_task_create_pinned_to_core(void *entry, wlerr("Failed to create task, error %d\n", pid); } - return pid > 0 ? true : false; + return pid > 0; } /**************************************************************************** diff --git a/arch/xtensa/src/esp32/esp32_rt_timer.c b/arch/xtensa/src/esp32/esp32_rt_timer.c index 6732902..34f3c21 100644 --- a/arch/xtensa/src/esp32/esp32_rt_timer.c +++ b/arch/xtensa/src/esp32/esp32_rt_timer.c @@ -66,7 +66,7 @@ struct esp32_rt_priv_s { - int pid; + pid_t pid; sem_t toutsem; @@ -81,7 +81,10 @@ struct esp32_rt_priv_s * Private Data ****************************************************************************/ -static struct esp32_rt_priv_s g_rt_priv; +static struct esp32_rt_priv_s g_rt_priv = +{ + .pid = INVALID_PROCESS_ID +}; /**************************************************************************** * Private Function Prototypes @@ -705,7 +708,7 @@ int esp32_rt_timer_init(void) list_initialize(&priv->toutlist); priv->timer = tim; - priv->pid = pid; + priv->pid = (pid_t)pid; flags = spin_lock_irqsave(&priv->lock); @@ -757,7 +760,12 @@ void esp32_rt_timer_deinit(void) spin_unlock_irqrestore(&priv->lock, flags); - kthread_delete(priv->pid); + if (priv->pid != INVALID_PROCESS_ID) + { + kthread_delete(priv->pid); + priv->pid = INVALID_PROCESS_ID; + } + nxsem_destroy(&priv->toutsem); } diff --git a/arch/xtensa/src/esp32/esp32_wifi_adapter.c b/arch/xtensa/src/esp32/esp32_wifi_adapter.c index c00b41e..b752ca0 100644 --- a/arch/xtensa/src/esp32/esp32_wifi_adapter.c +++ b/arch/xtensa/src/esp32/esp32_wifi_adapter.c @@ -1933,7 +1933,7 @@ static int32_t esp_task_create_pinned_to_core(void *entry, wlerr("Failed to create task\n"); } - return pid > 0 ? true : false; + return pid > 0; } /**************************************************************************** diff --git a/arch/xtensa/src/esp32s2/esp32s2_rt_timer.c b/arch/xtensa/src/esp32s2/esp32s2_rt_timer.c index 20539ba..86e2161 100644 --- a/arch/xtensa/src/esp32s2/esp32s2_rt_timer.c +++ b/arch/xtensa/src/esp32s2/esp32s2_rt_timer.c @@ -74,7 +74,7 @@ struct esp32s2_rt_priv_s { - int pid; + pid_t pid; sem_t toutsem; struct list_node runlist; struct list_node toutlist; @@ -87,7 +87,7 @@ struct esp32s2_rt_priv_s static struct esp32s2_rt_priv_s g_rt_priv = { - .pid = -EINVAL, + .pid = INVALID_PROCESS_ID, }; /**************************************************************************** @@ -752,7 +752,7 @@ int esp32s2_rt_timer_init(void) list_initialize(&priv->runlist); list_initialize(&priv->toutlist); - priv->pid = pid; + priv->pid = (pid_t)pid; priv->timer = tim; flags = enter_critical_section(); @@ -832,10 +832,10 @@ void esp32s2_rt_timer_deinit(void) leave_critical_section(flags); - if (priv->pid != -EINVAL) + if (priv->pid != INVALID_PROCESS_ID) { kthread_delete(priv->pid); - priv->pid = -EINVAL; + priv->pid = INVALID_PROCESS_ID; } nxsem_destroy(&priv->toutsem); diff --git a/arch/xtensa/src/esp32s3/esp32s3_rt_timer.c b/arch/xtensa/src/esp32s3/esp32s3_rt_timer.c index b69d093..52d9f66 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_rt_timer.c +++ b/arch/xtensa/src/esp32s3/esp32s3_rt_timer.c @@ -72,7 +72,7 @@ static_assert(RT_TIMER_TASK_PRIORITY < CONFIG_SCHED_HPWORKPRIORITY, struct esp32s3_rt_priv_s { - int pid; /* PID of RT Timer kernel thread */ + pid_t pid; /* PID of RT Timer kernel thread */ int cpuint; /* CPU interrupt assigned to this timer */ int core; /* Core that is taking care of the timer * interrupts @@ -91,7 +91,7 @@ struct esp32s3_rt_priv_s static struct esp32s3_rt_priv_s g_rt_priv = { - .pid = -EINVAL, + .pid = INVALID_PROCESS_ID, .cpuint = -ENOMEM, .core = -ENODEV }; @@ -961,7 +961,7 @@ int esp32s3_rt_timer_init(void) list_initialize(&priv->runlist); list_initialize(&priv->toutlist); - priv->pid = pid; + priv->pid = (pid_t)pid; flags = spin_lock_irqsave(&priv->lock); @@ -1044,10 +1044,10 @@ void esp32s3_rt_timer_deinit(void) spin_unlock_irqrestore(&priv->lock, flags); - if (priv->pid != -EINVAL) + if (priv->pid != INVALID_PROCESS_ID) { kthread_delete(priv->pid); - priv->pid = -EINVAL; + priv->pid = INVALID_PROCESS_ID; } nxsem_destroy(&priv->toutsem); diff --git a/arch/z80/src/z180/z180_initialstate.c b/arch/z80/src/z180/z180_initialstate.c index 74d2801..14c0d00 100644 --- a/arch/z80/src/z180/z180_initialstate.c +++ b/arch/z80/src/z180/z180_initialstate.c @@ -54,7 +54,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { char *stack_ptr = (char *)CONFIG_STACK_BASE; #ifdef CONFIG_STACK_COLORATION diff --git a/arch/z80/src/z80/z80_initialstate.c b/arch/z80/src/z80/z80_initialstate.c index 2b63860..b26c3f1 100644 --- a/arch/z80/src/z80/z80_initialstate.c +++ b/arch/z80/src/z80/z80_initialstate.c @@ -54,7 +54,7 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the idle thread stack */ - if (tcb->pid == 0) + if (tcb->pid == IDLE_PROCESS_ID) { char *stack_ptr = (char *)CONFIG_STACK_BASE; #ifdef CONFIG_STACK_COLORATION diff --git a/boards/arm/imxrt/imxrt1020-evk/src/imxrt_usbhost.c b/boards/arm/imxrt/imxrt1020-evk/src/imxrt_usbhost.c index b36fde0..c32dcbc 100644 --- a/boards/arm/imxrt/imxrt1020-evk/src/imxrt_usbhost.c +++ b/boards/arm/imxrt/imxrt1020-evk/src/imxrt_usbhost.c @@ -131,7 +131,6 @@ static int ehci_waiter(int argc, char *argv[]) int imxrt_usbhost_initialize(void) { - pid_t pid; int ret; imxrt_clockall_usboh3(); @@ -205,10 +204,10 @@ int imxrt_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); return -ENODEV; diff --git a/boards/arm/imxrt/imxrt1060-evk/src/imxrt_usbhost.c b/boards/arm/imxrt/imxrt1060-evk/src/imxrt_usbhost.c index eabd144..ac3c6b4 100644 --- a/boards/arm/imxrt/imxrt1060-evk/src/imxrt_usbhost.c +++ b/boards/arm/imxrt/imxrt1060-evk/src/imxrt_usbhost.c @@ -131,7 +131,6 @@ static int ehci_waiter(int argc, char *argv[]) int imxrt_usbhost_initialize(void) { - pid_t pid; int ret; imxrt_clockall_usboh3(); @@ -203,10 +202,10 @@ int imxrt_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); return -ENODEV; diff --git a/boards/arm/imxrt/imxrt1064-evk/src/imxrt_usbhost.c b/boards/arm/imxrt/imxrt1064-evk/src/imxrt_usbhost.c index 925bba4..580fc1d 100644 --- a/boards/arm/imxrt/imxrt1064-evk/src/imxrt_usbhost.c +++ b/boards/arm/imxrt/imxrt1064-evk/src/imxrt_usbhost.c @@ -131,7 +131,6 @@ static int ehci_waiter(int argc, char *argv[]) int imxrt_usbhost_initialize(void) { - pid_t pid; int ret; imxrt_clockall_usboh3(); @@ -203,10 +202,10 @@ int imxrt_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); return -ENODEV; diff --git a/boards/arm/kinetis/freedom-k28f/src/k28_usbhshost.c b/boards/arm/kinetis/freedom-k28f/src/k28_usbhshost.c index 4013c18..b5d67cd 100644 --- a/boards/arm/kinetis/freedom-k28f/src/k28_usbhshost.c +++ b/boards/arm/kinetis/freedom-k28f/src/k28_usbhshost.c @@ -398,7 +398,6 @@ static void usb_msc_disconnect(FAR void *arg) int k28_usbhost_initialize(void) { - pid_t pid; int ret; # ifdef HAVE_USB_AUTOMOUNTER int index; @@ -479,10 +478,10 @@ int k28_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); return -ENODEV; diff --git a/boards/arm/kinetis/twr-k64f120m/README.txt b/boards/arm/kinetis/twr-k64f120m/README.txt index 4026b9e..17ee5b8 100644 --- a/boards/arm/kinetis/twr-k64f120m/README.txt +++ b/boards/arm/kinetis/twr-k64f120m/README.txt @@ -36,7 +36,7 @@ Kinetis TWR-K64F120M Features: o Touch TWRPI Socket adds support for various capacitive touch boards (e.g. keypads, rotary dials, sliders, etc.) o Tower connectivity for access to USB, Ethernet, RS232/RS485, CAN, SPI, - I�C, Flexbus, etc. + I²C, Flexbus, etc. o Plus: Potentiometer, 4 LEDs, 2 pushbuttons, accelerometer, RTC battery Kinetis TWR-K64F120M Pin Configuration diff --git a/boards/arm/lpc17xx_40xx/lpc4088-devkit/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/lpc4088-devkit/src/lpc17_40_bringup.c index 4c8f17d..0d3ddc9 100644 --- a/boards/arm/lpc17xx_40xx/lpc4088-devkit/src/lpc17_40_bringup.c +++ b/boards/arm/lpc17xx_40xx/lpc4088-devkit/src/lpc17_40_bringup.c @@ -260,7 +260,6 @@ static int nsh_sdinitialize(void) #ifdef NSH_HAVE_USBHOST static int nsh_usbhostinitialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -302,10 +301,10 @@ static int nsh_usbhostinitialize(void) syslog(LOG_INFO, "Start nsh_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)nsh_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/src/lpc17_40_bringup.c index 69fb4e5..0c60eb0 100644 --- a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/src/lpc17_40_bringup.c +++ b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/src/lpc17_40_bringup.c @@ -296,7 +296,6 @@ static int nsh_sdinitialize(void) #ifdef NSH_HAVE_USBHOST static int nsh_usbhostinitialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -338,10 +337,10 @@ static int nsh_usbhostinitialize(void) syslog(LOG_INFO, "Start nsh_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)nsh_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c index 50493bd..c2ac678 100644 --- a/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c +++ b/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c @@ -294,7 +294,6 @@ static int nsh_sdinitialize(void) #ifdef NSH_HAVE_USBHOST static int nsh_usbhostinitialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -337,10 +336,10 @@ static int nsh_usbhostinitialize(void) syslog(LOG_INFO, "Start nsh_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)nsh_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } UNUSED(ret); diff --git a/boards/arm/lpc17xx_40xx/mcb1700/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/mcb1700/src/lpc17_40_bringup.c index fe2944e..01118a2 100644 --- a/boards/arm/lpc17xx_40xx/mcb1700/src/lpc17_40_bringup.c +++ b/boards/arm/lpc17xx_40xx/mcb1700/src/lpc17_40_bringup.c @@ -238,7 +238,6 @@ errout: #ifdef HAVE_USBHOST static int nsh_usbhostinitialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -294,10 +293,10 @@ static int nsh_usbhostinitialize(void) syslog(LOG_ERR, "ERROR: Start nsh_waiter\n"); - pid = kthread_create("usbhost", CONFIG_MCB1700_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_MCB1700_USBHOST_PRIO, CONFIG_MCB1700_USBHOST_STACKSIZE, (main_t)nsh_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/src/lpc17_40_bringup.c index 378f480..684e728 100644 --- a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/src/lpc17_40_bringup.c +++ b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/src/lpc17_40_bringup.c @@ -237,7 +237,6 @@ errout: #ifdef HAVE_USBHOST static int nsh_usbhostinitialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -313,10 +312,10 @@ static int nsh_usbhostinitialize(void) syslog(LOG_ERR, "ERROR: Start nsh_waiter\n"); - pid = kthread_create("usbhost", CONFIG_LPC1766STK_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_LPC1766STK_USBHOST_PRIO, CONFIG_LPC1766STK_USBHOST_STACKSIZE, (main_t)nsh_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/lpc17xx_40xx/open1788/src/lpc17_40_bringup.c b/boards/arm/lpc17xx_40xx/open1788/src/lpc17_40_bringup.c index d48fa9f..f770f4c 100644 --- a/boards/arm/lpc17xx_40xx/open1788/src/lpc17_40_bringup.c +++ b/boards/arm/lpc17xx_40xx/open1788/src/lpc17_40_bringup.c @@ -295,7 +295,6 @@ static int nsh_sdinitialize(void) #ifdef NSH_HAVE_USBHOST static int nsh_usbhostinitialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -337,10 +336,10 @@ static int nsh_usbhostinitialize(void) syslog(LOG_INFO, "Start nsh_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)nsh_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/lpc31xx/ea3131/src/lpc31_usbhost.c b/boards/arm/lpc31xx/ea3131/src/lpc31_usbhost.c index 02b72bc..203f859 100644 --- a/boards/arm/lpc31xx/ea3131/src/lpc31_usbhost.c +++ b/boards/arm/lpc31xx/ea3131/src/lpc31_usbhost.c @@ -159,7 +159,6 @@ void weak_function lpc31_usbhost_bootinitialize(void) int lpc31_usbhost_initialize(void) { - pid_t pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -218,10 +217,10 @@ int lpc31_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); return -ENODEV; diff --git a/boards/arm/lpc31xx/olimex-lpc-h3131/src/lpc31_usbhost.c b/boards/arm/lpc31xx/olimex-lpc-h3131/src/lpc31_usbhost.c index 8c9dcc7..41b399a 100644 --- a/boards/arm/lpc31xx/olimex-lpc-h3131/src/lpc31_usbhost.c +++ b/boards/arm/lpc31xx/olimex-lpc-h3131/src/lpc31_usbhost.c @@ -160,7 +160,6 @@ void weak_function lpc31_usbhost_bootinitialize(void) int lpc31_usbhost_initialize(void) { - pid_t pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -218,10 +217,10 @@ int lpc31_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, i + ret = kthread_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, i CONFIG_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); return -ENODEV; diff --git a/boards/arm/sama5/giant-board/src/sam_usb.c b/boards/arm/sama5/giant-board/src/sam_usb.c index 9b4e78f..c0e8829 100644 --- a/boards/arm/sama5/giant-board/src/sam_usb.c +++ b/boards/arm/sama5/giant-board/src/sam_usb.c @@ -230,7 +230,6 @@ void weak_function sam_usbinitialize(void) #ifdef HAVE_USBHOST int sam_usbhost_initialize(void) { - pid_t pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -291,11 +290,11 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("OHCI Monitor", + ret = kthread_create("OHCI Monitor", CONFIG_SAMA5D27_GIANT_BOARD_USBHOST_PRIO, CONFIG_SAMA5D27_GIANT_BOARD_USBHOST_STACKSIZE, (main_t)ohci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ohci_waiter task: %d\n", ret); return -ENODEV; @@ -314,11 +313,11 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("EHCI Monitor", + ret = kthread_create("EHCI Monitor", CONFIG_SAMA5D27_GIANT_BOARD_USBHOST_PRIO, CONFIG_SAMA5D27_GIANT_BOARD_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); return -ENODEV; diff --git a/boards/arm/sama5/sama5d2-xult/src/sam_usb.c b/boards/arm/sama5/sama5d2-xult/src/sam_usb.c index de7cfc0..5ed9194 100644 --- a/boards/arm/sama5/sama5d2-xult/src/sam_usb.c +++ b/boards/arm/sama5/sama5d2-xult/src/sam_usb.c @@ -278,7 +278,6 @@ void weak_function sam_usbinitialize(void) #ifdef HAVE_USBHOST int sam_usbhost_initialize(void) { - pid_t pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -339,10 +338,10 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("OHCI Monitor", CONFIG_SAMA5D2XULT_USBHOST_PRIO, + ret = kthread_create("OHCI Monitor", CONFIG_SAMA5D2XULT_USBHOST_PRIO, CONFIG_SAMA5D2XULT_USBHOST_STACKSIZE, (main_t)ohci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ohci_waiter task: %d\n", ret); return -ENODEV; @@ -361,10 +360,10 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("EHCI Monitor", CONFIG_SAMA5D2XULT_USBHOST_PRIO, + ret = kthread_create("EHCI Monitor", CONFIG_SAMA5D2XULT_USBHOST_PRIO, CONFIG_SAMA5D2XULT_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); return -ENODEV; diff --git a/boards/arm/sama5/sama5d3-xplained/src/sam_usb.c b/boards/arm/sama5/sama5d3-xplained/src/sam_usb.c index 473d9c5..d973bfb 100644 --- a/boards/arm/sama5/sama5d3-xplained/src/sam_usb.c +++ b/boards/arm/sama5/sama5d3-xplained/src/sam_usb.c @@ -286,7 +286,6 @@ void weak_function sam_usbinitialize(void) #ifdef HAVE_USBHOST int sam_usbhost_initialize(void) { - pid_t pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -347,10 +346,10 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("OHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO, + ret = kthread_create("OHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO, CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE, (main_t)ohci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ohci_waiter task: %d\n", ret); return -ENODEV; @@ -369,10 +368,10 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("EHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO, + ret = kthread_create("EHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO, CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); return -ENODEV; diff --git a/boards/arm/sama5/sama5d3x-ek/src/sam_usb.c b/boards/arm/sama5/sama5d3x-ek/src/sam_usb.c index 8532e18..6582853 100644 --- a/boards/arm/sama5/sama5d3x-ek/src/sam_usb.c +++ b/boards/arm/sama5/sama5d3x-ek/src/sam_usb.c @@ -284,7 +284,6 @@ void weak_function sam_usbinitialize(void) #ifdef HAVE_USBHOST int sam_usbhost_initialize(void) { - pid_t pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -345,11 +344,11 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("OHCI Monitor", + ret = kthread_create("OHCI Monitor", CONFIG_SAMA5D3XEK_USBHOST_PRIO, CONFIG_SAMA5D3XEK_USBHOST_STACKSIZE, (main_t)ohci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ohci_waiter task: %d\n", ret); return -ENODEV; @@ -368,10 +367,10 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("EHCI Monitor", CONFIG_SAMA5D3XEK_USBHOST_PRIO, + ret = kthread_create("EHCI Monitor", CONFIG_SAMA5D3XEK_USBHOST_PRIO, CONFIG_SAMA5D3XEK_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); return -ENODEV; diff --git a/boards/arm/sama5/sama5d4-ek/src/sam_usb.c b/boards/arm/sama5/sama5d4-ek/src/sam_usb.c index f884e29..ae8606c 100644 --- a/boards/arm/sama5/sama5d4-ek/src/sam_usb.c +++ b/boards/arm/sama5/sama5d4-ek/src/sam_usb.c @@ -284,7 +284,6 @@ void weak_function sam_usbinitialize(void) #ifdef HAVE_USBHOST int sam_usbhost_initialize(void) { - pid_t pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -345,10 +344,10 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("OHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO, + ret = kthread_create("OHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO, CONFIG_SAMA5D4EK_USBHOST_STACKSIZE, (main_t)ohci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ohci_waiter task: %d\n", ret); return -ENODEV; @@ -367,10 +366,10 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = kthread_create("EHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO, + ret = kthread_create("EHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO, CONFIG_SAMA5D4EK_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); - if (pid < 0) + if (ret < 0) { uerr("ERROR: Failed to create ehci_waiter task: %d\n", ret); return -ENODEV; diff --git a/boards/arm/samd5e5/metro-m4/src/sam_usbhost.c b/boards/arm/samd5e5/metro-m4/src/sam_usbhost.c index be2ee12..f9da729 100644 --- a/boards/arm/samd5e5/metro-m4/src/sam_usbhost.c +++ b/boards/arm/samd5e5/metro-m4/src/sam_usbhost.c @@ -171,7 +171,6 @@ void sam_usbhost_vbusdrive(int iface, bool enable) #ifdef CONFIG_USBHOST int samd_usbhost_initialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -219,11 +218,10 @@ int samd_usbhost_initialize(void) /* Start a thread to handle device connection. */ uinfo("Start usbhost_waiter\n"); - pid = - kthread_create("usbhost", CONFIG_METRO_M4_USBHOST_PRIO, - CONFIG_METRO_M4_USBHOST_STACKSIZE, - (main_t) usbhost_waiter, (FAR char *const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + ret = kthread_create("usbhost", CONFIG_METRO_M4_USBHOST_PRIO, + CONFIG_METRO_M4_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char *const *)NULL); + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/axoloti/src/stm32_usbhost.c b/boards/arm/stm32/axoloti/src/stm32_usbhost.c index 33d5422..3249dda 100644 --- a/boards/arm/stm32/axoloti/src/stm32_usbhost.c +++ b/boards/arm/stm32/axoloti/src/stm32_usbhost.c @@ -203,7 +203,6 @@ int stm32_setup_overcurrent(xcpt_t handler, void *arg) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -251,11 +250,10 @@ int stm32_usbhost_initialize(void) /* Start a thread to handle device connection. */ uinfo("Start usbhost_waiter\n"); - pid = - kthread_create("usbhost", CONFIG_AXOLOTI_USBHOST_PRIO, - CONFIG_AXOLOTI_USBHOST_STACKSIZE, - (main_t) usbhost_waiter, (FAR char *const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + ret = kthread_create("usbhost", CONFIG_AXOLOTI_USBHOST_PRIO, + CONFIG_AXOLOTI_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char *const *)NULL); + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/cloudctrl/src/stm32_usb.c b/boards/arm/stm32/cloudctrl/src/stm32_usb.c index d278e3e..e4fc3f3 100644 --- a/boards/arm/stm32/cloudctrl/src/stm32_usb.c +++ b/boards/arm/stm32/cloudctrl/src/stm32_usb.c @@ -160,7 +160,6 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -199,10 +198,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/mikroe-stm32f4/src/stm32_usb.c b/boards/arm/stm32/mikroe-stm32f4/src/stm32_usb.c index 95b9108..3271d96 100644 --- a/boards/arm/stm32/mikroe-stm32f4/src/stm32_usb.c +++ b/boards/arm/stm32/mikroe-stm32f4/src/stm32_usb.c @@ -160,7 +160,6 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -199,10 +198,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/nucleo-f207zg/src/stm32_usb.c b/boards/arm/stm32/nucleo-f207zg/src/stm32_usb.c index 2659b04..1c431d7 100644 --- a/boards/arm/stm32/nucleo-f207zg/src/stm32_usb.c +++ b/boards/arm/stm32/nucleo-f207zg/src/stm32_usb.c @@ -157,11 +157,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -229,10 +225,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_NUCLEOF207ZG_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_NUCLEOF207ZG_USBHOST_PRIO, CONFIG_NUCLEOF207ZG_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/nucleo-f412zg/src/stm32_usb.c b/boards/arm/stm32/nucleo-f412zg/src/stm32_usb.c index cfb85f8..46c056c 100644 --- a/boards/arm/stm32/nucleo-f412zg/src/stm32_usb.c +++ b/boards/arm/stm32/nucleo-f412zg/src/stm32_usb.c @@ -170,12 +170,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) || \ - defined(CONFIG_USBHOST_XBOXCONTROLLER) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -253,10 +248,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32F411DISCO_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_STM32F411DISCO_USBHOST_PRIO, CONFIG_STM32F411DISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c b/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c index 5053617..15c52e6 100644 --- a/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c +++ b/boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c @@ -235,7 +235,7 @@ typedef struct fault_flags_t flags; /* What is in the dump */ uintptr_t current_regs; /* Used to validate the dump */ int lineno; /* __LINE__ to up_assert */ - int pid; /* Process ID */ + pid_t pid; /* Process ID */ uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */ stack_t stacks; /* Stack info */ #if CONFIG_TASK_NAME_SIZE > 0 diff --git a/boards/arm/stm32/nucleo-f429zi/src/stm32_usb.c b/boards/arm/stm32/nucleo-f429zi/src/stm32_usb.c index b41addd..4de6fb2 100644 --- a/boards/arm/stm32/nucleo-f429zi/src/stm32_usb.c +++ b/boards/arm/stm32/nucleo-f429zi/src/stm32_usb.c @@ -156,11 +156,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -228,10 +224,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/olimex-stm32-e407/src/stm32_usb.c b/boards/arm/stm32/olimex-stm32-e407/src/stm32_usb.c index 8cbe4fd..0971e01 100644 --- a/boards/arm/stm32/olimex-stm32-e407/src/stm32_usb.c +++ b/boards/arm/stm32/olimex-stm32-e407/src/stm32_usb.c @@ -155,11 +155,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -227,10 +223,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/olimex-stm32-h407/src/stm32_usb.c b/boards/arm/stm32/olimex-stm32-h407/src/stm32_usb.c index 3bdf60c..d0c459f 100644 --- a/boards/arm/stm32/olimex-stm32-h407/src/stm32_usb.c +++ b/boards/arm/stm32/olimex-stm32-h407/src/stm32_usb.c @@ -157,7 +157,6 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -206,10 +205,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32H407_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_STM32H407_USBHOST_PRIO, CONFIG_STM32H407_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/olimex-stm32-p207/src/stm32_usb.c b/boards/arm/stm32/olimex-stm32-p207/src/stm32_usb.c index 16ab649..f646ade 100644 --- a/boards/arm/stm32/olimex-stm32-p207/src/stm32_usb.c +++ b/boards/arm/stm32/olimex-stm32-p207/src/stm32_usb.c @@ -159,10 +159,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_STM32_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || defined(CONFIG_USBHOST_CDCACM) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -210,10 +207,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/olimex-stm32-p407/src/stm32_usb.c b/boards/arm/stm32/olimex-stm32-p407/src/stm32_usb.c index 645e818..88c2087 100644 --- a/boards/arm/stm32/olimex-stm32-p407/src/stm32_usb.c +++ b/boards/arm/stm32/olimex-stm32-p407/src/stm32_usb.c @@ -156,7 +156,6 @@ void stm32_usb_configure(void) #ifdef CONFIG_USBHOST int stm32_usbhost_setup(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -215,8 +214,6 @@ int stm32_usbhost_setup(void) } #endif - UNUSED(ret); - /* Then get an instance of the USB host interface */ uinfo("Initialize USB host\n"); @@ -227,10 +224,10 @@ int stm32_usbhost_setup(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_OLIMEXP407_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_OLIMEXP407_USBHOST_PRIO, CONFIG_OLIMEXP407_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/omnibusf4/src/stm32_usb.c b/boards/arm/stm32/omnibusf4/src/stm32_usb.c index 79fa7d5..2a1febf 100644 --- a/boards/arm/stm32/omnibusf4/src/stm32_usb.c +++ b/boards/arm/stm32/omnibusf4/src/stm32_usb.c @@ -154,12 +154,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) || \ - defined(CONFIG_USBHOST_XBOXCONTROLLER) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -237,10 +232,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_OMNIBUSF4_USBHOST_PRIO, - CONFIG_OMNIBUSF4_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + ret = kthread_create("usbhost", CONFIG_OMNIBUSF4_USBHOST_PRIO, + CONFIG_OMNIBUSF4_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/shenzhou/src/stm32_usb.c b/boards/arm/stm32/shenzhou/src/stm32_usb.c index 92e97da..2f73fe2 100644 --- a/boards/arm/stm32/shenzhou/src/stm32_usb.c +++ b/boards/arm/stm32/shenzhou/src/stm32_usb.c @@ -160,7 +160,6 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -199,10 +198,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/stm3220g-eval/src/stm32_usb.c b/boards/arm/stm32/stm3220g-eval/src/stm32_usb.c index 660d94e..a6e8888 100644 --- a/boards/arm/stm32/stm3220g-eval/src/stm32_usb.c +++ b/boards/arm/stm32/stm3220g-eval/src/stm32_usb.c @@ -160,7 +160,6 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -199,10 +198,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/stm3240g-eval/src/stm32_usb.c b/boards/arm/stm32/stm3240g-eval/src/stm32_usb.c index 7116d1b..7676255 100644 --- a/boards/arm/stm32/stm3240g-eval/src/stm32_usb.c +++ b/boards/arm/stm32/stm3240g-eval/src/stm32_usb.c @@ -160,7 +160,6 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -199,10 +198,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, - CONFIG_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + CONFIG_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/stm32f411-minimum/src/stm32_usb.c b/boards/arm/stm32/stm32f411-minimum/src/stm32_usb.c index 3d750b2..0de05c3 100644 --- a/boards/arm/stm32/stm32f411-minimum/src/stm32_usb.c +++ b/boards/arm/stm32/stm32f411-minimum/src/stm32_usb.c @@ -152,12 +152,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) || \ - defined(CONFIG_USBHOST_XBOXCONTROLLER) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -235,10 +230,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32F411MINIMUM_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_STM32F411MINIMUM_USBHOST_PRIO, CONFIG_STM32F411MINIMUM_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/stm32f411e-disco/src/stm32_usb.c b/boards/arm/stm32/stm32f411e-disco/src/stm32_usb.c index cd65546..be38985 100644 --- a/boards/arm/stm32/stm32f411e-disco/src/stm32_usb.c +++ b/boards/arm/stm32/stm32f411e-disco/src/stm32_usb.c @@ -171,12 +171,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) || \ - defined(CONFIG_USBHOST_XBOXCONTROLLER) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -254,10 +249,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32F411DISCO_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_STM32F411DISCO_USBHOST_PRIO, CONFIG_STM32F411DISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/stm32f429i-disco/src/stm32_usb.c b/boards/arm/stm32/stm32f429i-disco/src/stm32_usb.c index 704907d..74a998b 100644 --- a/boards/arm/stm32/stm32f429i-disco/src/stm32_usb.c +++ b/boards/arm/stm32/stm32f429i-disco/src/stm32_usb.c @@ -156,7 +156,6 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -205,10 +204,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32F429IDISCO_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_STM32F429IDISCO_USBHOST_PRIO, CONFIG_STM32F429IDISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_usb.c b/boards/arm/stm32/stm32f4discovery/src/stm32_usb.c index c0df65d..bbc036f 100644 --- a/boards/arm/stm32/stm32f4discovery/src/stm32_usb.c +++ b/boards/arm/stm32/stm32f4discovery/src/stm32_usb.c @@ -156,12 +156,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) || \ - defined(CONFIG_USBHOST_XBOXCONTROLLER) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -239,10 +234,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, - CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, - (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + ret = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, + CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, + (main_t)usbhost_waiter, (FAR char * const *)NULL); + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32/viewtool-stm32f107/src/stm32_max3421e.c b/boards/arm/stm32/viewtool-stm32f107/src/stm32_max3421e.c index cb29146..599202a 100644 --- a/boards/arm/stm32/viewtool-stm32f107/src/stm32_max3421e.c +++ b/boards/arm/stm32/viewtool-stm32f107/src/stm32_max3421e.c @@ -276,7 +276,6 @@ static int usbhost_detect(int argc, FAR char *argv[]) int stm32_max3421e_setup(void) { FAR struct spi_dev_s *spi; - pid_t monpid; int ret; /* Configure the MAX3421E interrupt pin as an input and the reset and power @@ -396,13 +395,13 @@ int stm32_max3421e_setup(void) /* Start the USB connection monitor kernel thread */ - monpid = kthread_create("MAX3421E ConnMon", - CONFIG_VIEWTOOL_MAX3421E_CONNMON_PRIORITY, - CONFIG_VIEWTOOL_MAX3421E_CONNMON_STACKSIZE, - usbhost_detect, NULL); - if (monpid < 0) + ret = kthread_create("MAX3421E ConnMon", + CONFIG_VIEWTOOL_MAX3421E_CONNMON_PRIORITY, + CONFIG_VIEWTOOL_MAX3421E_CONNMON_STACKSIZE, + usbhost_detect, NULL); + if (ret < 0) { - uerr("ERROR: Failed to start connection monitor: %d\n", monpid); + uerr("ERROR: Failed to start connection monitor: %d\n", ret); } return OK; diff --git a/boards/arm/stm32f7/nucleo-144/src/stm32_usb.c b/boards/arm/stm32f7/nucleo-144/src/stm32_usb.c index 65eec76..0060192 100644 --- a/boards/arm/stm32f7/nucleo-144/src/stm32_usb.c +++ b/boards/arm/stm32f7/nucleo-144/src/stm32_usb.c @@ -157,11 +157,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -229,10 +225,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32f7/stm32f746-ws/src/stm32_usb.c b/boards/arm/stm32f7/stm32f746-ws/src/stm32_usb.c index 204fe8b..673917f 100644 --- a/boards/arm/stm32f7/stm32f746-ws/src/stm32_usb.c +++ b/boards/arm/stm32f7/stm32f746-ws/src/stm32_usb.c @@ -159,11 +159,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -231,10 +227,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32F7F4DISCO_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_STM32F7F4DISCO_USBHOST_PRIO, CONFIG_STM32F7F4DISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_usb.c b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_usb.c index 70df138..b9ed680 100644 --- a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_usb.c +++ b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_usb.c @@ -157,11 +157,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -229,10 +225,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_NUCLEOH743ZI_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_NUCLEOH743ZI_USBHOST_PRIO, CONFIG_NUCLEOH743ZI_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_usb.c b/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_usb.c index 4d315e4..a786898 100644 --- a/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_usb.c +++ b/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_usb.c @@ -157,11 +157,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -229,10 +225,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_usb.c b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_usb.c index 2523be7..460870e 100644 --- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_usb.c +++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_usb.c @@ -148,11 +148,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -220,10 +216,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32H747XI_DISCO_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_STM32H747XI_DISCO_USBHOST_PRIO, CONFIG_STM32H747XI_DISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32l4/nucleo-l496zg/src/stm32_usb.c b/boards/arm/stm32l4/nucleo-l496zg/src/stm32_usb.c index 67533dd..5a8c77b 100644 --- a/boards/arm/stm32l4/nucleo-l496zg/src/stm32_usb.c +++ b/boards/arm/stm32l4/nucleo-l496zg/src/stm32_usb.c @@ -157,11 +157,7 @@ void stm32_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -229,10 +225,10 @@ int stm32_usbhost_initialize(void) uinfo("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_STM32F4DISCO_USBHOST_PRIO, CONFIG_STM32F4DISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32l4/stm32l476vg-disco/src/stm32_usb.c b/boards/arm/stm32l4/stm32l476vg-disco/src/stm32_usb.c index 6fc97bc..5f4c185 100644 --- a/boards/arm/stm32l4/stm32l476vg-disco/src/stm32_usb.c +++ b/boards/arm/stm32l4/stm32l476vg-disco/src/stm32_usb.c @@ -156,11 +156,7 @@ void stm32l4_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32l4_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -228,10 +224,10 @@ int stm32l4_usbhost_initialize(void) uvdbg("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32L4DISCO_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_STM32L4DISCO_USBHOST_PRIO, CONFIG_STM32L4DISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_usb.c b/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_usb.c index 6074418..b8e404d 100644 --- a/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_usb.c +++ b/boards/arm/stm32l4/stm32l4r9ai-disco/src/stm32_usb.c @@ -156,11 +156,7 @@ void stm32l4_usbinitialize(void) #ifdef CONFIG_USBHOST int stm32l4_usbhost_initialize(void) { - int pid; -#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || \ - defined(CONFIG_USBHOST_HIDKBD) || defined(CONFIG_USBHOST_HIDMOUSE) int ret; -#endif /* First, register all of the class drivers needed to support the drivers * that we care about: @@ -228,10 +224,10 @@ int stm32l4_usbhost_initialize(void) uvdbg("Start usbhost_waiter\n"); - pid = kthread_create("usbhost", CONFIG_STM32L4DISCO_USBHOST_PRIO, + ret = kthread_create("usbhost", CONFIG_STM32L4DISCO_USBHOST_PRIO, CONFIG_STM32L4DISCO_USBHOST_STACKSIZE, (main_t)usbhost_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_appinit.c b/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_appinit.c index 05a4b46..43068ff 100644 --- a/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_appinit.c +++ b/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_appinit.c @@ -259,7 +259,6 @@ errout: #ifdef NSH_HAVEUSBHOST static int nsh_usbhostinitialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -301,10 +300,10 @@ static int nsh_usbhostinitialize(void) syslog(LOG_INFO, "Start nsh_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)nsh_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c index 5de25d9..7ed6ac7 100644 --- a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c +++ b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c @@ -272,7 +272,6 @@ errout: #ifdef NSH_HAVEUSBHOST static int nsh_usbhostinitialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -314,10 +313,10 @@ static int nsh_usbhostinitialize(void) syslog(LOG_INFO, "Start nsh_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)nsh_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_appinit.c b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_appinit.c index 55c8616..de02be7 100644 --- a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_appinit.c +++ b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_appinit.c @@ -271,7 +271,6 @@ errout: #ifdef NSH_HAVE_USBHOST static int nsh_usbhostinitialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -314,10 +313,10 @@ static int nsh_usbhostinitialize(void) syslog(LOG_INFO, "Start nsh_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)nsh_waiter, (FAR char * const *)NULL); - return pid < 0 ? -ENOEXEC : OK; + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c index 740ecf0..bc72621 100644 --- a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c +++ b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c @@ -149,7 +149,6 @@ static int nsh_waiter(int argc, char *argv[]) #ifdef NSH_HAVE_USBHOST static int nsh_usbhostinitialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -210,11 +209,11 @@ static int nsh_usbhostinitialize(void) syslog(LOG_INFO, "Start nsh_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)nsh_waiter, (FAR char * const *)NULL); - syslog(LOG_INFO, "USBHost: Created pid = %d\n", pid); - return pid < 0 ? -ENOEXEC : OK; + syslog(LOG_INFO, "USBHost: Created pid = %d\n", ret); + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c index 298e8f1..a5c2382 100644 --- a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c +++ b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c @@ -184,7 +184,7 @@ typedef struct fault_flags_t flags; /* What is in the dump */ uintptr_t current_regs; /* Used to validate the dump */ int lineno; /* __LINE__ to up_assert */ - int pid; /* Process ID */ + pid_t pid; /* Process ID */ uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */ stack_t stacks; /* Stack info */ #if CONFIG_TASK_NAME_SIZE > 0 diff --git a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c index a571264..cd43344 100644 --- a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c +++ b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c @@ -146,7 +146,6 @@ static int nsh_waiter(int argc, char *argv[]) #ifdef NSH_HAVE_USBHOST static int nsh_usbhostinitialize(void) { - int pid; int ret; /* First, register all of the class drivers needed to support the drivers @@ -209,11 +208,11 @@ static int nsh_usbhostinitialize(void) syslog(LOG_INFO, "Start nsh_waiter\n"); - pid = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, + ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, (main_t)nsh_waiter, (FAR char * const *)NULL); - syslog(LOG_INFO, "USBHost: Created pid = %d\n", pid); - return pid < 0 ? -ENOEXEC : OK; + syslog(LOG_INFO, "USBHost: Created pid = %d\n", ret); + return ret < 0 ? -ENOEXEC : OK; } return -ENODEV; diff --git a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c index d50cf10..98bf5a5 100644 --- a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c +++ b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c @@ -184,7 +184,7 @@ typedef struct fault_flags_t flags; /* What is in the dump */ uintptr_t current_regs; /* Used to validate the dump */ int lineno; /* __LINE__ to up_assert */ - int pid; /* Process ID */ + pid_t pid; /* Process ID */ uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */ stack_t stacks; /* Stack info */ #if CONFIG_TASK_NAME_SIZE > 0 diff --git a/drivers/1wire/1wire.c b/drivers/1wire/1wire.c index ce673a0..43aee5c 100644 --- a/drivers/1wire/1wire.c +++ b/drivers/1wire/1wire.c @@ -46,7 +46,7 @@ # define onewire_leuint32(x) (x) #endif -#define NO_HOLDER ((pid_t)-1) +#define NO_HOLDER (INVALID_PROCESS_ID) /**************************************************************************** * Private Function Prototypes diff --git a/drivers/lcd/ft80x.h b/drivers/lcd/ft80x.h index 4adc3ba..5c5ff97 100644 --- a/drivers/lcd/ft80x.h +++ b/drivers/lcd/ft80x.h @@ -154,7 +154,7 @@ struct ft80x_eventinfo_s struct sigevent event; /* Describe the way a task is to be notified */ struct sigwork_s work; /* Work for SIGEV_THREAD */ bool enable; /* True: enable notification; false: disable */ - int16_t pid; /* Send the notification to this task */ + pid_t pid; /* Send the notification to this task */ }; /* This structure describes the overall state of the FT80x driver */ diff --git a/drivers/net/phy_notify.c b/drivers/net/phy_notify.c index 35b13eb..9f9f0bf 100644 --- a/drivers/net/phy_notify.c +++ b/drivers/net/phy_notify.c @@ -162,7 +162,7 @@ static FAR struct phy_notify_s *phy_find_unassigned(void) client->assigned = true; client->intf[0] = '\0'; - client->pid = -1; + client->pid = INVALID_PROCESS_ID; client->enable = NULL; /* Return the client entry assigned to the caller */ @@ -388,7 +388,7 @@ int phy_notify_unsubscribe(FAR const char *intf, pid_t pid) client->assigned = false; client->intf[0] = '\0'; - client->pid = -1; + client->pid = INVALID_PROCESS_ID; phy_semgive(); } diff --git a/drivers/net/slip.c b/drivers/net/slip.c index a4c4608..f1b492d 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c @@ -1013,30 +1013,34 @@ int slip_initialize(int intf, FAR const char *devname) argv[0] = buffer; argv[1] = NULL; - priv->rxpid = kthread_create("rxslip", CONFIG_NET_SLIP_DEFPRIO, - CONFIG_NET_SLIP_STACKSIZE, slip_rxtask, - (FAR char * const *)argv); - if (priv->rxpid < 0) + ret = kthread_create("rxslip", CONFIG_NET_SLIP_DEFPRIO, + CONFIG_NET_SLIP_STACKSIZE, slip_rxtask, + (FAR char * const *)argv); + if (ret < 0) { nerr("ERROR: Failed to start receiver task\n"); - return priv->rxpid; + return ret; } + priv->rxpid = (pid_t)ret; + /* Wait and make sure that the receive task is started. */ slip_forcetake(priv); /* Start the SLIP transmitter kernel thread */ - priv->txpid = kthread_create("txslip", CONFIG_NET_SLIP_DEFPRIO, - CONFIG_NET_SLIP_STACKSIZE, slip_txtask, - (FAR char * const *)argv); - if (priv->txpid < 0) + ret = kthread_create("txslip", CONFIG_NET_SLIP_DEFPRIO, + CONFIG_NET_SLIP_STACKSIZE, slip_txtask, + (FAR char * const *)argv); + if (ret < 0) { nerr("ERROR: Failed to start receiver task\n"); - return priv->txpid; + return ret; } + priv->txpid = (pid_t)ret; + /* Wait and make sure that the transmit task is started. */ slip_forcetake(priv); diff --git a/drivers/net/telnet.c b/drivers/net/telnet.c index f2bb20b..5b7dec3 100644 --- a/drivers/net/telnet.c +++ b/drivers/net/telnet.c @@ -227,7 +227,7 @@ static const struct file_operations g_factory_fops = * characters received via Telenet (via Ctrl-C SIGINT, in particular). */ -static pid_t g_telnet_io_kthread; +static pid_t g_telnet_io_kthread = INVALID_PROCESS_ID; static struct telnet_dev_s *g_telnet_clients[CONFIG_TELNET_MAXLCLIENTS]; static sem_t g_iosem = SEM_INITIALIZER(0); static sem_t g_clients_sem = SEM_INITIALIZER(1); @@ -1006,7 +1006,7 @@ static int telnet_session(FAR struct telnet_session_s *session) priv->td_pending = 0; priv->td_offset = 0; #ifdef HAVE_SIGNALS - priv->td_pid = -1; + priv->td_pid = INVALID_PROCESS_ID; #endif #ifdef CONFIG_TELNET_SUPPORT_NAWS priv->td_rows = 25; @@ -1092,7 +1092,7 @@ static int telnet_session(FAR struct telnet_session_s *session) /* Has the I/O thread been started? */ - if (g_telnet_io_kthread == (pid_t)0) + if (g_telnet_io_kthread == INVALID_PROCESS_ID) { /* g_iosem is used for signaling and, hence, must not participate in * priority inheritance. @@ -1102,10 +1102,13 @@ static int telnet_session(FAR struct telnet_session_s *session) /* Start the I/O thread */ - g_telnet_io_kthread = - kthread_create("telnet_io", CONFIG_TELNET_IOTHREAD_PRIORITY, - CONFIG_TELNET_IOTHREAD_STACKSIZE, telnet_io_main, - NULL); + ret = kthread_create("telnet_io", CONFIG_TELNET_IOTHREAD_PRIORITY, + CONFIG_TELNET_IOTHREAD_STACKSIZE, telnet_io_main, + NULL); + if (ret > 0) + { + g_telnet_io_kthread = ret; + } } /* Save ourself in the list of Telnet client threads */ diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c index 6f9094e..e7467c6 100644 --- a/drivers/rptun/rptun.c +++ b/drivers/rptun/rptun.c @@ -49,7 +49,7 @@ #endif #define RPTUNIOC_NONE 0 -#define NO_HOLDER (pid_t)-1 +#define NO_HOLDER (INVALID_PROCESS_ID) /**************************************************************************** * Private Types @@ -177,7 +177,7 @@ static struct image_store_ops g_rptun_storeops = static sem_t g_rptunlock = SEM_INITIALIZER(1); static pid_t g_holder = NO_HOLDER; -static unsigned int g_count = 0; +static unsigned int g_count; static METAL_DECLARE_LIST(g_rptun_cb); static METAL_DECLARE_LIST(g_rptun_priv); @@ -958,11 +958,8 @@ int rptun_initialize(FAR struct rptun_dev_s *dev) argv[1] = arg1; argv[2] = NULL; - ret = kthread_create("rptun", - CONFIG_RPTUN_PRIORITY, - CONFIG_RPTUN_STACKSIZE, - rptun_thread, - argv); + ret = kthread_create("rptun", CONFIG_RPTUN_PRIORITY, + CONFIG_RPTUN_STACKSIZE, rptun_thread, argv); if (ret < 0) { goto err_thread; diff --git a/drivers/sensors/fakesensor.c b/drivers/sensors/fakesensor.c index 2860f96..8631e4d 100644 --- a/drivers/sensors/fakesensor.c +++ b/drivers/sensors/fakesensor.c @@ -404,7 +404,8 @@ int fakesensor_init(int type, FAR const char *file_name, argv[0] = arg1; argv[1] = NULL; ret = kthread_create("fakesensor_thread", SCHED_PRIORITY_DEFAULT, - CONFIG_DEFAULT_TASK_STACKSIZE, fakesensor_thread, argv); + CONFIG_DEFAULT_TASK_STACKSIZE, + fakesensor_thread, argv); if (ret < 0) { kmm_free(sensor); diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index a6bdbf5..30bc81d 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -1428,7 +1428,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case TIOCNOTTY: { - dev->pid = (pid_t)-1; + dev->pid = INVALID_PROCESS_ID; ret = 0; } break; @@ -1703,7 +1703,7 @@ int uart_register(FAR const char *path, FAR uart_dev_t *dev) #if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP) /* Initialize of the task that will receive SIGINT signals. */ - dev->pid = (pid_t)-1; + dev->pid = INVALID_PROCESS_ID; #endif #ifdef CONFIG_SERIAL_TERMIOS diff --git a/drivers/syslog/syslog_device.c b/drivers/syslog/syslog_device.c index 01697f3..51d441c 100644 --- a/drivers/syslog/syslog_device.c +++ b/drivers/syslog/syslog_device.c @@ -57,7 +57,7 @@ /* An invalid thread ID */ -#define NO_HOLDER ((pid_t)-1) +#define NO_HOLDER (INVALID_PROCESS_ID) /**************************************************************************** * Private Types @@ -321,7 +321,7 @@ static int syslog_dev_outputready(FAR struct syslog_dev_s *syslog_dev) /* Cases (4) and (5) */ - if (up_interrupt_context() || getpid() == 0) + if (up_interrupt_context() || sched_idletask()) { return -ENOSYS; } @@ -768,9 +768,9 @@ void syslog_dev_uninitialize(FAR struct syslog_channel_s *channel) * interrupt context. */ - if (up_interrupt_context() || getpid() == 0) + if (up_interrupt_context() || sched_idletask()) { - DEBUGASSERT(!up_interrupt_context() && getpid() != 0); + DEBUGASSERT(!up_interrupt_context() && !sched_idletask()); return; } diff --git a/drivers/usbdev/usbmsc.c b/drivers/usbdev/usbmsc.c index 5c3a3fb..cd7a683 100644 --- a/drivers/usbdev/usbmsc.c +++ b/drivers/usbdev/usbmsc.c @@ -1689,16 +1689,17 @@ int usbmsc_exportluns(FAR void *handle) g_usbmsc_handoff = priv; uinfo("Starting SCSI worker thread\n"); - priv->thpid = kthread_create("scsid", CONFIG_USBMSC_SCSI_PRIO, - CONFIG_USBMSC_SCSI_STACKSIZE, - usbmsc_scsi_main, NULL); - if (priv->thpid <= 0) + ret = kthread_create("scsid", CONFIG_USBMSC_SCSI_PRIO, + CONFIG_USBMSC_SCSI_STACKSIZE, + usbmsc_scsi_main, NULL); + if (ret < 0) { - usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_THREADCREATE), - (uint16_t)priv->thpid); + usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_THREADCREATE), (uint16_t)ret); goto errout_with_lock; } + priv->thpid = (pid_t)ret; + /* Wait for the worker thread to run and initialize */ uinfo("Waiting for the SCSI worker thread\n"); diff --git a/drivers/usbhost/usbhost_hidkbd.c b/drivers/usbhost/usbhost_hidkbd.c index 84b1862..c44d378 100644 --- a/drivers/usbhost/usbhost_hidkbd.c +++ b/drivers/usbhost/usbhost_hidkbd.c @@ -1738,21 +1738,21 @@ static inline int usbhost_devinit(FAR struct usbhost_state_s *priv) g_priv = priv; - priv->pollpid = kthread_create("kbdpoll", CONFIG_HIDKBD_DEFPRIO, - CONFIG_HIDKBD_STACKSIZE, - (main_t)usbhost_kbdpoll, - (FAR char * const *)NULL); - if (priv->pollpid < 0) + ret = kthread_create("kbdpoll", CONFIG_HIDKBD_DEFPRIO, + CONFIG_HIDKBD_STACKSIZE, (main_t)usbhost_kbdpoll, + (FAR char * const *)NULL); + if (ret < 0) { /* Failed to started the poll thread... * probably due to memory resources */ usbhost_givesem(&g_exclsem); - ret = (int)priv->pollpid; goto errout; } + priv->pollpid = (pid_t)ret; + /* Now wait for the poll task to get properly initialized */ ret = usbhost_takesem(&g_syncsem); diff --git a/drivers/usbhost/usbhost_hidmouse.c b/drivers/usbhost/usbhost_hidmouse.c index da4f3c3..84cfa00 100644 --- a/drivers/usbhost/usbhost_hidmouse.c +++ b/drivers/usbhost/usbhost_hidmouse.c @@ -1703,21 +1703,21 @@ static inline int usbhost_devinit(FAR struct usbhost_state_s *priv) g_priv = priv; - priv->pollpid = kthread_create("mouse", CONFIG_HIDMOUSE_DEFPRIO, - CONFIG_HIDMOUSE_STACKSIZE, - (main_t)usbhost_mouse_poll, - (FAR char * const *)NULL); - if (priv->pollpid < 0) + ret = kthread_create("mouse", CONFIG_HIDMOUSE_DEFPRIO, + CONFIG_HIDMOUSE_STACKSIZE, (main_t)usbhost_mouse_poll, + (FAR char * const *)NULL); + if (ret < 0) { /* Failed to started the poll thread... * probably due to memory resources */ usbhost_givesem(&g_exclsem); - ret = priv->pollpid; goto errout; } + priv->pollpid = (pid_t)ret; + /* Now wait for the poll task to get properly initialized */ ret = usbhost_takesem(&g_syncsem); diff --git a/drivers/usbhost/usbhost_max3421e.c b/drivers/usbhost/usbhost_max3421e.c index 7261eff..30ad966 100644 --- a/drivers/usbhost/usbhost_max3421e.c +++ b/drivers/usbhost/usbhost_max3421e.c @@ -121,6 +121,8 @@ # define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif +#define NO_HOLDER (INVALID_PROCESS_ID) + /* Debug ********************************************************************/ #define TR_FMT1 false @@ -1183,7 +1185,7 @@ static void max3421e_give_exclsem(FAR struct max3421e_usbhost_s *priv) { /* No.. give the semaphore */ - priv->holder = (pid_t)-1; + priv->holder = NO_HOLDER; priv->exclcount = 0; max3421e_givesem(&priv->exclsem); } @@ -4800,7 +4802,7 @@ static inline int max3421e_sw_initialize(FAR struct max3421e_usbhost_s *priv, priv->connected = false; priv->irqset = 0; priv->change = false; - priv->holder = (pid_t)-1; + priv->holder = NO_HOLDER; /* Put all of the channels back in their initial, allocated state */ diff --git a/drivers/usbhost/usbhost_xboxcontroller.c b/drivers/usbhost/usbhost_xboxcontroller.c index f7ef5f5..87f5141 100644 --- a/drivers/usbhost/usbhost_xboxcontroller.c +++ b/drivers/usbhost/usbhost_xboxcontroller.c @@ -1404,21 +1404,22 @@ static inline int usbhost_devinit(FAR struct usbhost_state_s *priv) g_priv = priv; uinfo("Starting thread\n"); - priv->pollpid = kthread_create("xbox", CONFIG_XBOXCONTROLLER_DEFPRIO, - CONFIG_XBOXCONTROLLER_STACKSIZE, - (main_t)usbhost_xboxcontroller_poll, - (FAR char * const *)NULL); - if (priv->pollpid < 0) + ret = kthread_create("xbox", CONFIG_XBOXCONTROLLER_DEFPRIO, + CONFIG_XBOXCONTROLLER_STACKSIZE, + (main_t)usbhost_xboxcontroller_poll, + (FAR char * const *)NULL); + if (ret < 0) { /* Failed to started the poll thread... probably due to memory * resources. */ usbhost_givesem(&g_exclsem); - ret = priv->pollpid; goto errout; } + priv->pollpid = (pid_t)ret; + /* Now wait for the poll task to get properly initialized */ usbhost_forcetake(&g_syncsem); diff --git a/drivers/usbmonitor/usbmonitor.c b/drivers/usbmonitor/usbmonitor.c index 2096908..2229889 100644 --- a/drivers/usbmonitor/usbmonitor.c +++ b/drivers/usbmonitor/usbmonitor.c @@ -221,7 +221,7 @@ int usbmonitor_start(void) } else { - g_usbmonitor.pid = ret; + g_usbmonitor.pid = (pid_t)ret; uinfo("Started: %d\n", g_usbmonitor.pid); ret = OK; } diff --git a/drivers/video/vnc/vnc_fbdev.c b/drivers/video/vnc/vnc_fbdev.c index 371b1db..0aa6293 100644 --- a/drivers/video/vnc/vnc_fbdev.c +++ b/drivers/video/vnc/vnc_fbdev.c @@ -490,7 +490,7 @@ static int vnc_start_server(int display) { FAR char *argv[2]; char str[8]; - pid_t pid; + int ret; DEBUGASSERT(display >= 0 && display < RFB_MAX_DISPLAYS); @@ -515,13 +515,13 @@ static int vnc_start_server(int display) argv[0] = str; argv[1] = NULL; - pid = kthread_create("vnc_server", CONFIG_VNCSERVER_PRIO, + ret = kthread_create("vnc_server", CONFIG_VNCSERVER_PRIO, CONFIG_VNCSERVER_STACKSIZE, (main_t)vnc_server, argv); - if (pid < 0) + if (ret < 0) { - gerr("ERROR: Failed to start the VNC server: %d\n", (int)pid); - return (int)pid; + gerr("ERROR: Failed to start the VNC server: %d\n", ret); + return ret; } return OK; diff --git a/drivers/wireless/bluetooth/bt_uart_shim.c b/drivers/wireless/bluetooth/bt_uart_shim.c index 1c250e4..56707a0 100644 --- a/drivers/wireless/bluetooth/bt_uart_shim.c +++ b/drivers/wireless/bluetooth/bt_uart_shim.c @@ -61,7 +61,7 @@ struct hciuart_state_s struct file f; /* File structure */ bool enabled; /* Flag indicating that reception is enabled */ - int serialmontask; /* The receive serial octets task handle */ + pid_t serialmontask; /* The receive serial octets task handle */ }; struct hciuart_config_s @@ -423,10 +423,12 @@ FAR struct btuart_lowerhalf_s *btuart_shim_getdevice(FAR const char *path) argv[0] = arg1; argv[1] = NULL; - s->serialmontask = kthread_create("BT HCI Rx", - CONFIG_BLUETOOTH_TXCONN_PRIORITY, - CONFIG_DEFAULT_TASK_STACKSIZE, - hcicollecttask, argv); + ret = kthread_create("BT HCI Rx", CONFIG_BLUETOOTH_TXCONN_PRIORITY, + CONFIG_DEFAULT_TASK_STACKSIZE, hcicollecttask, argv); + if (ret > 0) + { + s->serialmontask = (pid_t)ret; + } return (FAR struct btuart_lowerhalf_s *)n; } diff --git a/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.c b/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.c index 9f0d2cc..346861e 100644 --- a/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.c +++ b/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.c @@ -781,7 +781,7 @@ int bcmf_bus_sdio_initialize(FAR struct bcmf_dev_s *priv, goto exit_uninit_hw; } - sbus->thread_id = ret; + sbus->thread_id = (pid_t)ret; /* SDIO bus is up and running */ diff --git a/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.h b/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.h index ac42149..1eb3db8 100644 --- a/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.h +++ b/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.h @@ -87,7 +87,7 @@ struct bcmf_sdio_dev_s volatile bool ready; /* Current device status */ bool sleeping; /* Current sleep status */ - int thread_id; /* Processing thread id */ + pid_t thread_id; /* Processing thread id */ sem_t thread_signal; /* Semaphore for processing thread event */ struct wdog_s waitdog; /* Processing thread waitdog */ diff --git a/fs/aio/aio_initialize.c b/fs/aio/aio_initialize.c index 3fa9962..d238131 100644 --- a/fs/aio/aio_initialize.c +++ b/fs/aio/aio_initialize.c @@ -49,15 +49,16 @@ static dq_queue_t g_aioc_free; /* This counting semaphore tracks the number of free AIO containers */ -static sem_t g_aioc_freesem; +static sem_t g_aioc_freesem = NXSEM_INITIALIZER(CONFIG_FS_NAIOC, + SEM_PRIO_NONE); /* This binary semaphore supports exclusive access to the list of pending * asynchronous I/O. g_aio_holder and a_aio_count support the reentrant * lock. */ -static sem_t g_aio_exclsem; -static pid_t g_aio_holder; +static sem_t g_aio_exclsem = SEM_INITIALIZER(1); +static pid_t g_aio_holder = INVALID_PROCESS_ID; static uint16_t g_aio_count; /**************************************************************************** @@ -92,19 +93,6 @@ void aio_initialize(void) { int i; - /* Initialize counting semaphores */ - - nxsem_init(&g_aioc_freesem, 0, CONFIG_FS_NAIOC); - nxsem_set_protocol(&g_aioc_freesem, SEM_PRIO_NONE); - nxsem_init(&g_aio_exclsem, 0, 1); - - g_aio_holder = INVALID_PROCESS_ID; - - /* Initialize the container queues */ - - dq_init(&g_aioc_free); - dq_init(&g_aio_pending); - /* Add all of the pre-allocated AIO containers to the free list */ for (i = 0; i < CONFIG_FS_NAIOC; i++) diff --git a/fs/inode/fs_inode.c b/fs/inode/fs_inode.c index 93a05ad..a5aa0db 100644 --- a/fs/inode/fs_inode.c +++ b/fs/inode/fs_inode.c @@ -37,7 +37,7 @@ * Pre-processor Definitions ****************************************************************************/ -#define NO_HOLDER ((pid_t)-1) +#define NO_HOLDER (INVALID_PROCESS_ID) /**************************************************************************** * Private Types diff --git a/fs/procfs/fs_procfsmeminfo.c b/fs/procfs/fs_procfsmeminfo.c index c53f34e..29f3ff3 100644 --- a/fs/procfs/fs_procfsmeminfo.c +++ b/fs/procfs/fs_procfsmeminfo.c @@ -450,7 +450,7 @@ static ssize_t memdump_write(FAR struct file *filep, FAR const char *buffer, { FAR const struct procfs_meminfo_entry_s *entry; FAR struct meminfo_file_s *procfile; - pid_t pid = -1; + pid_t pid = INVALID_PROCESS_ID; DEBUGASSERT(filep != NULL && buffer != NULL && buflen > 0); @@ -462,11 +462,11 @@ static ssize_t memdump_write(FAR struct file *filep, FAR const char *buffer, switch (buffer[0]) { case 'u': - pid = -1; + pid = (pid_t)-1; break; case 'f': - pid = -2; + pid = (pid_t)-2; break; #ifdef CONFIG_DEBUG_MM default: diff --git a/fs/spiffs/src/spiffs.h b/fs/spiffs/src/spiffs.h index 4a78b2a..bf4b832 100644 --- a/fs/spiffs/src/spiffs.h +++ b/fs/spiffs/src/spiffs.h @@ -70,7 +70,7 @@ extern "C" /* Re-entrant semaphore definitions */ -#define SPIFFS_NO_HOLDER ((pid_t)-1) +#define SPIFFS_NO_HOLDER (INVALID_PROCESS_ID) /**************************************************************************** * Public Types diff --git a/graphics/nxmu/nxmu_start.c b/graphics/nxmu/nxmu_start.c index 271ffe6..5bf224d 100644 --- a/graphics/nxmu/nxmu_start.c +++ b/graphics/nxmu/nxmu_start.c @@ -182,7 +182,7 @@ int nxmu_start(int display, int plane) { FAR char display_str[8]; FAR char plane_str[8]; - pid_t server; + int server; FAR char * const argv[3] = { (FAR char * const)display_str, @@ -201,8 +201,8 @@ int nxmu_start(int display, int plane) if (server < 0) { gerr("ERROR: Failed to create nx_server kernel thread: %d\n", - (int)server); - return (int)server; + server); + return server; } g_nxserver_started[display] = true; diff --git a/graphics/nxterm/nxterm.h b/graphics/nxterm/nxterm.h index 45d84d3..70a25c2 100644 --- a/graphics/nxterm/nxterm.h +++ b/graphics/nxterm/nxterm.h @@ -54,7 +54,7 @@ /* Semaphore protection */ -#define NO_HOLDER (pid_t)-1 +#define NO_HOLDER (INVALID_PROCESS_ID) /* VT100 escape sequence processing */ diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index 2d8395e..6c38313 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -79,7 +79,7 @@ /* Special task IDS. Any negative PID is invalid. */ -#define NULL_TASK_PROCESS_ID (pid_t)0 +#define IDLE_PROCESS_ID (pid_t)0 #define INVALID_PROCESS_ID (pid_t)-1 /* This is the maximum number of times that a lock can be set */ diff --git a/libs/libc/modlib/modlib_registry.c b/libs/libc/modlib/modlib_registry.c index 850242f..53e4e22 100644 --- a/libs/libc/modlib/modlib_registry.c +++ b/libs/libc/modlib/modlib_registry.c @@ -36,7 +36,7 @@ * Pre-processor Definitions ****************************************************************************/ -#define NO_HOLDER ((pid_t)-1) +#define NO_HOLDER (INVALID_PROCESS_ID) /**************************************************************************** * Private Types diff --git a/mm/mm_heap/mm.h b/mm/mm_heap/mm.h index 6f442db..c4c6a9d 100644 --- a/mm/mm_heap/mm.h +++ b/mm/mm_heap/mm.h @@ -160,7 +160,7 @@ typedef uint32_t mmsize_t; struct mm_allocnode_s { #ifdef CONFIG_DEBUG_MM - uint32_t pid; /* The pid for caller */ + pid_t pid; /* The pid for caller */ FAR void *backtrace[MM_BACKTRACE_DEPTH]; /* The backtrace buffer for caller */ #endif mmsize_t size; /* Size of this chunk */ @@ -175,7 +175,7 @@ static_assert(SIZEOF_MM_ALLOCNODE <= MM_MIN_CHUNK, struct mm_freenode_s { #ifdef CONFIG_DEBUG_MM - uint32_t pid; /* The pid for caller */ + pid_t pid; /* The pid for caller */ FAR void *backtrace[MM_BACKTRACE_DEPTH]; /* The backtrace buffer for caller */ #endif mmsize_t size; /* Size of this chunk */ diff --git a/net/route/net_fileroute.c b/net/route/net_fileroute.c index e9ff85a..5349979 100644 --- a/net/route/net_fileroute.c +++ b/net/route/net_fileroute.c @@ -47,7 +47,7 @@ * of the lock. */ -#define NO_HOLDER ((pid_t)-1) +#define NO_HOLDER (INVALID_PROCESS_ID) /**************************************************************************** * Private Data diff --git a/net/utils/net_lock.c b/net/utils/net_lock.c index db2af19..8d634cb 100644 --- a/net/utils/net_lock.c +++ b/net/utils/net_lock.c @@ -34,6 +34,7 @@ #include <nuttx/irq.h> #include <nuttx/clock.h> #include <nuttx/semaphore.h> +#include <nuttx/sched.h> #include <nuttx/mm/iob.h> #include <nuttx/net/net.h> @@ -43,7 +44,7 @@ * Pre-processor Definitions ****************************************************************************/ -#define NO_HOLDER (pid_t)-1 +#define NO_HOLDER (INVALID_PROCESS_ID) /**************************************************************************** * Private Data diff --git a/sched/mqueue/mq_notify.c b/sched/mqueue/mq_notify.c index fb0d245..021fa41 100644 --- a/sched/mqueue/mq_notify.c +++ b/sched/mqueue/mq_notify.c @@ -157,7 +157,7 @@ int mq_notify(mqd_t mqdes, FAR const struct sigevent *notification) * Is it trying to remove it? */ - else if ((msgq->ntpid != rtcb->pid) || (notification)) + else if ((msgq->ntpid != rtcb->pid) || (notification != NULL)) { /* This thread does not own the notification OR it is * not trying to remove it. Return EBUSY. diff --git a/sched/pthread/pthread_cancel.c b/sched/pthread/pthread_cancel.c index 469847a..9965706 100644 --- a/sched/pthread/pthread_cancel.c +++ b/sched/pthread/pthread_cancel.c @@ -47,7 +47,7 @@ int pthread_cancel(pthread_t thread) /* First, make sure that the handle references a valid thread */ - if (thread == 0) + if ((pid_t)thread == IDLE_PROCESS_ID) { /* pid == 0 is the IDLE task (in a single CPU configuration). Callers * cannot cancel the IDLE task. diff --git a/sched/pthread/pthread_condclockwait.c b/sched/pthread/pthread_condclockwait.c index 8bc046e..50995af 100644 --- a/sched/pthread/pthread_condclockwait.c +++ b/sched/pthread/pthread_condclockwait.c @@ -243,7 +243,7 @@ int pthread_cond_clockwait(FAR pthread_cond_t *cond, #endif /* Give up the mutex */ - mutex->pid = -1; + mutex->pid = INVALID_PROCESS_ID; #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE mflags = mutex->flags; #endif diff --git a/sched/pthread/pthread_condwait.c b/sched/pthread/pthread_condwait.c index ad3e707..2ec4b99 100644 --- a/sched/pthread/pthread_condwait.c +++ b/sched/pthread/pthread_condwait.c @@ -93,7 +93,7 @@ int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex) sinfo("Give up mutex / take cond\n"); sched_lock(); - mutex->pid = -1; + mutex->pid = INVALID_PROCESS_ID; #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE mflags = mutex->flags; #endif diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index 2e64bf4..ea73f11 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -526,7 +526,7 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, * as well. */ - pid = (int)ptcb->cmn.pid; + pid = ptcb->cmn.pid; pjoin->thread = (pthread_t)pid; /* Initialize the semaphores in the join structure to zero. */ diff --git a/sched/pthread/pthread_mutexconsistent.c b/sched/pthread/pthread_mutexconsistent.c index 48fb5f5..f910510 100644 --- a/sched/pthread/pthread_mutexconsistent.c +++ b/sched/pthread/pthread_mutexconsistent.c @@ -105,7 +105,7 @@ int pthread_mutex_consistent(FAR pthread_mutex_t *mutex) { /* The thread associated with the PID no longer exists */ - mutex->pid = -1; + mutex->pid = INVALID_PROCESS_ID; mutex->flags &= _PTHREAD_MFLAGS_ROBUST; #ifdef CONFIG_PTHREAD_MUTEX_TYPES mutex->nlocks = 0; diff --git a/sched/pthread/pthread_mutexdestroy.c b/sched/pthread/pthread_mutexdestroy.c index a6d9f9e..354d5fd 100644 --- a/sched/pthread/pthread_mutexdestroy.c +++ b/sched/pthread/pthread_mutexdestroy.c @@ -94,7 +94,7 @@ int pthread_mutex_destroy(FAR pthread_mutex_t *mutex) { /* The thread associated with the PID no longer exists */ - mutex->pid = -1; + mutex->pid = INVALID_PROCESS_ID; /* Reset the semaphore. If threads are were on this * semaphore, then this will awakened them and make @@ -111,7 +111,7 @@ int pthread_mutex_destroy(FAR pthread_mutex_t *mutex) * mutex. */ - else if (mutex->pid != -1) + else if (mutex->pid != INVALID_PROCESS_ID) { /* Yes.. then we cannot destroy the mutex now. */ diff --git a/sched/pthread/pthread_mutexinit.c b/sched/pthread/pthread_mutexinit.c index fc69f63..95da3f4 100644 --- a/sched/pthread/pthread_mutexinit.c +++ b/sched/pthread/pthread_mutexinit.c @@ -103,7 +103,7 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex, /* Indicate that the semaphore is not held by any thread. */ - mutex->pid = -1; + mutex->pid = INVALID_PROCESS_ID; /* Initialize the mutex like a semaphore with initial count = 1 */ diff --git a/sched/pthread/pthread_mutextimedlock.c b/sched/pthread/pthread_mutextimedlock.c index 90bc82b..af06988 100644 --- a/sched/pthread/pthread_mutextimedlock.c +++ b/sched/pthread/pthread_mutextimedlock.c @@ -78,7 +78,7 @@ int pthread_mutex_timedlock(FAR pthread_mutex_t *mutex, FAR const struct timespec *abs_timeout) { - int mypid = (int)getpid(); + pid_t mypid = getpid(); int ret = EINVAL; sinfo("mutex=0x%p\n", mutex); diff --git a/sched/pthread/pthread_mutextrylock.c b/sched/pthread/pthread_mutextrylock.c index a225db6..84e2a56 100644 --- a/sched/pthread/pthread_mutextrylock.c +++ b/sched/pthread/pthread_mutextrylock.c @@ -76,7 +76,7 @@ int pthread_mutex_trylock(FAR pthread_mutex_t *mutex) if (mutex != NULL) { - int mypid = (int)getpid(); + pid_t mypid = getpid(); /* Make sure the semaphore is stable while we make the following * checks. This all needs to be one atomic action. diff --git a/sched/pthread/pthread_mutexunlock.c b/sched/pthread/pthread_mutexunlock.c index 9fb71e5..60ec293 100644 --- a/sched/pthread/pthread_mutexunlock.c +++ b/sched/pthread/pthread_mutexunlock.c @@ -214,7 +214,7 @@ int pthread_mutex_unlock(FAR pthread_mutex_t *mutex) { /* Nullify the pid and lock count then post the semaphore */ - mutex->pid = -1; + mutex->pid = INVALID_PROCESS_ID; #ifdef CONFIG_PTHREAD_MUTEX_TYPES mutex->nlocks = 0; #endif diff --git a/sched/sched/sched_idletask.c b/sched/sched/sched_idletask.c index c48b0f4..ab83fa6 100644 --- a/sched/sched/sched_idletask.c +++ b/sched/sched/sched_idletask.c @@ -43,7 +43,7 @@ * Check if the caller is an IDLE thread. For most implementations of * the SYSLOG output semaphore locking is required for mutual exclusion. * The idle threads are unable to lock semaphores because they cannot - * want. So IDLE thread output is a special case and is treated much as + * wait. So IDLE thread output is a special case and is treated much as * we treat debug output from an interrupt handler. * * Input Parameters: diff --git a/sched/sched/sched_wait.c b/sched/sched/sched_wait.c index e617a16..bf7f954 100644 --- a/sched/sched/sched_wait.c +++ b/sched/sched/sched_wait.c @@ -44,7 +44,7 @@ pid_t nx_wait(FAR int *stat_loc) { - return nx_waitpid((pid_t)-1, stat_loc, 0); + return nx_waitpid(INVALID_PROCESS_ID, stat_loc, 0); } /**************************************************************************** @@ -61,8 +61,8 @@ pid_t nx_wait(FAR int *stat_loc) * available prior to the call to wait(), return will be immediate. * * The waitpid() function will behave identically to wait(), if the pid - * argument is (pid_t)-1 and the options argument is 0. Otherwise, its - * behaviour will be modified by the values of the pid and options + * argument is INVALID_PROCESS_ID and the options argument is 0. Otherwise, + * its behaviour will be modified by the values of the pid and options * arguments. * * Input Parameters: @@ -79,7 +79,7 @@ pid_t wait(FAR int *stat_loc) * trivial case. */ - return waitpid((pid_t)-1, stat_loc, 0); + return waitpid(INVALID_PROCESS_ID, stat_loc, 0); } #endif /* CONFIG_SCHED_WAITPID && CONFIG_SCHED_HAVE_PARENT */ diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c index 92d4d10..a1a74fc 100644 --- a/sched/sched/sched_waitpid.c +++ b/sched/sched/sched_waitpid.c @@ -171,8 +171,8 @@ errout: /**************************************************************************** * * If CONFIG_SCHED_HAVE_PARENT is defined, then waitpid will use the SIGCHLD - * signal. It can also handle the pid == (pid_t)-1 argument. This is - * slightly more spec-compliant. + * signal. It can also handle the pid == INVALID_PROCESS_ID argument. This + * is slightly more spec-compliant. * * But then I have to be concerned about the fact that NuttX does not queue * signals. This means that a flurry of signals can cause signals to be @@ -227,7 +227,7 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options) ret = -ECHILD; goto errout; } - else if (pid != (pid_t)-1) + else if (pid != INVALID_PROCESS_ID) { /* Get the TCB corresponding to this PID. NOTE: If the child has * already exited, then the PID will not map to a valid TCB. @@ -270,7 +270,7 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options) ret = -ECHILD; goto errout; } - else if (pid != (pid_t)-1) + else if (pid != INVALID_PROCESS_ID) { /* Get the TCB corresponding to this PID and make sure that the * thread it is our child. @@ -297,7 +297,7 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options) * instead). */ - if (pid == (pid_t)-1) + if (pid == INVALID_PROCESS_ID) { /* We are waiting for any child, check if there are still * children. @@ -379,7 +379,7 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options) */ if (rtcb->group->tg_nchildren == 0 || - (pid != (pid_t)-1 && nxsig_kill(pid, 0) < 0)) + (pid != INVALID_PROCESS_ID && nxsig_kill(pid, 0) < 0)) { /* We know that the child task was running okay when we started, * so we must have lost the signal. What can we do? @@ -407,11 +407,11 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options) } /* Was this the death of the thread we were waiting for? In the of - * pid == (pid_t)-1, we are waiting for any child thread. + * pid == INVALID_PROCESS_ID, we are waiting for any child thread. */ if (info.si_signo == SIGCHLD && - (pid == (pid_t)-1 || info.si_pid == pid)) + (pid == INVALID_PROCESS_ID || info.si_pid == pid)) { /* Yes... return the status and PID (in the event it was -1) */ diff --git a/sched/task/task_getpid.c b/sched/task/task_getpid.c index f0e0db3..102c633 100644 --- a/sched/task/task_getpid.c +++ b/sched/task/task_getpid.c @@ -96,5 +96,5 @@ pid_t getpid(void) * start-up/IDLE thread before the ready-to-run list has been initialized. */ - return (pid_t)0; + return IDLE_PROCESS_ID; } diff --git a/sched/task/task_getppid.c b/sched/task/task_getppid.c index 0f79784..8d19360 100644 --- a/sched/task/task_getppid.c +++ b/sched/task/task_getppid.c @@ -96,5 +96,5 @@ pid_t getppid(void) * start-up/IDLE thread before the ready-to-run list has been initialized. */ - return (pid_t)0; + return IDLE_PROCESS_ID; } diff --git a/sched/task/task_posixspawn.c b/sched/task/task_posixspawn.c index 888e7b5..881d604 100644 --- a/sched/task/task_posixspawn.c +++ b/sched/task/task_posixspawn.c @@ -316,7 +316,7 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, FAR char * const argv[], FAR char * const envp[]) { struct sched_param param; - pid_t proxy; + int proxy; #ifdef CONFIG_SCHED_WAITPID int status; #endif @@ -410,7 +410,7 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, * for use within the OS. */ - ret = nx_waitpid(proxy, &status, 0); + ret = nx_waitpid((pid_t)proxy, &status, 0); if (ret < 0) { serr("ERROR: waitpid() failed: %d\n", ret); diff --git a/sched/task/task_vfork.c b/sched/task/task_vfork.c index 1642ca4..fe87899 100644 --- a/sched/task/task_vfork.c +++ b/sched/task/task_vfork.c @@ -276,7 +276,7 @@ pid_t nxtask_start_vfork(FAR struct task_tcb_s *child) /* Get the assigned pid before we start the task */ - pid = (int)child->cmn.pid; + pid = child->cmn.pid; /* Eliminate a race condition by disabling pre-emption. The child task * can be instantiated, but cannot run until we call waitpid(). This diff --git a/wireless/bluetooth/bt_conn.c b/wireless/bluetooth/bt_conn.c index 9c52445..c69658a 100644 --- a/wireless/bluetooth/bt_conn.c +++ b/wireless/bluetooth/bt_conn.c @@ -557,14 +557,12 @@ void bt_conn_set_state(FAR struct bt_conn_s *conn, { case BT_CONN_CONNECTED: { - pid_t pid; int ret; ret = bt_queue_open(BT_CONN_TX, O_RDWR | O_CREAT, CONFIG_BLUETOOTH_TXCONN_NMSGS, &conn->tx_queue); DEBUGASSERT(ret >= 0); - UNUSED(ret); /* Get exclusive access to the handoff structure. The count will * be zero when we complete this. @@ -576,12 +574,11 @@ void bt_conn_set_state(FAR struct bt_conn_s *conn, /* Start the Tx connection kernel thread */ g_conn_handoff.conn = bt_conn_addref(conn); - pid = kthread_create("BT Conn Tx", + ret = kthread_create("BT Conn Tx", CONFIG_BLUETOOTH_TXCONN_PRIORITY, CONFIG_BLUETOOTH_TXCONN_STACKSIZE, conn_tx_kthread, NULL); - DEBUGASSERT(pid > 0); - UNUSED(pid); + DEBUGASSERT(ret > 0); /* Take the semaphore again. This will force us to wait with * the sem_count at -1. It will be zero again when we @@ -591,6 +588,8 @@ void bt_conn_set_state(FAR struct bt_conn_s *conn, ret = nxsem_wait_uninterruptible(&g_conn_handoff.sync_sem); nxsem_post(&g_conn_handoff.sync_sem); } + + UNUSED(ret); } break; diff --git a/wireless/bluetooth/bt_hcicore.c b/wireless/bluetooth/bt_hcicore.c index 54532a6..1914835 100644 --- a/wireless/bluetooth/bt_hcicore.c +++ b/wireless/bluetooth/bt_hcicore.c @@ -1438,7 +1438,6 @@ static int hci_initialize(void) static void cmd_queue_init(void) { - pid_t pid; int ret; /* When there is a command to be sent to the Bluetooth driver, it queued on @@ -1448,17 +1447,16 @@ static void cmd_queue_init(void) ret = bt_queue_open(BT_HCI_TX, O_RDWR | O_CREAT, CONFIG_BLUETOOTH_TXCMD_NMSGS, &g_btdev.tx_queue); DEBUGASSERT(ret >= 0); - UNUSED(ret); nxsem_init(&g_btdev.ncmd_sem, 0, 1); nxsem_set_protocol(&g_btdev.ncmd_sem, SEM_PRIO_NONE); g_btdev.ncmd = 1; - pid = kthread_create("BT HCI Tx", CONFIG_BLUETOOTH_TXCMD_PRIORITY, + ret = kthread_create("BT HCI Tx", CONFIG_BLUETOOTH_TXCMD_PRIORITY, CONFIG_BLUETOOTH_TXCMD_STACKSIZE, hci_tx_kthread, NULL); - DEBUGASSERT(pid > 0); - UNUSED(pid); + DEBUGASSERT(ret > 0); + UNUSED(ret); } /****************************************************************************