tests: drivers: rename shadow variables
Renames shadow variables found by -Wshadow. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
174caf0c10
commit
121b4d2d62
|
@ -49,7 +49,7 @@ static void init_adc(void)
|
|||
|
||||
zassert_true(adc_is_ready_dt(&adc_channels[0]), "ADC device is not ready");
|
||||
|
||||
for (int i = 0; i < adc_channels_count; i++) {
|
||||
for (i = 0; i < adc_channels_count; i++) {
|
||||
ret = adc_channel_setup_dt(&adc_channels[i]);
|
||||
zassert_equal(ret, 0, "Setting up of channel %d failed with code %d", i, ret);
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#include <hal/nrf_clock.h>
|
||||
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
|
||||
|
||||
static nrf_clock_lfclk_t type;
|
||||
static bool on;
|
||||
static nrf_clock_lfclk_t clk_type;
|
||||
static bool clk_on;
|
||||
static uint32_t rtc_cnt;
|
||||
|
||||
static void xtal_check(bool on, nrf_clock_lfclk_t type)
|
||||
|
@ -58,11 +58,11 @@ ZTEST(nrf_lf_clock_start, test_clock_check)
|
|||
IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF_K32SRC_EXT_FULL_SWING);
|
||||
|
||||
if (xtal) {
|
||||
xtal_check(on, type);
|
||||
xtal_check(clk_on, clk_type);
|
||||
} else if (IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC)) {
|
||||
rc_check(on, type);
|
||||
rc_check(clk_on, clk_type);
|
||||
} else {
|
||||
synth_check(on, type);
|
||||
synth_check(clk_on, clk_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ static int get_lfclk_state(void)
|
|||
* not valid, in that case read system clock to check if it has
|
||||
* progressed.
|
||||
*/
|
||||
on = nrf_clock_is_running(NRF_CLOCK, NRF_CLOCK_DOMAIN_LFCLK, &type);
|
||||
clk_on = nrf_clock_is_running(NRF_CLOCK, NRF_CLOCK_DOMAIN_LFCLK, &clk_type);
|
||||
k_busy_wait(100);
|
||||
rtc_cnt = k_cycle_get_32();
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ static void top_handler(const struct device *dev, void *user_data);
|
|||
|
||||
void *exp_user_data = (void *)199;
|
||||
|
||||
struct counter_alarm_cfg alarm_cfg;
|
||||
struct counter_alarm_cfg alarm_cfg2;
|
||||
struct counter_alarm_cfg cntr_alarm_cfg;
|
||||
struct counter_alarm_cfg cntr_alarm_cfg2;
|
||||
|
||||
#define DEVICE_DT_GET_AND_COMMA(node_id) DEVICE_DT_GET(node_id),
|
||||
/* Generate a list of devices for all instances of the "compat" */
|
||||
|
@ -340,7 +340,7 @@ static void alarm_handler(const struct device *dev, uint8_t chan_id,
|
|||
counter, now, top, processing_limit_us);
|
||||
|
||||
if (user_data) {
|
||||
zassert_true(&alarm_cfg == user_data,
|
||||
zassert_true(&cntr_alarm_cfg == user_data,
|
||||
"%s: Unexpected callback", dev->name);
|
||||
}
|
||||
|
||||
|
@ -369,9 +369,9 @@ static void test_single_shot_alarm_instance(const struct device *dev, bool set_t
|
|||
ticks = counter_us_to_ticks(dev, counter_period_us);
|
||||
top_cfg.ticks = ticks;
|
||||
|
||||
alarm_cfg.flags = 0;
|
||||
alarm_cfg.callback = alarm_handler;
|
||||
alarm_cfg.user_data = &alarm_cfg;
|
||||
cntr_alarm_cfg.flags = 0;
|
||||
cntr_alarm_cfg.callback = alarm_handler;
|
||||
cntr_alarm_cfg.user_data = &cntr_alarm_cfg;
|
||||
|
||||
k_sem_reset(&alarm_cnt_sem);
|
||||
alarm_cnt = 0;
|
||||
|
@ -390,16 +390,16 @@ static void test_single_shot_alarm_instance(const struct device *dev, bool set_t
|
|||
zassert_equal(0, err,
|
||||
"%s: Counter failed to set top value", dev->name);
|
||||
|
||||
alarm_cfg.ticks = ticks + 1;
|
||||
err = counter_set_channel_alarm(dev, 0, &alarm_cfg);
|
||||
cntr_alarm_cfg.ticks = ticks + 1;
|
||||
err = counter_set_channel_alarm(dev, 0, &cntr_alarm_cfg);
|
||||
zassert_equal(-EINVAL, err,
|
||||
"%s: Counter should return error because ticks"
|
||||
" exceeded the limit set alarm", dev->name);
|
||||
alarm_cfg.ticks = ticks - 1;
|
||||
cntr_alarm_cfg.ticks = ticks - 1;
|
||||
}
|
||||
|
||||
alarm_cfg.ticks = ticks;
|
||||
err = counter_set_channel_alarm(dev, 0, &alarm_cfg);
|
||||
cntr_alarm_cfg.ticks = ticks;
|
||||
err = counter_set_channel_alarm(dev, 0, &cntr_alarm_cfg);
|
||||
zassert_equal(0, err, "%s: Counter set alarm failed (err: %d)",
|
||||
dev->name, err);
|
||||
|
||||
|
@ -509,15 +509,15 @@ static void test_multiple_alarms_instance(const struct device *dev)
|
|||
zassert_equal(0, err, "%s: Counter get value failed", dev->name);
|
||||
top_cfg.ticks += ticks;
|
||||
|
||||
alarm_cfg.flags = COUNTER_ALARM_CFG_ABSOLUTE;
|
||||
alarm_cfg.ticks = counter_us_to_ticks(dev, 2000);
|
||||
alarm_cfg.callback = alarm_handler2;
|
||||
alarm_cfg.user_data = &alarm_cfg;
|
||||
cntr_alarm_cfg.flags = COUNTER_ALARM_CFG_ABSOLUTE;
|
||||
cntr_alarm_cfg.ticks = counter_us_to_ticks(dev, 2000);
|
||||
cntr_alarm_cfg.callback = alarm_handler2;
|
||||
cntr_alarm_cfg.user_data = &cntr_alarm_cfg;
|
||||
|
||||
alarm_cfg2.flags = 0;
|
||||
alarm_cfg2.ticks = counter_us_to_ticks(dev, 2000);
|
||||
alarm_cfg2.callback = alarm_handler2;
|
||||
alarm_cfg2.user_data = &alarm_cfg2;
|
||||
cntr_alarm_cfg2.flags = 0;
|
||||
cntr_alarm_cfg2.ticks = counter_us_to_ticks(dev, 2000);
|
||||
cntr_alarm_cfg2.callback = alarm_handler2;
|
||||
cntr_alarm_cfg2.user_data = &cntr_alarm_cfg2;
|
||||
|
||||
k_sem_reset(&alarm_cnt_sem);
|
||||
alarm_cnt = 0;
|
||||
|
@ -541,12 +541,12 @@ static void test_multiple_alarms_instance(const struct device *dev)
|
|||
return;
|
||||
}
|
||||
|
||||
k_busy_wait(3*(uint32_t)counter_ticks_to_us(dev, alarm_cfg.ticks));
|
||||
k_busy_wait(3*(uint32_t)counter_ticks_to_us(dev, cntr_alarm_cfg.ticks));
|
||||
|
||||
err = counter_set_channel_alarm(dev, 0, &alarm_cfg);
|
||||
err = counter_set_channel_alarm(dev, 0, &cntr_alarm_cfg);
|
||||
zassert_equal(0, err, "%s: Counter set alarm failed", dev->name);
|
||||
|
||||
err = counter_set_channel_alarm(dev, 1, &alarm_cfg2);
|
||||
err = counter_set_channel_alarm(dev, 1, &cntr_alarm_cfg2);
|
||||
zassert_equal(0, err, "%s: Counter set alarm failed", dev->name);
|
||||
|
||||
k_busy_wait(1.2 * counter_ticks_to_us(dev, ticks * 2U));
|
||||
|
@ -557,10 +557,10 @@ static void test_multiple_alarms_instance(const struct device *dev)
|
|||
"%s: Invalid number of callbacks %d (expected: %d)",
|
||||
dev->name, cnt, 2);
|
||||
|
||||
zassert_equal(&alarm_cfg2, clbk_data[0],
|
||||
zassert_equal(&cntr_alarm_cfg2, clbk_data[0],
|
||||
"%s: Expected different order or callbacks",
|
||||
dev->name);
|
||||
zassert_equal(&alarm_cfg, clbk_data[1],
|
||||
zassert_equal(&cntr_alarm_cfg, clbk_data[1],
|
||||
"%s: Expected different order or callbacks",
|
||||
dev->name);
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
|
||||
#ifdef CONFIG_RANDOM_BUFFER_NOCACHED
|
||||
__attribute__((__section__(".nocache")))
|
||||
static uint8_t buffer[BUFFER_LENGTH] = {0};
|
||||
static uint8_t entropy_buffer[BUFFER_LENGTH] = {0};
|
||||
#else
|
||||
static uint8_t buffer[BUFFER_LENGTH] = {0};
|
||||
static uint8_t entropy_buffer[BUFFER_LENGTH] = {0};
|
||||
#endif
|
||||
|
||||
static int random_entropy(const struct device *dev, char *buffer, char num)
|
||||
|
@ -86,7 +86,7 @@ static int get_entropy(void)
|
|||
TC_PRINT("random device is %p, name is %s\n",
|
||||
dev, dev->name);
|
||||
|
||||
ret = random_entropy(dev, buffer, 0);
|
||||
ret = random_entropy(dev, entropy_buffer, 0);
|
||||
|
||||
/* Check whether 20% or more of buffer still filled with default
|
||||
* value(0), if yes then recheck again by filling nonzero value(0xa5)
|
||||
|
@ -94,7 +94,7 @@ static int get_entropy(void)
|
|||
* of buffer filled with value(0xa5) or not.
|
||||
*/
|
||||
if (ret == RECHECK_RANDOM_ENTROPY) {
|
||||
ret = random_entropy(dev, buffer, 0xa5);
|
||||
ret = random_entropy(dev, entropy_buffer, 0xa5);
|
||||
if (ret == RECHECK_RANDOM_ENTROPY) {
|
||||
return TC_FAIL;
|
||||
} else {
|
||||
|
|
|
@ -25,7 +25,7 @@ static uint32_t sector_mask;
|
|||
static uint8_t __aligned(4) expected[EXPECTED_SIZE];
|
||||
|
||||
static int sector_mask_from_offset(const struct device *dev, off_t offset,
|
||||
size_t size, uint32_t *sector_mask)
|
||||
size_t size, uint32_t *mask)
|
||||
{
|
||||
struct flash_pages_info start_page, end_page;
|
||||
|
||||
|
@ -34,8 +34,8 @@ static int sector_mask_from_offset(const struct device *dev, off_t offset,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
*sector_mask = ((1UL << (end_page.index + 1)) - 1) &
|
||||
~((1UL << start_page.index) - 1);
|
||||
*mask = ((1UL << (end_page.index + 1)) - 1) &
|
||||
~((1UL << start_page.index) - 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -433,7 +433,7 @@ static K_SEM_DEFINE(caller, 0, 1);
|
|||
K_THREAD_STACK_DEFINE(spi_async_stack, STACK_SIZE);
|
||||
static int result = 1;
|
||||
|
||||
static void spi_async_call_cb(struct k_poll_event *async_evt,
|
||||
static void spi_async_call_cb(struct k_poll_event *evt,
|
||||
struct k_sem *caller_sem,
|
||||
void *unused)
|
||||
{
|
||||
|
@ -442,15 +442,15 @@ static void spi_async_call_cb(struct k_poll_event *async_evt,
|
|||
LOG_DBG("Polling...");
|
||||
|
||||
while (1) {
|
||||
ret = k_poll(async_evt, 1, K_MSEC(200));
|
||||
ret = k_poll(evt, 1, K_MSEC(200));
|
||||
zassert_false(ret, "one or more events are not ready");
|
||||
|
||||
result = async_evt->signal->result;
|
||||
result = evt->signal->result;
|
||||
k_sem_give(caller_sem);
|
||||
|
||||
/* Reinitializing for next call */
|
||||
async_evt->signal->signaled = 0U;
|
||||
async_evt->state = K_POLL_STATE_NOT_READY;
|
||||
evt->signal->signaled = 0U;
|
||||
evt->state = K_POLL_STATE_NOT_READY;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -260,7 +260,7 @@ ZTEST_BMEM uint8_t rx_buf_idx;
|
|||
|
||||
ZTEST_BMEM uint8_t *read_ptr;
|
||||
|
||||
static void test_chained_read_callback(const struct device *uart_dev,
|
||||
static void test_chained_read_callback(const struct device *dev,
|
||||
struct uart_event *evt, void *user_data)
|
||||
{
|
||||
int err;
|
||||
|
@ -277,7 +277,7 @@ static void test_chained_read_callback(const struct device *uart_dev,
|
|||
rx_data_idx += evt->data.rx.len;
|
||||
break;
|
||||
case UART_RX_BUF_REQUEST:
|
||||
err = uart_rx_buf_rsp(uart_dev,
|
||||
err = uart_rx_buf_rsp(dev,
|
||||
chained_read_buf[rx_buf_idx],
|
||||
sizeof(chained_read_buf[0]));
|
||||
zassert_equal(err, 0);
|
||||
|
@ -338,7 +338,7 @@ ZTEST_USER(uart_async_chain_read, test_chained_read)
|
|||
ZTEST_BMEM uint8_t double_buffer[2][12];
|
||||
ZTEST_DMEM uint8_t *next_buf = double_buffer[1];
|
||||
|
||||
static void test_double_buffer_callback(const struct device *uart_dev,
|
||||
static void test_double_buffer_callback(const struct device *dev,
|
||||
struct uart_event *evt, void *user_data)
|
||||
{
|
||||
switch (evt->type) {
|
||||
|
@ -350,7 +350,7 @@ static void test_double_buffer_callback(const struct device *uart_dev,
|
|||
k_sem_give(&rx_rdy);
|
||||
break;
|
||||
case UART_RX_BUF_REQUEST:
|
||||
uart_rx_buf_rsp(uart_dev, next_buf, sizeof(double_buffer[0]));
|
||||
uart_rx_buf_rsp(dev, next_buf, sizeof(double_buffer[0]));
|
||||
break;
|
||||
case UART_RX_BUF_RELEASED:
|
||||
next_buf = evt->data.rx_buf.buf;
|
||||
|
@ -513,7 +513,7 @@ ZTEST_USER(uart_async_read_abort, test_read_abort)
|
|||
|
||||
ZTEST_BMEM volatile size_t sent;
|
||||
ZTEST_BMEM volatile size_t received;
|
||||
ZTEST_BMEM uint8_t rx_buf[2][100];
|
||||
ZTEST_BMEM uint8_t test_rx_buf[2][100];
|
||||
|
||||
static void test_write_abort_callback(const struct device *dev,
|
||||
struct uart_event *evt, void *user_data)
|
||||
|
@ -533,7 +533,7 @@ static void test_write_abort_callback(const struct device *dev,
|
|||
k_sem_give(&rx_rdy);
|
||||
break;
|
||||
case UART_RX_BUF_REQUEST:
|
||||
uart_rx_buf_rsp(dev, rx_buf[1], sizeof(rx_buf[1]));
|
||||
uart_rx_buf_rsp(dev, test_rx_buf[1], sizeof(test_rx_buf[1]));
|
||||
break;
|
||||
case UART_RX_BUF_RELEASED:
|
||||
k_sem_give(&rx_buf_released);
|
||||
|
@ -559,15 +559,15 @@ ZTEST_USER(uart_async_write_abort, test_write_abort)
|
|||
{
|
||||
uint8_t tx_buf[100];
|
||||
|
||||
memset(rx_buf, 0, sizeof(rx_buf));
|
||||
memset(test_rx_buf, 0, sizeof(test_rx_buf));
|
||||
memset(tx_buf, 1, sizeof(tx_buf));
|
||||
|
||||
uart_rx_enable(uart_dev, rx_buf[0], sizeof(rx_buf[0]), 50 * USEC_PER_MSEC);
|
||||
uart_rx_enable(uart_dev, test_rx_buf[0], sizeof(test_rx_buf[0]), 50 * USEC_PER_MSEC);
|
||||
|
||||
uart_tx(uart_dev, tx_buf, 5, 100 * USEC_PER_MSEC);
|
||||
zassert_equal(k_sem_take(&tx_done, K_MSEC(100)), 0, "TX_DONE timeout");
|
||||
zassert_equal(k_sem_take(&rx_rdy, K_MSEC(100)), 0, "RX_RDY timeout");
|
||||
zassert_equal(memcmp(tx_buf, rx_buf, 5), 0, "Buffers not equal");
|
||||
zassert_equal(memcmp(tx_buf, test_rx_buf, 5), 0, "Buffers not equal");
|
||||
|
||||
uart_tx(uart_dev, tx_buf, 95, 100 * USEC_PER_MSEC);
|
||||
uart_tx_abort(uart_dev);
|
||||
|
@ -664,13 +664,13 @@ ZTEST_DMEM uint8_t chained_write_tx_bufs[2][10] = {"Message 1", "Message 2"};
|
|||
ZTEST_DMEM bool chained_write_next_buf = true;
|
||||
ZTEST_BMEM volatile uint8_t tx_sent;
|
||||
|
||||
static void test_chained_write_callback(const struct device *uart_dev,
|
||||
static void test_chained_write_callback(const struct device *dev,
|
||||
struct uart_event *evt, void *user_data)
|
||||
{
|
||||
switch (evt->type) {
|
||||
case UART_TX_DONE:
|
||||
if (chained_write_next_buf) {
|
||||
uart_tx(uart_dev, chained_write_tx_bufs[1], 10, 100 * USEC_PER_MSEC);
|
||||
uart_tx(dev, chained_write_tx_bufs[1], 10, 100 * USEC_PER_MSEC);
|
||||
chained_write_next_buf = false;
|
||||
}
|
||||
tx_sent = 1;
|
||||
|
@ -738,10 +738,10 @@ ZTEST_BMEM uint8_t long_tx_buf[1000];
|
|||
ZTEST_BMEM volatile uint8_t evt_num;
|
||||
ZTEST_BMEM size_t long_received[2];
|
||||
|
||||
static void test_long_buffers_callback(const struct device *uart_dev,
|
||||
static void test_long_buffers_callback(const struct device *dev,
|
||||
struct uart_event *evt, void *user_data)
|
||||
{
|
||||
static uint8_t *next_buf = long_rx_buf2;
|
||||
static uint8_t *next_buffer = long_rx_buf2;
|
||||
|
||||
switch (evt->type) {
|
||||
case UART_TX_DONE:
|
||||
|
@ -763,8 +763,8 @@ static void test_long_buffers_callback(const struct device *uart_dev,
|
|||
k_sem_give(&rx_disabled);
|
||||
break;
|
||||
case UART_RX_BUF_REQUEST:
|
||||
uart_rx_buf_rsp(uart_dev, next_buf, 1024);
|
||||
next_buf = (next_buf == long_rx_buf2) ? long_rx_buf : long_rx_buf2;
|
||||
uart_rx_buf_rsp(dev, next_buffer, 1024);
|
||||
next_buffer = (next_buffer == long_rx_buf2) ? long_rx_buf : long_rx_buf2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -112,8 +112,8 @@ static void communication_verify(const struct device *dev, bool active)
|
|||
|
||||
#define state_verify(dev, exp_state) do {\
|
||||
enum pm_device_state power_state; \
|
||||
int err = pm_device_state_get(dev, &power_state); \
|
||||
zassert_equal(err, 0, "Unexpected err: %d", err); \
|
||||
int error = pm_device_state_get(dev, &power_state); \
|
||||
zassert_equal(error, 0, "Unexpected err: %d", error); \
|
||||
zassert_equal(power_state, exp_state); \
|
||||
} while (0)
|
||||
|
||||
|
|
Loading…
Reference in a new issue