Skip to content

Commit 3a8dddc

Browse files
Jeppe Odgaardkartben
authored andcommitted
drivers: adc: stm32: use __maybe_unused
Replace conditional `ARG_UNUSED` with `__maybe_unused`. This is recommended by coding style: https://kernel.org/doc/html/latest/process/coding-style.html#conditional-compilation Signed-off-by: Jeppe Odgaard <[email protected]>
1 parent c0c6047 commit 3a8dddc

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

drivers/adc/adc_stm32.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,10 +1080,7 @@ static void adc_context_start_sampling(struct adc_context *ctx)
10801080
CONTAINER_OF(ctx, struct adc_stm32_data, ctx);
10811081
const struct device *dev = data->dev;
10821082
const struct adc_stm32_cfg *config = dev->config;
1083-
ADC_TypeDef *adc = config->base;
1084-
1085-
/* Remove warning for some series */
1086-
ARG_UNUSED(adc);
1083+
__maybe_unused ADC_TypeDef *adc = config->base;
10871084

10881085
data->repeat_buffer = data->buffer;
10891086

@@ -1154,7 +1151,7 @@ static void adc_context_on_complete(struct adc_context *ctx, int status)
11541151
struct adc_stm32_data *data =
11551152
CONTAINER_OF(ctx, struct adc_stm32_data, ctx);
11561153
const struct adc_stm32_cfg *config = data->dev->config;
1157-
ADC_TypeDef *adc = config->base;
1154+
__maybe_unused ADC_TypeDef *adc = config->base;
11581155

11591156
ARG_UNUSED(status);
11601157

@@ -1165,8 +1162,6 @@ static void adc_context_on_complete(struct adc_context *ctx, int status)
11651162
#if defined(CONFIG_SOC_SERIES_STM32H7X) || defined(CONFIG_SOC_SERIES_STM32U5X)
11661163
/* Reset channel preselection register */
11671164
LL_ADC_SetChannelPreselection(adc, 0);
1168-
#else
1169-
ARG_UNUSED(adc);
11701165
#endif /* CONFIG_SOC_SERIES_STM32H7X || CONFIG_SOC_SERIES_STM32U5X */
11711166
}
11721167

@@ -1237,7 +1232,7 @@ static int adc_stm32_sampling_time_setup(const struct device *dev, uint8_t id,
12371232
const struct adc_stm32_cfg *config =
12381233
(const struct adc_stm32_cfg *)dev->config;
12391234
ADC_TypeDef *adc = config->base;
1240-
struct adc_stm32_data *data = dev->data;
1235+
__maybe_unused struct adc_stm32_data *data = dev->data;
12411236

12421237
int acq_time_index;
12431238

@@ -1255,7 +1250,6 @@ static int adc_stm32_sampling_time_setup(const struct device *dev, uint8_t id,
12551250
switch (config->num_sampling_time_common_channels) {
12561251
case 0:
12571252
#if ANY_NUM_COMMON_SAMPLING_TIME_CHANNELS_IS(0)
1258-
ARG_UNUSED(data);
12591253
LL_ADC_SetChannelSamplingTime(adc,
12601254
__LL_ADC_DECIMAL_NB_TO_CHANNEL(id),
12611255
(uint32_t)acq_time_index);
@@ -1491,11 +1485,9 @@ static int adc_stm32_set_clock(const struct device *dev)
14911485
{
14921486
const struct adc_stm32_cfg *config = dev->config;
14931487
const struct device *const clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE);
1494-
ADC_TypeDef *adc = config->base;
1488+
__maybe_unused ADC_TypeDef *adc = config->base;
14951489
int ret = 0;
14961490

1497-
ARG_UNUSED(adc); /* Necessary to avoid warnings on some series */
1498-
14991491
if (clock_control_on(clk,
15001492
(clock_control_subsys_t) &config->pclken[0]) != 0) {
15011493
return -EIO;
@@ -1560,11 +1552,9 @@ static int adc_stm32_init(const struct device *dev)
15601552
struct adc_stm32_data *data = dev->data;
15611553
const struct adc_stm32_cfg *config = dev->config;
15621554
const struct device *const clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE);
1563-
ADC_TypeDef *adc = config->base;
1555+
__maybe_unused ADC_TypeDef *adc = config->base;
15641556
int err;
15651557

1566-
ARG_UNUSED(adc); /* Necessary to avoid warnings on some series */
1567-
15681558
LOG_DBG("Initializing %s", dev->name);
15691559

15701560
if (!device_is_ready(clk)) {

0 commit comments

Comments
 (0)