This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 23a3cd5ce27bf7d14138f158cf363c054f8c3d86 Author: Marco Casaroli <[email protected]> AuthorDate: Mon Oct 12 07:32:54 2026 +0200 nuttx: Fix the nxstyle errors in 31 files. apache/nuttx#20565 adds include directives to these files, and the check job runs nxstyle on the whole of every changed file. Their nxstyle errors are older than the change: braces, case labels and comments in the wrong column, missing blank lines after declarations, and long lines. Only the layout changes. With all white space and comment margins removed, every file is identical to the old one, except two: iconv() and stm32_touchscreen.c get braces around one-line statements, and getpass() gets a break aligned. The object code of the three libc files is identical before and after on qemu-armv8a:nsh with LIBC_LOCALE. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- arch/arm/src/stm32h7/stm32_crypto.c | 56 +-- arch/arm/src/xmc4/xmc4_i2c.c | 57 ++-- arch/risc-v/src/bl808/bl808_gpadc.c | 72 ++-- arch/risc-v/src/common/espressif/esp_gpio.c | 2 + arch/risc-v/src/common/espressif/esp_i2c_slave.c | 16 +- arch/risc-v/src/common/espressif/esp_i2s.c | 11 +- .../src/common/espressif/esp_temperature_sensor.c | 2 +- arch/xtensa/src/common/espressif/esp_i2c_slave.c | 16 +- arch/xtensa/src/esp32s3/esp32s3_partition.c | 12 +- .../stm32f4/mikroe-stm32f4/src/stm32_touchscreen.c | 380 +++++++++++---------- .../arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c | 2 +- .../pic32mx/pic32mx7mmb/src/pic32_touchscreen.c | 318 ++++++++--------- boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c | 29 +- boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c | 1 + drivers/analog/ads1115.c | 371 ++++++++++---------- drivers/analog/ads7046.c | 4 + drivers/analog/mcp47x6.c | 6 +- drivers/leds/ktd2052.c | 7 + drivers/mtd/mtd_cfi.c | 2 + drivers/net/oa_tc6/oa_tc6.c | 56 +-- drivers/rpmsg/rpmsg_virtio_ivshmem.c | 3 + drivers/rptun/rptun_bmp.c | 3 + drivers/video/goldfish_camera.c | 3 + drivers/wireless/bluetooth/bt_uart.c | 85 ++--- drivers/wireless/gs2200m.c | 61 ++-- libs/libbuiltin/libgcc/gcov.c | 1 + libs/libc/gdbstub/lib_gdbstub.c | 72 ++-- libs/libc/locale/lib_iconv.c | 53 +-- libs/libc/stdio/lib_fgetwc.c | 1 + libs/libc/unistd/lib_getpass.c | 2 +- sched/misc/coredump.c | 2 +- 31 files changed, 891 insertions(+), 815 deletions(-) diff --git a/arch/arm/src/stm32h7/stm32_crypto.c b/arch/arm/src/stm32h7/stm32_crypto.c index c0c7bfb55d3..9ff3b164a97 100644 --- a/arch/arm/src/stm32h7/stm32_crypto.c +++ b/arch/arm/src/stm32h7/stm32_crypto.c @@ -342,6 +342,7 @@ static int stm32_wait_for_clr(uintptr_t regaddr, uint32_t bitmask, uint32_t timeout) { uint32_t regval; + while (timeout--) { regval = stm32crypto_getreg32(regaddr); @@ -366,6 +367,7 @@ static int stm32_wait_for_set(uintptr_t regaddr, uint32_t bitmask, uint32_t timeout) { uint32_t regval; + while (timeout--) { regval = stm32crypto_getreg32(regaddr); @@ -547,7 +549,7 @@ static int hash_init(struct stm32_crypto_data *sw) case CRYPTO_SHA2_224_HMAC: regval = HASH_CR_ALGO_SHA2_224; sw->u.hash.dsize = 28; - break; + break; case CRYPTO_SHA2_256: case CRYPTO_SHA2_256_HMAC: regval = HASH_CR_ALGO_SHA2_256; @@ -561,14 +563,14 @@ static int hash_init(struct stm32_crypto_data *sw) /* If HMAC set mode, and key is large set HASH_CR_LKEY bit */ if (sw->u.hash.hmac) - { - regval |= HASH_CR_MODE_HMAC; - stm32cryptoinfo("klen %" PRIx32 "", sw->u.hash.klen); - if (sw->u.hash.klen > 64) { - regval |= HASH_CR_LKEY_GT_64; + regval |= HASH_CR_MODE_HMAC; + stm32cryptoinfo("klen %" PRIx32 "", sw->u.hash.klen); + if (sw->u.hash.klen > 64) + { + regval |= HASH_CR_LKEY_GT_64; + } } - } regval |= HASH_CR_INIT; /* set init to configure HASH algorithm */ regval |= HASH_CR_DATATYPE_8; /* 8-bit data... */ @@ -786,10 +788,10 @@ static int stm32_freesession(uint64_t tid) case CRYPTO_SHA2_224_HMAC: case CRYPTO_SHA2_256_HMAC: if (sw->u.hash.key) - { - explicit_bzero(sw->u.hash.key, sw->u.hash.klen); - kmm_free(sw->u.hash.key); - } + { + explicit_bzero(sw->u.hash.key, sw->u.hash.klen); + kmm_free(sw->u.hash.key); + } break; case CRYPTO_CRC32: @@ -911,9 +913,9 @@ static int stm32_newsession(uint32_t *sid, struct cryptoini *cri) sw->u.hash.klen = cri->cri_klen / 8; sw->u.hash.key = kmm_malloc(sw->u.hash.klen); if (sw->u.hash.key == NULL) - { - return -ENOBUFS; - } + { + return -ENOBUFS; + } bcopy(cri->cri_key, sw->u.hash.key, sw->u.hash.klen); @@ -949,9 +951,9 @@ static int stm32_newsession(uint32_t *sid, struct cryptoini *cri) sw->u.hash.hmac = false; ret = hash_init(sw); if (ret < 0) - { - return ret; - } + { + return ret; + } break; case CRYPTO_CRC32: @@ -964,11 +966,11 @@ static int stm32_newsession(uint32_t *sid, struct cryptoini *cri) case CRYPTO_AES_CTR: klen = cri->cri_klen / 8 - 4; if ((klen != 16) && (klen != 24) && (klen != 32)) - { - /* stm32h7 aes-ctr key bits support 128, 192, or 256 */ + { + /* stm32h7 aes-ctr key bits support 128, 192, or 256 */ - return -EINVAL; - } + return -EINVAL; + } break; @@ -1108,13 +1110,13 @@ static int stm32_process(struct cryptop *crp) case CRYPTO_CRC32: if (crd->crd_flags & CRD_F_UPDATE) - { - return crc32_update(sw, crp->crp_buf, crd->crd_len); - } + { + return crc32_update(sw, crp->crp_buf, crd->crd_len); + } else - { - return crc32_final(sw, crp->crp_mac); - } + { + return crc32_final(sw, crp->crp_mac); + } break; case CRYPTO_AES_CBC: return aes_cypher(crp->crp_dst, crp->crp_buf, crd->crd_len, diff --git a/arch/arm/src/xmc4/xmc4_i2c.c b/arch/arm/src/xmc4/xmc4_i2c.c index 69b19df53c6..38414abd5b3 100644 --- a/arch/arm/src/xmc4/xmc4_i2c.c +++ b/arch/arm/src/xmc4/xmc4_i2c.c @@ -958,57 +958,57 @@ struct i2c_master_s *xmc4_i2cbus_initialize(int port) { #ifdef CONFIG_XMC4_I2C0 case 0: - { - priv = (struct xmc4_i2cdev_s *)&g_i2c0; - break; - } + { + priv = (struct xmc4_i2cdev_s *)&g_i2c0; + break; + } #endif #ifdef CONFIG_XMC4_I2C1 case 1: - { - priv = (struct xmc4_i2cdev_s *)&g_i2c1; - break; - } + { + priv = (struct xmc4_i2cdev_s *)&g_i2c1; + break; + } #endif #ifdef CONFIG_XMC4_I2C2 case 2: - { - priv = (struct xmc4_i2cdev_s *)&g_i2c2; - break; - } + { + priv = (struct xmc4_i2cdev_s *)&g_i2c2; + break; + } #endif #ifdef CONFIG_XMC4_I2C3 case 3: - { - priv = (struct xmc4_i2cdev_s *)&g_i2c3; - break; - } + { + priv = (struct xmc4_i2cdev_s *)&g_i2c3; + break; + } #endif #ifdef CONFIG_XMC4_I2C4 case 4: - { - priv = (struct xmc4_i2cdev_s *)&g_i2c4; - break; - } + { + priv = (struct xmc4_i2cdev_s *)&g_i2c4; + break; + } #endif #ifdef CONFIG_XMC4_I2C5 case 5: - { - priv = (struct xmc4_i2cdev_s *)&g_i2c5; - break; - } + { + priv = (struct xmc4_i2cdev_s *)&g_i2c5; + break; + } #endif default: - { - i2cerr("No such i2c module.\n"); - return NULL; - } + { + i2cerr("No such i2c module.\n"); + return NULL; + } } nxmutex_lock(&priv->lock); @@ -1016,6 +1016,7 @@ struct i2c_master_s *xmc4_i2cbus_initialize(int port) if (priv->refs++ == 0) { int ret = i2c_initialize(priv); + if (ret < 0) { nxmutex_unlock(&priv->lock); diff --git a/arch/risc-v/src/bl808/bl808_gpadc.c b/arch/risc-v/src/bl808/bl808_gpadc.c index ad619bf6734..f80447e2bde 100644 --- a/arch/risc-v/src/bl808/bl808_gpadc.c +++ b/arch/risc-v/src/bl808/bl808_gpadc.c @@ -197,6 +197,7 @@ uint8_t bl808_gpadc_get_count() uint32_t status = getreg32(BL808_GPADC_CONFIG); uint8_t count = (status & GPADC_FIFO_DATA_COUNT_MASK) >> GPADC_FIFO_DATA_COUNT_SHIFT; + return count; } @@ -231,6 +232,7 @@ static int __gpadc_interrupt(int irq, void *context, void *arg) int receive_ret = priv->callback->au_receive(dev, channel, adc_val); + if (receive_ret) { aerr("ADC driver upper half receive error"); @@ -365,6 +367,7 @@ static int bl808_gpadc_setup(struct adc_dev_s *dev) if (channel < 12) { int pin = ch_to_gpio_map[channel]; + bl808_configgpio(pin, GPIO_INPUT | GPIO_FLOAT | GPIO_FUNC_ANA); @@ -449,40 +452,40 @@ static int bl808_gpadc_ioctl(struct adc_dev_s *dev, switch (cmd) { - case ANIOC_TRIGGER: - { - modifyreg32(BL808_GPADC_CMD, 0, GPADC_CONV_START); - ret = OK; - break; - } - - case ANIOC_GET_NCHANNELS: - { - ret = priv->nchannels; - break; - } - - case ANIOC_RESET_FIFO: - { - modifyreg32(BL808_GPADC_CONFIG, 0, - GPADC_FIFO_CLR); - ret = OK; - break; - } - - case ANIOC_SAMPLES_ON_READ: - { - ret = bl808_gpadc_get_count(); - break; - } - - default: - { - /* Other commands not implemented */ - - ret = -ENOTTY; - break; - } + case ANIOC_TRIGGER: + { + modifyreg32(BL808_GPADC_CMD, 0, GPADC_CONV_START); + ret = OK; + break; + } + + case ANIOC_GET_NCHANNELS: + { + ret = priv->nchannels; + break; + } + + case ANIOC_RESET_FIFO: + { + modifyreg32(BL808_GPADC_CONFIG, 0, + GPADC_FIFO_CLR); + ret = OK; + break; + } + + case ANIOC_SAMPLES_ON_READ: + { + ret = bl808_gpadc_get_count(); + break; + } + + default: + { + /* Other commands not implemented */ + + ret = -ENOTTY; + break; + } } return ret; @@ -495,6 +498,7 @@ static int bl808_gpadc_ioctl(struct adc_dev_s *dev, int bl808_gpadc_init(void) { struct adc_dev_s *dev = kmm_zalloc(sizeof(struct adc_dev_s)); + dev->ad_ops = &gpadc_ops; dev->ad_priv = &gpadc_priv; diff --git a/arch/risc-v/src/common/espressif/esp_gpio.c b/arch/risc-v/src/common/espressif/esp_gpio.c index eb64a4d5f8d..c10ea7d6b92 100644 --- a/arch/risc-v/src/common/espressif/esp_gpio.c +++ b/arch/risc-v/src/common/espressif/esp_gpio.c @@ -190,6 +190,7 @@ int esp_configgpio(int pin, gpio_pinattr_t attr) if ((attr & DRIVE_MASK) != 0) { uint32_t val = ((attr & DRIVE_MASK) >> DRIVE_SHIFT) - 1; + gpio_hal_set_drive_capability(&g_gpio_hal, pin, val); } else @@ -201,6 +202,7 @@ int esp_configgpio(int pin, gpio_pinattr_t attr) if ((attr & FUNCTION_MASK) != 0) { uint32_t val = ((attr & FUNCTION_MASK) >> FUNCTION_SHIFT) - 1; + gpio_hal_func_sel(&g_gpio_hal, pin, val); } else diff --git a/arch/risc-v/src/common/espressif/esp_i2c_slave.c b/arch/risc-v/src/common/espressif/esp_i2c_slave.c index 24b565d9ced..dbbb06ba2e7 100644 --- a/arch/risc-v/src/common/espressif/esp_i2c_slave.c +++ b/arch/risc-v/src/common/espressif/esp_i2c_slave.c @@ -864,17 +864,17 @@ struct i2c_slave_s *esp_i2cbus_slave_initialize(int port, int addr) switch (port) { #ifdef CONFIG_ESPRESSIF_I2C0_SLAVE_MODE - case ESPRESSIF_I2C0_SLAVE: - priv = &esp_i2c0_priv; - break; + case ESPRESSIF_I2C0_SLAVE: + priv = &esp_i2c0_priv; + break; #endif #ifdef CONFIG_ESPRESSIF_I2C1_SLAVE_MODE - case ESPRESSIF_I2C1_SLAVE: - priv = &esp_i2c1_priv; - break; + case ESPRESSIF_I2C1_SLAVE: + priv = &esp_i2c1_priv; + break; #endif - default: - return NULL; + default: + return NULL; } nxmutex_lock(&priv->lock); diff --git a/arch/risc-v/src/common/espressif/esp_i2s.c b/arch/risc-v/src/common/espressif/esp_i2s.c index 885c16b6abc..e831672eb42 100644 --- a/arch/risc-v/src/common/espressif/esp_i2s.c +++ b/arch/risc-v/src/common/espressif/esp_i2s.c @@ -554,6 +554,7 @@ static struct esp_buffer_s *i2s_buf_allocate(struct esp_i2s_s *priv) for (i = 0; i < I2S_DMADESC_NUM; i++) { size_t size = ALIGN_UP(sizeof(lldesc_t), alignment); + bfcontainer->dma_link[i] = (lldesc_t *)kmm_memalign(alignment, size); } @@ -2095,6 +2096,7 @@ static int32_t i2s_check_mclkfrequency(struct esp_i2s_s *priv) static uint32_t i2s_set_datawidth(struct esp_i2s_s *priv) { int width; + if (priv->config->tx_en) { i2s_ll_tx_set_sample_bit(priv->config->ctx->dev, @@ -3288,13 +3290,13 @@ static int i2s_dma_setup(struct esp_i2s_s *priv) #if SOC_I2S_NUM > 1 case I2S_NUM_1: - trig = GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_I2S, 1); - break; + trig = GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_I2S, 1); + break; #endif case I2S_NUM_0: - trig = GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_I2S, 0); - break; + trig = GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_I2S, 0); + break; default: i2serr("Unsupported I2S port number"); @@ -3478,6 +3480,7 @@ struct i2s_dev_s *esp_i2sbus_initialize(int port) if (priv->config->pm_lock == NULL) { esp_pm_lock_handle_t pm_lock = priv->config->pm_lock; + ret = esp_pm_lock_create(pm_type, 0, "i2s_driver", diff --git a/arch/risc-v/src/common/espressif/esp_temperature_sensor.c b/arch/risc-v/src/common/espressif/esp_temperature_sensor.c index fdd7c5e9e26..07a512a6f60 100644 --- a/arch/risc-v/src/common/espressif/esp_temperature_sensor.c +++ b/arch/risc-v/src/common/espressif/esp_temperature_sensor.c @@ -774,7 +774,7 @@ static int esp_temperature_sensor_activate( { /* Set suspend mode to sensors. */ - esp_temperature_sensor_disable(priv); + esp_temperature_sensor_disable(priv); } #ifdef CONFIG_ESPRESSIF_TEMP_UORB_POLL diff --git a/arch/xtensa/src/common/espressif/esp_i2c_slave.c b/arch/xtensa/src/common/espressif/esp_i2c_slave.c index 500c8837d8e..94d6d9cb454 100644 --- a/arch/xtensa/src/common/espressif/esp_i2c_slave.c +++ b/arch/xtensa/src/common/espressif/esp_i2c_slave.c @@ -876,17 +876,17 @@ struct i2c_slave_s *esp_i2cbus_slave_initialize(int port, int addr) switch (port) { #ifdef CONFIG_ESPRESSIF_I2C0_SLAVE - case ESPRESSIF_I2C0_SLAVE: - priv = &esp_i2c0_priv; - break; + case ESPRESSIF_I2C0_SLAVE: + priv = &esp_i2c0_priv; + break; #endif #ifdef CONFIG_ESPRESSIF_I2C1_SLAVE - case ESPRESSIF_I2C1_SLAVE: - priv = &esp_i2c1_priv; - break; + case ESPRESSIF_I2C1_SLAVE: + priv = &esp_i2c1_priv; + break; #endif - default: - return NULL; + default: + return NULL; } nxmutex_lock(&priv->lock); diff --git a/arch/xtensa/src/esp32s3/esp32s3_partition.c b/arch/xtensa/src/esp32s3/esp32s3_partition.c index 022542cf33f..ba261f3ec6a 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_partition.c +++ b/arch/xtensa/src/esp32s3/esp32s3_partition.c @@ -335,7 +335,7 @@ static int ota_set_bootseq(struct mtd_dev_priv_s *dev, int num) return -EINVAL; } - return 0; + return 0; } /**************************************************************************** @@ -382,7 +382,7 @@ static int ota_invalidate_bootseq(struct mtd_dev_priv_s *dev, int num) return -EINVAL; } - return 0; + return 0; } /**************************************************************************** @@ -647,8 +647,10 @@ static int partition_get_offset(const char *label, size_t size) uint8_t *pbuf; int partion_offset; const struct partition_info_priv_s *info; + DEBUGASSERT(label != NULL); struct mtd_dev_s *mtd = esp32s3_spiflash_encrypt_mtd(); + if (!mtd) { ferr("ERROR: Failed to get SPI flash MTD\n"); @@ -908,8 +910,10 @@ int esp32s3_partition_read(const char *label, size_t offset, void *buf, { int ret; int partion_offset; + DEBUGASSERT(label != NULL && buf != NULL); struct mtd_dev_s *mtd = esp32s3_spiflash_mtd(); + if (!mtd) { ferr("ERROR: Failed to get SPI flash MTD\n"); @@ -956,8 +960,10 @@ int esp32s3_partition_read_decrypt(const char *label, size_t offset, { int ret; int partion_offset; + DEBUGASSERT(label != NULL && buf != NULL); struct mtd_dev_s *mtd = esp32s3_spiflash_encrypt_mtd(); + if (!mtd) { ferr("ERROR: Failed to get SPI flash MTD\n"); @@ -1004,8 +1010,10 @@ int esp32s3_partition_write(const char *label, size_t offset, void *buf, { int ret; int partion_offset; + DEBUGASSERT(label != NULL && buf != NULL); struct mtd_dev_s *mtd = esp32s3_spiflash_mtd(); + if (!mtd) { ferr("ERROR: Failed to get SPI flash MTD\n"); diff --git a/boards/arm/stm32f4/mikroe-stm32f4/src/stm32_touchscreen.c b/boards/arm/stm32f4/mikroe-stm32f4/src/stm32_touchscreen.c index 22a7b7b75bf..35c3f8eced2 100644 --- a/boards/arm/stm32f4/mikroe-stm32f4/src/stm32_touchscreen.c +++ b/boards/arm/stm32f4/mikroe-stm32f4/src/stm32_touchscreen.c @@ -738,230 +738,233 @@ static void tc_worker(void *arg) switch (priv->state) { - /* The touchscreen is IDLE and we are ready to begin the next sample */ + /* The touchscreen is IDLE and we are ready to begin the next sample */ - case TC_READY: - { - /* Select DRIVE for Y sampling */ + case TC_READY: + { + /* Select DRIVE for Y sampling */ - /* Configure XL, XR with drive voltages and disable YU drive. Note - * that this is configuring the DRIVEA and DRIVEB outputs to enable - * the on-board transistor drive logic to energize the touch panel. - */ + /* Configure XL, XR with drive voltages and disable YU drive. Note + * that this is configuring the DRIVEA and DRIVEB outputs to enable + * the on-board transistor drive logic to energize the touch panel. + */ - *((uint32_t *)LCD_TP_PORT_SETRESET) = LCD_SAMPY_BITS; + *((uint32_t *)LCD_TP_PORT_SETRESET) = LCD_SAMPY_BITS; - /* Allow time for the Y DRIVE to settle */ + /* Allow time for the Y DRIVE to settle */ - priv->resamplecount = 0; - priv->sampcount = 0; - priv->value = 0; - priv->state = TC_READY_SETTLE; - delay = TC_SETTLE_TICKS; - } - break; + priv->resamplecount = 0; + priv->sampcount = 0; + priv->value = 0; + priv->state = TC_READY_SETTLE; + delay = TC_SETTLE_TICKS; + } + break; - case TC_READY_SETTLE: - { - /* Start Y sampling */ + case TC_READY_SETTLE: + { + /* Start Y sampling */ - tc_y_sample(); + tc_y_sample(); - /* Allow time for the Y pend down sampling */ + /* Allow time for the Y pend down sampling */ - priv->state = TC_YPENDOWN; - delay = TC_SAMPLE_TICKS; - } - break; + priv->state = TC_YPENDOWN; + delay = TC_SAMPLE_TICKS; + } + break; - /* The Y sampling time has elapsed and the Y value should be ready - * for conversion - */ + /* The Y sampling time has elapsed and the Y value should be ready + * for conversion + */ - case TC_YPENDOWN: - { - /* Convert the Y sample value */ + case TC_YPENDOWN: + { + /* Convert the Y sample value */ - value = tc_adc_read_sample(); + value = tc_adc_read_sample(); - /* A converted value at the minimum would mean that there is no touch - * and that the sampling period is complete. - */ + /* A converted value at the minimum would mean that there is no + * touch and that the sampling period is complete. + */ - if (!tc_valid_sample(value)) - { - priv->state = TC_PENUP; - } - else - { - /* Allow time for touch inputs to stabilize */ + if (!tc_valid_sample(value)) + { + priv->state = TC_PENUP; + } + else + { + /* Allow time for touch inputs to stabilize */ - priv->state = TC_DEBOUNCE; - delay = TC_DEBOUNCE_TICKS; - } - } - break; + priv->state = TC_DEBOUNCE; + delay = TC_DEBOUNCE_TICKS; + } + } + break; - /* The debounce time period has elapsed and we are ready to re-sample - * the touchscreen. - */ + /* The debounce time period has elapsed and we are ready to re-sample + * the touchscreen. + */ - case TC_RESAMPLE: - { - /* Select DRIVE for Y sampling */ + case TC_RESAMPLE: + { + /* Select DRIVE for Y sampling */ - /* Configure XL, XR with drive voltages and disable YU drive. Note - * that this is configuring the DRIVEA and DRIVEB outputs to enable - * the on-board transistor drive logic to energize the touch panel. - */ + /* Configure XL, XR with drive voltages and disable YU drive. Note + * that this is configuring the DRIVEA and DRIVEB outputs to enable + * the on-board transistor drive logic to energize the touch panel. + */ - *((uint32_t *)LCD_TP_PORT_SETRESET) = LCD_SAMPY_BITS; + *((uint32_t *)LCD_TP_PORT_SETRESET) = LCD_SAMPY_BITS; - /* Allow time for the Y DRIVE to settle */ + /* Allow time for the Y DRIVE to settle */ - priv->state = TC_DEBOUNCE; - delay = TC_SETTLE_TICKS; - } - break; + priv->state = TC_DEBOUNCE; + delay = TC_SETTLE_TICKS; + } + break; - case TC_DEBOUNCE: - { - /* (Re-)start Y sampling */ + case TC_DEBOUNCE: + { + /* (Re-)start Y sampling */ - tc_y_sample(); + tc_y_sample(); - /* Allow time for the Y sampling */ + /* Allow time for the Y sampling */ - priv->state = TC_YSAMPLE; - delay = TC_SAMPLE_TICKS; - } - break; + priv->state = TC_YSAMPLE; + delay = TC_SAMPLE_TICKS; + } + break; - /* The Y sampling period has elapsed and we are ready to perform the - * conversion. - */ + /* The Y sampling period has elapsed and we are ready to perform the + * conversion. + */ - case TC_YSAMPLE: /* Allowing time for the Y sampling */ - { - /* Read the Y axis position */ + case TC_YSAMPLE: /* Allowing time for the Y sampling */ + { + /* Read the Y axis position */ - value = tc_adc_read_sample(); + value = tc_adc_read_sample(); - /* A converted value at the minimum would mean that we lost the - * contact before all of the conversions were completed. At - * converted value at the maximum value is probably bad too. - */ + /* A converted value at the minimum would mean that we lost the + * contact before all of the conversions were completed. At + * converted value at the maximum value is probably bad too. + */ - if (!tc_valid_sample(value)) - { + if (!tc_valid_sample(value)) + { #ifdef CONFIG_TOUCHSCREEN_RESAMPLE - priv->state = TC_RESAMPLE; - delay = TC_RESAMPLE_TICKS; + priv->state = TC_RESAMPLE; + delay = TC_RESAMPLE_TICKS; #else - priv->state = TC_PENUP; + priv->state = TC_PENUP; #endif - } - else - { - value = MAX_ADC - value; - priv->value += value; - if (++priv->sampcount < CONFIG_TOUCHSCREEN_AVG_SAMPLES) - { - priv->state = TC_READY_SETTLE; - delay = 1; - break; - } - - priv->newy = value / CONFIG_TOUCHSCREEN_AVG_SAMPLES; - priv->value = 0; - priv->sampcount = 0; - iinfo("Y=%d\n", priv->newy); - - /* Configure YU and YD with drive voltages and disable XR drive. - * Note that this is configuring the DRIVEA and DRIVEB outputs - * to enable the on-board transistor drive logic to energize the - * touch panel. - */ - - *((uint32_t *)LCD_TP_PORT_SETRESET) = LCD_SAMPX_BITS; - - /* Allow time for the X sampling */ - - priv->state = TC_XSETTLE; - delay = TC_SETTLE_TICKS; - } - } - break; - - case TC_XRESAMPLE: /* Perform X resampling */ - { - if (priv->resamplecount-- == 0) - { - priv->state = TC_PENUP; - break; - } - } - - case TC_XSETTLE: /* Allowing time X to settle after changing DRIVE */ - { - /* The X Drive settling time has elaspsed and it's time to start - * the conversion - */ - - /* Start X sampling */ - - tc_x_sample(); - - /* Allow time for the X sampling */ - - priv->state = TC_XSAMPLE; - delay = TC_SAMPLE_TICKS; - } - break; - - case TC_XSAMPLE: /* Allowing time for the X sampling */ - { - /* Read the converted X axis position */ - - value = tc_adc_read_sample(); - - /* A converted value at the minimum would mean that we lost the - * contact before all of the conversions were completed. At - * converted value at the maximum value is probably bad too. - */ - - if (!tc_valid_sample(value)) - { + } + else + { + value = MAX_ADC - value; + priv->value += value; + if (++priv->sampcount < CONFIG_TOUCHSCREEN_AVG_SAMPLES) + { + priv->state = TC_READY_SETTLE; + delay = 1; + break; + } + + priv->newy = value / CONFIG_TOUCHSCREEN_AVG_SAMPLES; + priv->value = 0; + priv->sampcount = 0; + iinfo("Y=%d\n", priv->newy); + + /* Configure YU and YD with drive voltages and disable XR + * drive. Note that this is configuring the DRIVEA and DRIVEB + * outputs to enable the on-board transistor drive logic to + * energize the touch panel. + */ + + *((uint32_t *)LCD_TP_PORT_SETRESET) = LCD_SAMPX_BITS; + + /* Allow time for the X sampling */ + + priv->state = TC_XSETTLE; + delay = TC_SETTLE_TICKS; + } + } + break; + + case TC_XRESAMPLE: /* Perform X resampling */ + { + if (priv->resamplecount-- == 0) + { + priv->state = TC_PENUP; + break; + } + } + + case TC_XSETTLE: /* Allowing time X to settle after changing DRIVE */ + { + /* The X Drive settling time has elaspsed and it's time to start + * the conversion + */ + + /* Start X sampling */ + + tc_x_sample(); + + /* Allow time for the X sampling */ + + priv->state = TC_XSAMPLE; + delay = TC_SAMPLE_TICKS; + } + break; + + case TC_XSAMPLE: /* Allowing time for the X sampling */ + { + /* Read the converted X axis position */ + + value = tc_adc_read_sample(); + + /* A converted value at the minimum would mean that we lost the + * contact before all of the conversions were completed. At + * converted value at the maximum value is probably bad too. + */ + + if (!tc_valid_sample(value)) + { #ifdef CONFIG_TOUCHSCREEN_RESAMPLE - priv->state = TC_XRESAMPLE; - if (priv->resamplecount == 0) - priv->resamplecount = 1; - delay = TC_RESAMPLE_TICKS; + priv->state = TC_XRESAMPLE; + if (priv->resamplecount == 0) + { + priv->resamplecount = 1; + } + + delay = TC_RESAMPLE_TICKS; #else - priv->state = TC_PENUP; + priv->state = TC_PENUP; #endif - } - else - { - /* Calculate the X axis position */ - - priv->value += value; - if (++priv->sampcount < CONFIG_TOUCHSCREEN_AVG_SAMPLES) - { - priv->state = TC_XSETTLE; - delay = 1; - break; - } - - newx = value / CONFIG_TOUCHSCREEN_AVG_SAMPLES; - iinfo("X=%d\n", newx); - - /* Samples are available */ - - priv->state = TC_PENDOWN; - } - } - break; + } + else + { + /* Calculate the X axis position */ + + priv->value += value; + if (++priv->sampcount < CONFIG_TOUCHSCREEN_AVG_SAMPLES) + { + priv->state = TC_XSETTLE; + delay = 1; + break; + } + + newx = value / CONFIG_TOUCHSCREEN_AVG_SAMPLES; + iinfo("X=%d\n", newx); + + /* Samples are available */ + + priv->state = TC_PENDOWN; + } + } + break; } /* Check for terminal conditions.. */ @@ -1417,6 +1420,7 @@ static int tc_poll(struct file *filep, struct pollfd *fds, bool setup) /* This is a request to tear down the poll. */ struct pollfd **slot = (struct pollfd **)fds->priv; + DEBUGASSERT(slot != NULL); /* Remove all memory of the poll setup */ diff --git a/boards/arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c b/boards/arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c index 88a6e9c1f2f..eff17a00c9b 100644 --- a/boards/arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c +++ b/boards/arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c @@ -233,7 +233,7 @@ static int tm4c_mpu60x0_setup(int bus) syslog(LOG_ERR, "ERROR: Failed to allocate mpu60x0 driver\n"); return -ENOMEM; } - else + else { mpu_config->i2c = i2c; mpu_config->addr = 0x68; diff --git a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c index 03dd0fabe1e..53ca39a95c2 100644 --- a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c +++ b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c @@ -627,225 +627,225 @@ static void tc_worker(void *arg) switch (priv->state) { - /* The touchscreen is IDLE and we are ready to begin the next sample */ + /* The touchscreen is IDLE and we are ready to begin the next sample */ - case TC_READY: - { - /* Start Y- sampling */ + case TC_READY: + { + /* Start Y- sampling */ - tc_yminus_sample(); + tc_yminus_sample(); - /* Allow time for the Y- pend down sampling */ + /* Allow time for the Y- pend down sampling */ - priv->state = TC_YMPENDOWN; - delay = TC_SAMPLE_TICKS; - } + priv->state = TC_YMPENDOWN; + delay = TC_SAMPLE_TICKS; + } break; - /* The Y- sampling time has elapsed and the Y- value should be ready - * for conversion - */ + /* The Y- sampling time has elapsed and the Y- value should be ready + * for conversion + */ - case TC_YMPENDOWN: - { - /* Convert the Y- sample value */ + case TC_YMPENDOWN: + { + /* Convert the Y- sample value */ - value = tc_adc_convert(); + value = tc_adc_convert(); - /* A converted value at the minimum would mean that there is no touch - * and that the sampling period is complete. - */ + /* A converted value at the minimum would mean that there is no + * touch and that the sampling period is complete. + */ - if (!tc_valid_sample(value)) - { - priv->state = TC_PENUP; - } - else - { - /* Allow time for touch inputs to stabilize */ + if (!tc_valid_sample(value)) + { + priv->state = TC_PENUP; + } + else + { + /* Allow time for touch inputs to stabilize */ - priv->state = TC_DEBOUNCE; - delay = TC_DEBOUNCE_TICKS; - } - } - break; + priv->state = TC_DEBOUNCE; + delay = TC_DEBOUNCE_TICKS; + } + } + break; - /* The debounce time period has elapsed and we are ready to re-sample - * the touchscreen. - */ + /* The debounce time period has elapsed and we are ready to re-sample + * the touchscreen. + */ - case TC_RESAMPLE: - case TC_DEBOUNCE: - { - /* (Re-)start Y- sampling */ + case TC_RESAMPLE: + case TC_DEBOUNCE: + { + /* (Re-)start Y- sampling */ - tc_yminus_sample(); + tc_yminus_sample(); - /* Allow time for the Y- sampling */ + /* Allow time for the Y- sampling */ - priv->state = TC_YMSAMPLE; - delay = TC_SAMPLE_TICKS; - } - break; + priv->state = TC_YMSAMPLE; + delay = TC_SAMPLE_TICKS; + } + break; - /* The Y- sampling period has elapsed and we are ready to perform the - * conversion. - */ + /* The Y- sampling period has elapsed and we are ready to perform the + * conversion. + */ - case TC_YMSAMPLE: - { - /* Convert and save the Y- sample value */ + case TC_YMSAMPLE: + { + /* Convert and save the Y- sample value */ - value = tc_adc_convert(); + value = tc_adc_convert(); - /* A converted value at the minimum would mean that there is no touch - * and that the sampling period is complete. At converted value at - * the maximum value is probably bad too. - */ + /* A converted value at the minimum would mean that there is no + * touch and that the sampling period is complete. At converted + * value at the maximum value is probably bad too. + */ - if (!tc_valid_sample(value)) - { - priv->state = TC_PENUP; - } - else - { - /* Save the Y- sample and start Y+ sampling */ + if (!tc_valid_sample(value)) + { + priv->state = TC_PENUP; + } + else + { + /* Save the Y- sample and start Y+ sampling */ - priv->value = value; - tc_yplus_sample(); + priv->value = value; + tc_yplus_sample(); - /* Allow time for the Y+ sampling */ + /* Allow time for the Y+ sampling */ - priv->state = TC_YPSAMPLE; - delay = TC_SAMPLE_TICKS; - } - } - break; + priv->state = TC_YPSAMPLE; + delay = TC_SAMPLE_TICKS; + } + } + break; - /* The Y+ sampling period has elapsed and we are ready to perform the - * conversion. - */ + /* The Y+ sampling period has elapsed and we are ready to perform the + * conversion. + */ - case TC_YPSAMPLE: /* Allowing time for the Y+ sampling */ - { - /* Read the Y+ axis position */ + case TC_YPSAMPLE: /* Allowing time for the Y+ sampling */ + { + /* Read the Y+ axis position */ - value = tc_adc_convert(); + value = tc_adc_convert(); - /* A converted value at the minimum would mean that we lost the - * contact before all of the conversions were completed. - * At converted value at the maximum value is probably bad too. - */ + /* A converted value at the minimum would mean that we lost the + * contact before all of the conversions were completed. + * At converted value at the maximum value is probably bad too. + */ - if (!tc_valid_sample(value)) - { + if (!tc_valid_sample(value)) + { #ifdef CONFIG_TOUCHSCREEN_RESAMPLE - priv->state = TC_RESAMPLE; - delay = TC_RESAMPLE_TICKS; + priv->state = TC_RESAMPLE; + delay = TC_RESAMPLE_TICKS; #else - priv->state = TC_PENUP; + priv->state = TC_PENUP; #endif - } - else - { - value = MAX_ADC - value; - priv->newy = (value + priv->value) >> 1; - iinfo("Y-=%d Y+=%d[%d] Y=%d\n", priv->value, - value, MAX_ADC - value, priv->newy); + } + else + { + value = MAX_ADC - value; + priv->newy = (value + priv->value) >> 1; + iinfo("Y-=%d Y+=%d[%d] Y=%d\n", priv->value, + value, MAX_ADC - value, priv->newy); - /* Start X+ sampling */ + /* Start X+ sampling */ - tc_xplus_sample(); + tc_xplus_sample(); - /* Allow time for the X+ sampling */ + /* Allow time for the X+ sampling */ - priv->state = TC_XPSAMPLE; - delay = TC_SAMPLE_TICKS; - } - } - break; + priv->state = TC_XPSAMPLE; + delay = TC_SAMPLE_TICKS; + } + } + break; - /* The X+ sampling period has elapsed and we are ready to perform the - * conversion. - */ + /* The X+ sampling period has elapsed and we are ready to perform the + * conversion. + */ - case TC_XPSAMPLE: - { - /* Convert the X+ sample value */ + case TC_XPSAMPLE: + { + /* Convert the X+ sample value */ - value = tc_adc_convert(); + value = tc_adc_convert(); - /* A converted value at the minimum would mean that we lost the - * contact before all of the conversions were completed. - * At converted value at the maximum value is probably bad too. - */ + /* A converted value at the minimum would mean that we lost the + * contact before all of the conversions were completed. + * At converted value at the maximum value is probably bad too. + */ - if (!tc_valid_sample(value)) - { + if (!tc_valid_sample(value)) + { #ifdef CONFIG_TOUCHSCREEN_RESAMPLE - priv->state = TC_RESAMPLE; - delay = TC_RESAMPLE_TICKS; + priv->state = TC_RESAMPLE; + delay = TC_RESAMPLE_TICKS; #else - priv->state = TC_PENUP; + priv->state = TC_PENUP; #endif - } - else - { - /* Save the X+ sample value */ + } + else + { + /* Save the X+ sample value */ - priv->value = value; + priv->value = value; - /* Start X- sampling */ + /* Start X- sampling */ - tc_xminus_sample(); + tc_xminus_sample(); - /* Allow time for the X- pend down sampling */ + /* Allow time for the X- pend down sampling */ - priv->state = TC_XMSAMPLE; - delay = TC_SAMPLE_TICKS; - } - } - break; + priv->state = TC_XMSAMPLE; + delay = TC_SAMPLE_TICKS; + } + } + break; - /* The X+ sampling period has elapsed and we are ready to perform the - * conversion. - */ + /* The X+ sampling period has elapsed and we are ready to perform the + * conversion. + */ - case TC_XMSAMPLE: /* Allowing time for the X- sampling */ - { - /* Read the converted X- axis position */ + case TC_XMSAMPLE: /* Allowing time for the X- sampling */ + { + /* Read the converted X- axis position */ - value = tc_adc_convert(); + value = tc_adc_convert(); - /* A converted value at the minimum would mean that we lost the - * contact before all of the conversions were completed. - * At converted value at the maximum value is probably bad too. - */ + /* A converted value at the minimum would mean that we lost the + * contact before all of the conversions were completed. + * At converted value at the maximum value is probably bad too. + */ - if (!tc_valid_sample(value)) - { + if (!tc_valid_sample(value)) + { #ifdef CONFIG_TOUCHSCREEN_RESAMPLE - priv->state = TC_RESAMPLE; - delay = TC_RESAMPLE_TICKS; + priv->state = TC_RESAMPLE; + delay = TC_RESAMPLE_TICKS; #else - priv->state = TC_PENUP; + priv->state = TC_PENUP; #endif - } - else - { - /* Calculate the X- axis position */ + } + else + { + /* Calculate the X- axis position */ - value = MAX_ADC - value; - newx = (value + priv->value) >> 1; - iinfo("X+=%d X-=%d[%d] X=%d\n", priv->value, - value, MAX_ADC - value, newx); + value = MAX_ADC - value; + newx = (value + priv->value) >> 1; + iinfo("X+=%d X-=%d[%d] X=%d\n", priv->value, + value, MAX_ADC - value, newx); - /* Samples are available */ + /* Samples are available */ - priv->state = TC_PENDOWN; - } - } - break; + priv->state = TC_PENDOWN; + } + } + break; } /* Check for terminal conditions.. */ diff --git a/boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c b/boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c index bc7ce418a9a..6f889a5e178 100644 --- a/boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c +++ b/boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c @@ -99,24 +99,24 @@ int bm3803_am29lv_initialize(int minor) } #if defined(CONFIG_XX3803_FLASH_PARA) - /* Register the MTD as the System Parameter device */ - - ret = mtdpara_register(mtd); - if (ret < 0) - { - _err("ERROR: Failed to register the /dev/para: %d\n", errno); - return ret; - } + /* Register the MTD as the System Parameter device */ + + ret = mtdpara_register(mtd); + if (ret < 0) + { + _err("ERROR: Failed to register the /dev/para: %d\n", errno); + return ret; + } #endif #ifdef CONFIG_MTD_PARTITION - mtd = mtd_partition(mtd, 48, 79); - if (!mtd) - { - _err("ERROR: mtd_partition failed\n"); - return ret; - } + mtd = mtd_partition(mtd, 48, 79); + if (!mtd) + { + _err("ERROR: mtd_partition failed\n"); + return ret; + } #endif #ifdef CONFIG_FS_LITTLEFS @@ -150,6 +150,7 @@ int bm3803_am29lv_initialize(int minor) #if defined(CONFIG_RAMMTD) && defined(CONFIG_XX3803_RAMMTD) uint8_t *start = kmm_malloc(CONFIG_XX3803_RAMMTD_SIZE * 1024); + mtd = rammtd_initialize(start, CONFIG_XX3803_RAMMTD_SIZE * 1024); mtd->ioctl(mtd, MTDIOC_BULKERASE, 0); #endif /* CONFIG_RAMMTD && CONFIG_XX3803_RAMMTD */ diff --git a/boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c b/boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c index dd132c53866..d04d144a21a 100644 --- a/boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c +++ b/boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c @@ -105,6 +105,7 @@ int bm3823_am29lv_initialize(int minor) #if defined(CONFIG_RAMMTD) && defined(CONFIG_XX3823_RAMMTD) uint8_t *start = kmm_malloc(CONFIG_XX3823_RAMMTD_SIZE * 1024); + mtd = rammtd_initialize(start, CONFIG_XX3823_RAMMTD_SIZE * 1024); mtd->ioctl(mtd, MTDIOC_BULKERASE, 0); diff --git a/drivers/analog/ads1115.c b/drivers/analog/ads1115.c index 14e21107193..9577cfdd752 100644 --- a/drivers/analog/ads1115.c +++ b/drivers/analog/ads1115.c @@ -475,6 +475,7 @@ static int ads1115_bind(FAR struct adc_dev_s *dev, FAR const struct adc_callback_s *callback) { FAR struct ads1115_dev_s *priv = (FAR struct ads1115_dev_s *)dev->ad_priv; + DEBUGASSERT(priv != NULL); priv->cb = callback; return 0; @@ -492,6 +493,7 @@ static int ads1115_bind(FAR struct adc_dev_s *dev, static void ads1115_reset(FAR struct adc_dev_s *dev) { FAR struct ads1115_dev_s *priv = (FAR struct ads1115_dev_s *)dev->ad_priv; + cmdbyte_init(priv); } @@ -508,6 +510,7 @@ static void ads1115_reset(FAR struct adc_dev_s *dev) static int ads1115_setup(FAR struct adc_dev_s *dev) { FAR struct ads1115_dev_s *priv = (FAR struct ads1115_dev_s *)dev->ad_priv; + return ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, htobe16(priv->cmdbyte)); } @@ -527,6 +530,7 @@ static int ads1115_setup(FAR struct adc_dev_s *dev) static void ads1115_shutdown(FAR struct adc_dev_s *dev) { FAR struct ads1115_dev_s *priv = (FAR struct ads1115_dev_s *)dev->ad_priv; + priv->cmdbyte |= ADS1115_MODE_MASK; ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, htobe16(priv->cmdbyte)); @@ -561,189 +565,190 @@ static int ads1115_ioctl(FAR struct adc_dev_s *dev, int cmd, switch (cmd) { - case ANIOC_TRIGGER: - { - struct adc_msg_s msg; - - /* Read all channels in sequence */ - - for (uint8_t i = 0; i < ADS1115_NUM_CHANNELS; i++) - { - msg.am_channel = i; - ret = ads1115_readchannel(priv, &msg); - if (ret) - { - aerr("Error reading channel %d with error %d \n", i, ret); - break; - } - - priv->cb->au_receive(dev, i, msg.am_data); - } - } - break; - - case ANIOC_ADS1115_SET_PGA: - { - DEBUGASSERT(arg >= ADS1115_PGA1 && arg <= ADS1115_PGA8); - - priv->cmdbyte &= ~ADS1115_PGA_MASK; - priv->cmdbyte |= arg << ADS1115_PGA_SHIFT; - ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, - htobe16(priv->cmdbyte)); - } - break; - - case ANIOC_ADS1115_SET_MODE: - { - if (arg == ADS1115_MODE1) - { - priv->cmdbyte &= ~ADS1115_MODE_MASK; - } - else if (arg == ADS1115_MODE2) - { - priv->cmdbyte |= ADS1115_MODE_MASK; - } - else - { - ret = -EINVAL; - break; - } - - ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, - htobe16(priv->cmdbyte)); - } - break; - - case ANIOC_ADS1115_SET_DR: - { - DEBUGASSERT(arg >= ADS1115_DR1 && arg <= ADS1115_DR8); - priv->cmdbyte &= ~ADS1115_DR_MASK; - priv->cmdbyte |= arg << ADS1115_DR_SHIFT; - - ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, - htobe16(priv->cmdbyte)); - } - break; - - case ANIOC_ADS1115_SET_COMP_POL: - { - if (arg == ADS1115_COMP_POL1) - { - priv->cmdbyte &= ~ADS1115_COMP_POL_MASK; - } - else if (arg == ADS1115_COMP_POL2) - { - priv->cmdbyte |= ADS1115_COMP_POL_MASK; - } - else - { - ret = -EINVAL; - break; - } - - ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, - htobe16(priv->cmdbyte)); - } - break; - - case ANIOC_ADS1115_SET_COMP_MODE: - { - if (arg == ADS1115_COMP_MODE1) - { - priv->cmdbyte &= ~ADS1115_COMP_MODE_MASK; - } - else if (arg == ADS1115_COMP_MODE2) - { - priv->cmdbyte |= ADS1115_COMP_MODE_MASK; - } - else - { - ret = -EINVAL; - break; - } - - ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, - htobe16(priv->cmdbyte)); - } - break; - - case ANIOC_ADS1115_SET_COMP_LAT: - { - if (arg == ADS1115_COMP_LAT1) - { - priv->cmdbyte &= ~ADS1115_COMP_LAT_MASK; - } - else if (arg == ADS1115_COMP_LAT2) - { - priv->cmdbyte |= ADS1115_COMP_LAT_MASK; - } - else - { - ret = -EINVAL; - break; - } - - ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, - htobe16(priv->cmdbyte)); - } - break; - - case ANIOC_ADS1115_SET_COMP_QUEUE: - { - DEBUGASSERT(arg >= ADS1115_COMP_QUEUE1 && - arg <= ADS1115_COMP_QUEUE4); - - priv->cmdbyte &= ~ADS1115_COMP_QUE_MASK; - priv->cmdbyte |= arg << ADS1115_COMP_QUE_SHIFT; - - ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, - htobe16(priv->cmdbyte)); - } - break; - - case ANIOC_ADS1115_READ_CHANNEL: - { - ret = ads1115_readchannel(priv, (FAR struct adc_msg_s *)arg); - } - break; - - case ANIOC_ADS1115_TRIGGER_CONVERSION: - { - ret = ads1115_trigger_conversion(priv, (FAR struct adc_msg_s *)arg); - } - break; - - case ANIOC_ADS1115_READ_CHANNEL_NO_CONVERSION: - { - ret = ads1115_read_conversion(priv, (FAR struct adc_msg_s *)arg); - } - break; - - case ANIOC_ADS1115_SET_HI_THRESH: - { - DEBUGASSERT(arg >= 0 && arg <= UINT16_MAX); - ret = ads1115_write_register(priv, ADS1115_HI_THRESH_REGISTER, - htobe16(arg)); - } - break; - - case ANIOC_ADS1115_SET_LO_THRESH: - { - DEBUGASSERT(arg >= 0 && arg <= UINT16_MAX); - ret = ads1115_write_register(priv, ADS1115_LO_THRESH_REGISTER, - htobe16(arg)); - } - break; - - case ANIOC_GET_NCHANNELS: - { - ret = ADS1115_NUM_CHANNELS; - } - break; - - default: - ret = -ENOTTY; - break; + case ANIOC_TRIGGER: + { + struct adc_msg_s msg; + + /* Read all channels in sequence */ + + for (uint8_t i = 0; i < ADS1115_NUM_CHANNELS; i++) + { + msg.am_channel = i; + ret = ads1115_readchannel(priv, &msg); + if (ret) + { + aerr("Error reading channel %d with error %d \n", i, ret); + break; + } + + priv->cb->au_receive(dev, i, msg.am_data); + } + } + break; + + case ANIOC_ADS1115_SET_PGA: + { + DEBUGASSERT(arg >= ADS1115_PGA1 && arg <= ADS1115_PGA8); + + priv->cmdbyte &= ~ADS1115_PGA_MASK; + priv->cmdbyte |= arg << ADS1115_PGA_SHIFT; + ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, + htobe16(priv->cmdbyte)); + } + break; + + case ANIOC_ADS1115_SET_MODE: + { + if (arg == ADS1115_MODE1) + { + priv->cmdbyte &= ~ADS1115_MODE_MASK; + } + else if (arg == ADS1115_MODE2) + { + priv->cmdbyte |= ADS1115_MODE_MASK; + } + else + { + ret = -EINVAL; + break; + } + + ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, + htobe16(priv->cmdbyte)); + } + break; + + case ANIOC_ADS1115_SET_DR: + { + DEBUGASSERT(arg >= ADS1115_DR1 && arg <= ADS1115_DR8); + priv->cmdbyte &= ~ADS1115_DR_MASK; + priv->cmdbyte |= arg << ADS1115_DR_SHIFT; + + ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, + htobe16(priv->cmdbyte)); + } + break; + + case ANIOC_ADS1115_SET_COMP_POL: + { + if (arg == ADS1115_COMP_POL1) + { + priv->cmdbyte &= ~ADS1115_COMP_POL_MASK; + } + else if (arg == ADS1115_COMP_POL2) + { + priv->cmdbyte |= ADS1115_COMP_POL_MASK; + } + else + { + ret = -EINVAL; + break; + } + + ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, + htobe16(priv->cmdbyte)); + } + break; + + case ANIOC_ADS1115_SET_COMP_MODE: + { + if (arg == ADS1115_COMP_MODE1) + { + priv->cmdbyte &= ~ADS1115_COMP_MODE_MASK; + } + else if (arg == ADS1115_COMP_MODE2) + { + priv->cmdbyte |= ADS1115_COMP_MODE_MASK; + } + else + { + ret = -EINVAL; + break; + } + + ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, + htobe16(priv->cmdbyte)); + } + break; + + case ANIOC_ADS1115_SET_COMP_LAT: + { + if (arg == ADS1115_COMP_LAT1) + { + priv->cmdbyte &= ~ADS1115_COMP_LAT_MASK; + } + else if (arg == ADS1115_COMP_LAT2) + { + priv->cmdbyte |= ADS1115_COMP_LAT_MASK; + } + else + { + ret = -EINVAL; + break; + } + + ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, + htobe16(priv->cmdbyte)); + } + break; + + case ANIOC_ADS1115_SET_COMP_QUEUE: + { + DEBUGASSERT(arg >= ADS1115_COMP_QUEUE1 && + arg <= ADS1115_COMP_QUEUE4); + + priv->cmdbyte &= ~ADS1115_COMP_QUE_MASK; + priv->cmdbyte |= arg << ADS1115_COMP_QUE_SHIFT; + + ret = ads1115_write_register(priv, ADS1115_CONFIG_REGISTER, + htobe16(priv->cmdbyte)); + } + break; + + case ANIOC_ADS1115_READ_CHANNEL: + { + ret = ads1115_readchannel(priv, (FAR struct adc_msg_s *)arg); + } + break; + + case ANIOC_ADS1115_TRIGGER_CONVERSION: + { + ret = ads1115_trigger_conversion(priv, + (FAR struct adc_msg_s *)arg); + } + break; + + case ANIOC_ADS1115_READ_CHANNEL_NO_CONVERSION: + { + ret = ads1115_read_conversion(priv, (FAR struct adc_msg_s *)arg); + } + break; + + case ANIOC_ADS1115_SET_HI_THRESH: + { + DEBUGASSERT(arg >= 0 && arg <= UINT16_MAX); + ret = ads1115_write_register(priv, ADS1115_HI_THRESH_REGISTER, + htobe16(arg)); + } + break; + + case ANIOC_ADS1115_SET_LO_THRESH: + { + DEBUGASSERT(arg >= 0 && arg <= UINT16_MAX); + ret = ads1115_write_register(priv, ADS1115_LO_THRESH_REGISTER, + htobe16(arg)); + } + break; + + case ANIOC_GET_NCHANNELS: + { + ret = ADS1115_NUM_CHANNELS; + } + break; + + default: + ret = -ENOTTY; + break; } return ret; diff --git a/drivers/analog/ads7046.c b/drivers/analog/ads7046.c index 6b992e73409..d79a193c1e0 100644 --- a/drivers/analog/ads7046.c +++ b/drivers/analog/ads7046.c @@ -192,6 +192,7 @@ static int ads7046_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case ANIOC_ADS7046_READ: { FAR uint16_t *data = (FAR uint16_t *)((uintptr_t)arg); + ads7046_read_conversion_result(priv, data, false); break; } @@ -203,6 +204,7 @@ static int ads7046_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case ANIOC_ADS7046_READ_FASTUNSAFE: { FAR uint16_t *data = (FAR uint16_t *)((uintptr_t)arg); + ads7046_read_conversion_result(priv, data, true); break; } @@ -258,6 +260,7 @@ int ads7046_register(FAR const char *devpath, FAR struct spi_dev_s *spi, /* Initialize the ADS7046 device structure */ struct ads7046_dev_s *priv = kmm_malloc(sizeof(struct ads7046_dev_s)); + if (priv == NULL) { aerr("ERROR: Failed to allocate instance %s (%d)\n", strerror(errno), @@ -271,6 +274,7 @@ int ads7046_register(FAR const char *devpath, FAR struct spi_dev_s *spi, /* Register the character driver */ int ret = register_driver(devpath, &ads7046_fops, 0600, priv); + if (ret < 0) { aerr("ERROR: Failed to register driver: %s (%d)\n", strerror(-ret), diff --git a/drivers/analog/mcp47x6.c b/drivers/analog/mcp47x6.c index c96648de5df..f65f23eb47f 100644 --- a/drivers/analog/mcp47x6.c +++ b/drivers/analog/mcp47x6.c @@ -303,6 +303,7 @@ static int mcp47x6_send(FAR struct dac_dev_s *dev, FAR struct dac_msg_s *msg) uint8_t buffer[BUFFER_SIZE]; uint32_t data; + data = msg->am_data & MCP47X6_DATA_MASK; data <<= MCP47X6_DATA_SHIFT; buffer[0] = (uint8_t)(data >> 8) | MCP47X6_COMMAND_WRITE_DAC; @@ -365,7 +366,7 @@ static int mcp47x6_ioctl(FAR struct dac_dev_s *dev, int cmd, ret = -EINVAL; break; } - } + } break; case ANIOC_MCP47X6_DAC_SET_REFERENCE: @@ -386,7 +387,7 @@ static int mcp47x6_ioctl(FAR struct dac_dev_s *dev, int cmd, } break; - /* Command was not recognized */ + /* Command was not recognized */ default: aerr("MCP47X6 ERROR: Unrecognized cmd: %d", cmd); @@ -397,6 +398,7 @@ static int mcp47x6_ioctl(FAR struct dac_dev_s *dev, int cmd, if (command_prepared) { uint8_t raw_cmd = MCP47X6_COMMAND_WRITE_CONFIG | priv->cmd; + ret = mcp47x6_i2c_write(priv, &raw_cmd, sizeof(raw_cmd)); } diff --git a/drivers/leds/ktd2052.c b/drivers/leds/ktd2052.c index 7edb65478cd..298c9568248 100644 --- a/drivers/leds/ktd2052.c +++ b/drivers/leds/ktd2052.c @@ -483,6 +483,7 @@ static int ktd2052_open(FAR struct file *filep) uint8_t reg_val; int ret = ktd2052_read_reg(priv, KTD2052_ID_REG, ®_val); + if (ret < 0) { return ret; @@ -611,6 +612,7 @@ static int ktd2052_ioctl(FAR struct file *filep, int cmd, unsigned long arg) */ FAR uint8_t *mrgb = (FAR uint8_t *)arg; + if (mrgb == NULL) { ret = -EINVAL; @@ -626,6 +628,7 @@ static int ktd2052_ioctl(FAR struct file *filep, int cmd, unsigned long arg) /* Set operating mode */ FAR struct ktd2052_mode_s *mode = (FAR struct ktd2052_mode_s *)arg; + if (mode == NULL) { ret = -EINVAL; @@ -643,6 +646,7 @@ static int ktd2052_ioctl(FAR struct file *filep, int cmd, unsigned long arg) FAR struct ktd2052_pattern_s *pattern = (FAR struct ktd2052_pattern_s *)arg; + if (pattern == NULL) { ret = -EINVAL; @@ -662,6 +666,7 @@ static int ktd2052_ioctl(FAR struct file *filep, int cmd, unsigned long arg) FAR struct ktd2052_slots_s *slots = (FAR struct ktd2052_slots_s *)arg; + if (slots == NULL) { ret = -EINVAL; @@ -677,6 +682,7 @@ static int ktd2052_ioctl(FAR struct file *filep, int cmd, unsigned long arg) /* Get monitor register status */ FAR uint8_t *status = (FAR uint8_t *)arg; + if (status == NULL) { ret = -EINVAL; @@ -692,6 +698,7 @@ static int ktd2052_ioctl(FAR struct file *filep, int cmd, unsigned long arg) /* Update watchdog register */ uint8_t wd = (uint8_t)arg; + ret = ktd2052_write_watchdog(priv, wd); } break; diff --git a/drivers/mtd/mtd_cfi.c b/drivers/mtd/mtd_cfi.c index dea4a3c1d27..ff04913fd81 100644 --- a/drivers/mtd/mtd_cfi.c +++ b/drivers/mtd/mtd_cfi.c @@ -231,6 +231,7 @@ static int cfi_mtd_ioctl(FAR struct mtd_dev_s *dev, int cmd, case MTDIOC_ERASESECTORS: { FAR struct mtd_erase_s *erase = (FAR struct mtd_erase_s *)arg; + ret = cfi_mtd_erase(dev, erase->startblock, erase->nblocks); } break; @@ -238,6 +239,7 @@ static int cfi_mtd_ioctl(FAR struct mtd_dev_s *dev, int cmd, case MTDIOC_ERASESTATE: { FAR uint8_t *result = (FAR uint8_t *)arg; + *result = 0xff; break; } diff --git a/drivers/net/oa_tc6/oa_tc6.c b/drivers/net/oa_tc6/oa_tc6.c index 05f269a89cf..d7337c33586 100644 --- a/drivers/net/oa_tc6/oa_tc6.c +++ b/drivers/net/oa_tc6/oa_tc6.c @@ -1082,19 +1082,19 @@ static int oa_tc6_init_by_id(FAR struct spi_dev_s *spi, { #ifdef CONFIG_NET_OA_TC6_NCV7410 case OA_TC6_NCV7410_PHYID: - ninfo("Info: Detected NCV7410 or NCN26010\n"); - return ncv7410_initialize(spi, config); + ninfo("Info: Detected NCV7410 or NCN26010\n"); + return ncv7410_initialize(spi, config); #endif #ifdef CONFIG_NET_OA_TC6_LAN865X case OA_TC6_LAN865X_PHYID: - ninfo("Info: Detected LAN865x\n"); - return lan865x_initialize(spi, config); + ninfo("Info: Detected LAN865x\n"); + return lan865x_initialize(spi, config); #endif default: - nerr("Error: Unknown PHYID 0x%08lX. " - "Is the support enabled in Kconfig? " - "Does the revision match?\n", phyid); - return -EINVAL; + nerr("Error: Unknown PHYID 0x%08lX. " + "Is the support enabled in Kconfig? " + "Does the revision match?\n", phyid); + return -EINVAL; } } @@ -1452,29 +1452,29 @@ static int oa_tc6_get_mmd_base(uint8_t mmd, switch (mmd) { case 1: - *mms = OA_TC6_MMD_1_BASE_MMS; - *addr = OA_TC6_MMD_1_BASE_ADDR; - return OK; + *mms = OA_TC6_MMD_1_BASE_MMS; + *addr = OA_TC6_MMD_1_BASE_ADDR; + return OK; case 3: - *mms = OA_TC6_MMD_3_BASE_MMS; - *addr = OA_TC6_MMD_3_BASE_ADDR; - return OK; + *mms = OA_TC6_MMD_3_BASE_MMS; + *addr = OA_TC6_MMD_3_BASE_ADDR; + return OK; case 7: - *mms = OA_TC6_MMD_7_BASE_MMS; - *addr = OA_TC6_MMD_7_BASE_ADDR; - return OK; + *mms = OA_TC6_MMD_7_BASE_MMS; + *addr = OA_TC6_MMD_7_BASE_ADDR; + return OK; case 13: - *mms = OA_TC6_MMD_13_BASE_MMS; - *addr = OA_TC6_MMD_13_BASE_ADDR; - return OK; + *mms = OA_TC6_MMD_13_BASE_MMS; + *addr = OA_TC6_MMD_13_BASE_ADDR; + return OK; case 29: - *mms = OA_TC6_MMD_29_BASE_MMS; - *addr = OA_TC6_MMD_29_BASE_ADDR; - return OK; + *mms = OA_TC6_MMD_29_BASE_MMS; + *addr = OA_TC6_MMD_29_BASE_ADDR; + return OK; case 31: - *mms = OA_TC6_MMD_31_BASE_MMS; - *addr = OA_TC6_MMD_31_BASE_ADDR; - return OK; + *mms = OA_TC6_MMD_31_BASE_MMS; + *addr = OA_TC6_MMD_31_BASE_ADDR; + return OK; } return ERROR; @@ -1503,6 +1503,7 @@ static int oa_tc6_ifup(FAR struct netdev_lowerhalf_s *dev) FAR struct oa_tc6_driver_s *priv = (FAR struct oa_tc6_driver_s *)dev; int err = nxmutex_lock(&priv->lock); + if (err) { nerr("Error: Failed to acquire lock\n"); @@ -1588,6 +1589,7 @@ static int oa_tc6_ifdown(FAR struct netdev_lowerhalf_s *dev) FAR struct oa_tc6_driver_s *priv = (FAR struct oa_tc6_driver_s *)dev; int err = nxmutex_lock(&priv->lock); + if (err) { nerr("Error: Failed to acquire lock\n"); @@ -1651,6 +1653,7 @@ static int oa_tc6_transmit(FAR struct netdev_lowerhalf_s *dev, FAR struct oa_tc6_driver_s *priv = (FAR struct oa_tc6_driver_s *)dev; int err = nxmutex_lock(&priv->lock); + if (err) { nerr("Error: Failed to acquire lock\n"); @@ -1890,6 +1893,7 @@ int oa_tc6_write_reg(FAR struct oa_tc6_driver_s *priv, | (mms << OA_TC6_MMS_POS) | (addr << OA_TC6_ADDR_POS); int parity = oa_tc6_get_parity(header); + header |= parity ? 0 : OA_TC6_P_MASK; /* Make header odd parity */ /* Convert to big endian */ diff --git a/drivers/rpmsg/rpmsg_virtio_ivshmem.c b/drivers/rpmsg/rpmsg_virtio_ivshmem.c index 810431dc01d..21183eb6962 100644 --- a/drivers/rpmsg/rpmsg_virtio_ivshmem.c +++ b/drivers/rpmsg/rpmsg_virtio_ivshmem.c @@ -120,6 +120,7 @@ rpmsg_virtio_ivshmem_get_cpuname(FAR struct rpmsg_virtio_lite_s *dev) { FAR struct rpmsg_virtio_ivshmem_dev_s *priv = (FAR struct rpmsg_virtio_ivshmem_dev_s *)dev; + return priv->cpuname; } @@ -182,6 +183,7 @@ rpmsg_virtio_ivshmem_is_master(FAR struct rpmsg_virtio_lite_s *dev) { FAR struct rpmsg_virtio_ivshmem_dev_s *priv = (FAR struct rpmsg_virtio_ivshmem_dev_s *)dev; + return priv->master; } @@ -346,6 +348,7 @@ int pci_register_rpmsg_virtio_ivshmem_driver(void) FAR struct rpmsg_virtio_ivshmem_dev_s * priv = kmm_zalloc(sizeof(*priv)); + if (priv == NULL) { return -ENOMEM; diff --git a/drivers/rptun/rptun_bmp.c b/drivers/rptun/rptun_bmp.c index ad1087f09be..f7b3394cb87 100644 --- a/drivers/rptun/rptun_bmp.c +++ b/drivers/rptun/rptun_bmp.c @@ -89,6 +89,7 @@ static const struct rptun_ops_s g_rptun_bmp_ops = static FAR const char *rptun_bmp_get_cpuname(FAR struct rptun_dev_s *dev) { FAR struct rptun_bmp_dev_s *priv = (FAR struct rptun_bmp_dev_s *)dev; + return priv->cpuname; } @@ -96,6 +97,7 @@ static FAR struct resource_table * rptun_bmp_get_resource(FAR struct rptun_dev_s *dev) { FAR struct rptun_bmp_dev_s *priv = (FAR struct rptun_bmp_dev_s *)dev; + return &priv->rsc->rsc_tbl_hdr; } @@ -107,6 +109,7 @@ static bool rptun_bmp_is_autostart(FAR struct rptun_dev_s *dev) static bool rptun_bmp_is_master(FAR struct rptun_dev_s *dev) { FAR struct rptun_bmp_dev_s *priv = (FAR struct rptun_bmp_dev_s *)dev; + return priv->master; } diff --git a/drivers/video/goldfish_camera.c b/drivers/video/goldfish_camera.c index a422da6bf14..0354bcad599 100644 --- a/drivers/video/goldfish_camera.c +++ b/drivers/video/goldfish_camera.c @@ -173,6 +173,7 @@ static int goldfish_camera_read_fully(FAR struct file *file, while (size > 0) { ssize_t n = file_read(file, p, size); + if (n < 0) { return n; @@ -194,6 +195,7 @@ static int goldfish_camera_write_fully(FAR struct file *file, while (size > 0) { ssize_t n = file_write(file, p, size); + if (n < 0) { return n; @@ -536,6 +538,7 @@ goldfish_camera_get_driver_name(FAR struct imgsensor_s *sensor) FAR goldfish_camera_priv_t *priv = container_of(sensor, goldfish_camera_priv_t, sensor); + return priv->info.name; } diff --git a/drivers/wireless/bluetooth/bt_uart.c b/drivers/wireless/bluetooth/bt_uart.c index 2d90a6c0494..e761625b8e2 100644 --- a/drivers/wireless/bluetooth/bt_uart.c +++ b/drivers/wireless/bluetooth/bt_uart.c @@ -125,48 +125,48 @@ static void btuart_rxwork(FAR void *arg) switch (upper->rxbuf[0]) { - case H4_EVT: - if (upper->rxlen < H4_HEADER_SIZE + - sizeof(struct bt_hci_evt_hdr_s)) - { - wlwarn("WARNING: Incomplete HCI event header\n"); - return; - } - - type = BT_EVT; - pktlen = H4_HEADER_SIZE + - sizeof(struct bt_hci_evt_hdr_s) + hdr->evt.len; - break; - - case H4_ACL: - if (upper->rxlen < H4_HEADER_SIZE + - sizeof(struct bt_hci_acl_hdr_s)) - { - wlwarn("WARNING: Incomplete HCI ACL header\n"); - return; - } - - type = BT_ACL_IN; - pktlen = H4_HEADER_SIZE + - sizeof(struct bt_hci_acl_hdr_s) + hdr->acl.len; - break; - - case H4_ISO: - if (upper->rxlen < H4_HEADER_SIZE + - sizeof(struct bt_hci_iso_hdr_s)) - { - wlwarn("WARNING: Incomplete HCI ISO header\n"); - return; - } - - type = BT_ISO_IN; - pktlen = H4_HEADER_SIZE + - sizeof(struct bt_hci_iso_hdr_s) + hdr->iso.len; - break; - - default: - wlerr("ERROR: Unknown H4 type %u\n", upper->rxbuf[0]); - return; + case H4_EVT: + if (upper->rxlen < H4_HEADER_SIZE + + sizeof(struct bt_hci_evt_hdr_s)) + { + wlwarn("WARNING: Incomplete HCI event header\n"); + return; + } + + type = BT_EVT; + pktlen = H4_HEADER_SIZE + + sizeof(struct bt_hci_evt_hdr_s) + hdr->evt.len; + break; + + case H4_ACL: + if (upper->rxlen < H4_HEADER_SIZE + + sizeof(struct bt_hci_acl_hdr_s)) + { + wlwarn("WARNING: Incomplete HCI ACL header\n"); + return; + } + + type = BT_ACL_IN; + pktlen = H4_HEADER_SIZE + + sizeof(struct bt_hci_acl_hdr_s) + hdr->acl.len; + break; + + case H4_ISO: + if (upper->rxlen < H4_HEADER_SIZE + + sizeof(struct bt_hci_iso_hdr_s)) + { + wlwarn("WARNING: Incomplete HCI ISO header\n"); + return; + } + + type = BT_ISO_IN; + pktlen = H4_HEADER_SIZE + + sizeof(struct bt_hci_iso_hdr_s) + hdr->iso.len; + break; + + default: + wlerr("ERROR: Unknown H4 type %u\n", upper->rxbuf[0]); + return; } if (upper->rxlen < pktlen) @@ -196,6 +196,7 @@ static void btuart_rxcallback(FAR const struct btuart_lowerhalf_s *lower, upper = (FAR struct btuart_upperhalf_s *)arg; int ret = work_queue(HPWORK, &upper->work, btuart_rxwork, arg, 0); + if (ret < 0) { wlerr("ERROR: work_queue failed: %d\n", ret); diff --git a/drivers/wireless/gs2200m.c b/drivers/wireless/gs2200m.c index 1e45f31768f..afa922f6182 100644 --- a/drivers/wireless/gs2200m.c +++ b/drivers/wireless/gs2200m.c @@ -1067,18 +1067,18 @@ static void _parse_pkt_in_s0(FAR struct pkt_ctx_s *pkt_ctx, { switch (*(pkt_ctx->ptr)) { - case ASCII_CR: - case ASCII_LF: - break; + case ASCII_CR: + case ASCII_LF: + break; - case ASCII_ESC: - pkt_ctx->state = PKT_ESC_START; - break; + case ASCII_ESC: + pkt_ctx->state = PKT_ESC_START; + break; - default: - pkt_ctx->head = pkt_ctx->ptr; - pkt_ctx->state = PKT_EVENT; - break; + default: + pkt_ctx->head = pkt_ctx->ptr; + pkt_ctx->state = PKT_EVENT; + break; } } @@ -1330,29 +1330,29 @@ static enum pkt_type_e _parse_pkt(FAR uint8_t *p, uint16_t len, { switch (pkt_ctx.state) { - case PKT_START: - _parse_pkt_in_s0(&pkt_ctx, pkt_dat); - break; + case PKT_START: + _parse_pkt_in_s0(&pkt_ctx, pkt_dat); + break; - case PKT_EVENT: - _parse_pkt_in_s1(&pkt_ctx, pkt_dat); - break; + case PKT_EVENT: + _parse_pkt_in_s1(&pkt_ctx, pkt_dat); + break; - case PKT_ESC_START: - _parse_pkt_in_s2(&pkt_ctx, pkt_dat); - break; + case PKT_ESC_START: + _parse_pkt_in_s2(&pkt_ctx, pkt_dat); + break; - case PKT_BULK_DATA_TCP: - _parse_pkt_in_s3(&pkt_ctx, pkt_dat); - break; + case PKT_BULK_DATA_TCP: + _parse_pkt_in_s3(&pkt_ctx, pkt_dat); + break; - case PKT_BULK_DATA_UDP: - _parse_pkt_in_s4(&pkt_ctx, pkt_dat); - break; + case PKT_BULK_DATA_UDP: + _parse_pkt_in_s4(&pkt_ctx, pkt_dat); + break; - default: - PANIC(); - break; + default: + PANIC(); + break; } } @@ -2209,6 +2209,7 @@ static enum pkt_type_e gs2200m_get_cstatus(FAR struct gs2200m_dev_s *dev, int p[2]; char type[8]; char mode[8]; + memset(type, 0, sizeof(type)); memset(mode, 0, sizeof(mode)); n = sscanf(pkt_dat.msg[i], "%c %7s %6s %d %d %d.%d.%d.%d", @@ -2233,6 +2234,7 @@ static enum pkt_type_e gs2200m_get_cstatus(FAR struct gs2200m_dev_s *dev, else { char addr[20]; + msg->addr.sin_port = HTONS(p[1]); snprintf(addr, sizeof(addr), "%d.%d.%d.%d", a[0], a[1], a[2], a[3]); @@ -2879,7 +2881,7 @@ static int gs2200m_ioctl_ifreq(FAR struct gs2200m_dev_s *dev, ); break; - case SIOCSIFADDR: + case SIOCSIFADDR: memcpy(&dev->net_dev.d_ipaddr, &inaddr->sin_addr, sizeof(inaddr->sin_addr) ); @@ -2911,6 +2913,7 @@ static int gs2200m_ioctl_ifreq(FAR struct gs2200m_dev_s *dev, if (false == getreq && OK == ret) { char inetaddr[INET_ADDRSTRLEN]; + memcpy(&in[0], &dev->net_dev.d_ipaddr, sizeof(in[0])); memcpy(&in[1], &dev->net_dev.d_netmask, sizeof(in[1])); memcpy(&in[2], &dev->net_dev.d_draddr, sizeof(in[2])); diff --git a/libs/libbuiltin/libgcc/gcov.c b/libs/libbuiltin/libgcc/gcov.c index 134b6aa79ac..18c309cce40 100644 --- a/libs/libbuiltin/libgcc/gcov.c +++ b/libs/libbuiltin/libgcc/gcov.c @@ -507,6 +507,7 @@ void __gcov_dump(void) { struct lib_rawoutstream_s stream; int fd = _NX_OPEN(prefix, O_WRONLY | O_CREAT | O_TRUNC, 0666); + if (fd < 0) { syslog(LOG_ERR, "open %s failed! ret: %d\n", prefix, ret); diff --git a/libs/libc/gdbstub/lib_gdbstub.c b/libs/libc/gdbstub/lib_gdbstub.c index 4467ee00b09..dac21623eb9 100644 --- a/libs/libc/gdbstub/lib_gdbstub.c +++ b/libs/libc/gdbstub/lib_gdbstub.c @@ -391,23 +391,24 @@ static int gdb_send_packet(FAR struct gdb_state_s *state) } #ifdef CONFIG_LIB_GDBSTUB_DEBUG - { - size_t p; - GDB_DEBUG(state, "-> "); - for (p = 0; p < len; p++) - { - if (isprint(buf[p])) - { - GDB_DEBUG(state, "%c", buf[p]); - } - else - { - GDB_DEBUG(state, "\\x%02x", buf[p] & 0xff); - } - } + { + size_t p; - GDB_DEBUG(state, "\n"); - } + GDB_DEBUG(state, "-> "); + for (p = 0; p < len; p++) + { + if (isprint(buf[p])) + { + GDB_DEBUG(state, "%c", buf[p]); + } + else + { + GDB_DEBUG(state, "\\x%02x", buf[p] & 0xff); + } + } + + GDB_DEBUG(state, "\n"); + } #endif while (i < len) @@ -581,23 +582,24 @@ static int gdb_recv_packet(FAR struct gdb_state_s *state) } #ifdef CONFIG_LIB_GDBSTUB_DEBUG - { - size_t p; - GDB_DEBUG(state, "<- "); - for (p = 0; p < state->pkt_len; p++) - { - if (isprint(state->pkt_buf[p])) - { - GDB_DEBUG(state, "%c", state->pkt_buf[p]); - } - else - { - GDB_DEBUG(state, "\\x%02x", state->pkt_buf[p] & 0xff); - } - } + { + size_t p; - GDB_DEBUG(state, "\n"); - } + GDB_DEBUG(state, "<- "); + for (p = 0; p < state->pkt_len; p++) + { + if (isprint(state->pkt_buf[p])) + { + GDB_DEBUG(state, "%c", state->pkt_buf[p]); + } + else + { + GDB_DEBUG(state, "\\x%02x", state->pkt_buf[p] & 0xff); + } + } + + GDB_DEBUG(state, "\n"); + } #endif ret = gdb_hex2bin(&expected, 1, buf, 2); @@ -1651,6 +1653,7 @@ retry: static int gdb_smp_debugpoint_add(FAR void *arg) { FAR struct gdb_debugpoint_s *point = arg; + return up_debugpoint_add(point->type, point->addr, point->size, point->callback, point->arg); } @@ -1666,6 +1669,7 @@ static int gdb_smp_debugpoint_add(FAR void *arg) static int gdb_smp_debugpoint_remove(FAR void *arg) { FAR struct gdb_debugpoint_s *point = arg; + return up_debugpoint_remove(point->type, point->addr, point->size); } #endif @@ -1888,6 +1892,7 @@ int gdb_debugpoint_add(int type, FAR void *addr, size_t size, { #ifdef CONFIG_SMP struct gdb_debugpoint_s point; + point.type = type; point.addr = addr; point.size = size; @@ -1909,6 +1914,7 @@ int gdb_debugpoint_remove(int type, FAR void *addr, size_t size) { #ifdef CONFIG_SMP struct gdb_debugpoint_s point; + point.type = type; point.addr = addr; point.size = size; @@ -2117,7 +2123,7 @@ int gdb_process(FAR struct gdb_state_s *state, int stopreason, #endif default: ret = -EPROTONOSUPPORT; - } + } if (ret == -EPROTONOSUPPORT) { diff --git a/libs/libc/locale/lib_iconv.c b/libs/libc/locale/lib_iconv.c index 9ba81c8e01f..6ffac2a1ef9 100644 --- a/libs/libc/locale/lib_iconv.c +++ b/libs/libc/locale/lib_iconv.c @@ -168,7 +168,9 @@ static int fuzzycmp(FAR const unsigned char *a, FAR const unsigned char *b) for (; *a && *b; a++, b++) { while (*a && (*a | 32U) - 'a' > 26 && *a - '0' > 10U) - a++; + { + a++; + } if ((*a | 32U) != *b) { @@ -520,24 +522,24 @@ size_t iconv(iconv_t cd, FAR char **in, FAR size_t *inb, if ((unsigned)(c - 0xd800) < 0x400) { - if (type - UCS2BE < 2U) + if (type - UCS2BE < 2U) { goto ilseq; } - l = 4; - if (*inb < 4) + l = 4; + if (*inb < 4) { goto starved; } - d = get_16((FAR void *)(*in + 2), type); - if ((unsigned)(d - 0xdc00) >= 0x400) + d = get_16((FAR void *)(*in + 2), type); + if ((unsigned)(d - 0xdc00) >= 0x400) { goto ilseq; } - c = ((c - 0xd7c0) << 10) + (d - 0xdc00); + c = ((c - 0xd7c0) << 10) + (d - 0xdc00); } } break; @@ -554,7 +556,9 @@ size_t iconv(iconv_t cd, FAR char **in, FAR size_t *inb, if (!scd->state) { if (*inb < 2) - goto starved; + { + goto starved; + } c = get_16((FAR void *)*in, 0); scd->state = (type == UCS2 @@ -580,17 +584,17 @@ size_t iconv(iconv_t cd, FAR char **in, FAR size_t *inb, l = 0; if (!scd->state) { - if (*inb < 4) + if (*inb < 4) { goto starved; } - c = get_32((FAR void *)*in, 0); - scd->state = (c == 0xfffe0000 ? UTF_32LE : UTF_32BE); - if (c == 0xfffe0000 || c == 0xfeff) - { - l = 4; - } + c = get_32((FAR void *)*in, 0); + scd->state = (c == 0xfffe0000 ? UTF_32LE : UTF_32BE); + if (c == 0xfffe0000 || c == 0xfeff) + { + l = 4; + } } type = scd->state; @@ -634,22 +638,22 @@ size_t iconv(iconv_t cd, FAR char **in, FAR size_t *inb, c *= 2; if (d - 64 <= 158 - 64) { - if (d == 127) + if (d == 127) { goto ilseq; } - if (d > 127) + if (d > 127) { d--; } - d -= 64; + d -= 64; } else if (d - 159 <= 252 - 159) { - c++; - d -= 159; + c++; + d -= 159; } c = g_jis0208[c][d]; @@ -725,10 +729,10 @@ size_t iconv(iconv_t cd, FAR char **in, FAR size_t *inb, switch (128 * (c == '$') + d) { - if (scd == NULL) - { - goto starved; - } + if (scd == NULL) + { + goto starved; + } case 'B': { @@ -1166,6 +1170,7 @@ size_t iconv(iconv_t cd, FAR char **in, FAR size_t *inb, if (*outb < 4) { char tmp[4]; + k = wctomb(tmp, c); if (*outb < k) { diff --git a/libs/libc/stdio/lib_fgetwc.c b/libs/libc/stdio/lib_fgetwc.c index c1360168de9..f5a9027aa6d 100644 --- a/libs/libc/stdio/lib_fgetwc.c +++ b/libs/libc/stdio/lib_fgetwc.c @@ -114,6 +114,7 @@ wint_t fgetwc_unlocked(FAR FILE *f) wint_t fgetwc(FAR FILE *f) { wint_t c; + flockfile(f); c = fgetwc_unlocked(f); funlockfile(f); diff --git a/libs/libc/unistd/lib_getpass.c b/libs/libc/unistd/lib_getpass.c index e323fb42fd8..cb543fc035c 100644 --- a/libs/libc/unistd/lib_getpass.c +++ b/libs/libc/unistd/lib_getpass.c @@ -69,7 +69,7 @@ FAR char *getpass(FAR const char *prompt) { if (bytes_read > 0 && g_password[total_bytes_read] == '\n') { - break; + break; } total_bytes_read += bytes_read; diff --git a/sched/misc/coredump.c b/sched/misc/coredump.c index cd0ea350be9..4ea68f3232a 100644 --- a/sched/misc/coredump.c +++ b/sched/misc/coredump.c @@ -374,7 +374,7 @@ static void elf_emit_note(FAR struct elf_dumpinfo_s *cinfo) if (cinfo->pid == INVALID_PROCESS_ID) { - FAR struct tcb_s *rtcb = running_task(); + FAR struct tcb_s *rtcb = running_task(); /* Emit the current (typically crashing) task first so that GDB's * default thread selection shows the crashing backtrace on the initial
