[Uboot-stm32] [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check

Patrice CHOTARD patrice.chotard at st.com
Thu Aug 13 11:49:05 CEST 2020


On 8/13/20 9:51 AM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 7/31/20 4:31 PM, Patrick Delaunay wrote:
>> Use IS_ENABLED to prevent ifdef in board_key_check
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
>> ---
>>
>>  board/st/stm32mp1/stm32mp1.c | 52 ++++++++++++++++++------------------
>>  1 file changed, 26 insertions(+), 26 deletions(-)

Applied on u-boot-stm/master

Thanks

>>
>> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
>> index 1d274c3157..1ad41796fb 100644
>> --- a/board/st/stm32mp1/stm32mp1.c
>> +++ b/board/st/stm32mp1/stm32mp1.c
>> @@ -135,51 +135,51 @@ int checkboard(void)
>>  
>>  static void board_key_check(void)
>>  {
>> -#if defined(CONFIG_FASTBOOT) || defined(CONFIG_CMD_STM32PROG)
>>  	ofnode node;
>>  	struct gpio_desc gpio;
>>  	enum forced_boot_mode boot_mode = BOOT_NORMAL;
>>  
>> +	if (!IS_ENABLED(CONFIG_FASTBOOT) && !IS_ENABLED(CONFIG_CMD_STM32PROG))
>> +		return;
>> +
>>  	node = ofnode_path("/config");
>>  	if (!ofnode_valid(node)) {
>>  		debug("%s: no /config node?\n", __func__);
>>  		return;
>>  	}
>> -#ifdef CONFIG_FASTBOOT
>> -	if (gpio_request_by_name_nodev(node, "st,fastboot-gpios", 0,
>> -				       &gpio, GPIOD_IS_IN)) {
>> -		debug("%s: could not find a /config/st,fastboot-gpios\n",
>> -		      __func__);
>> -	} else {
>> -		if (dm_gpio_get_value(&gpio)) {
>> -			puts("Fastboot key pressed, ");
>> -			boot_mode = BOOT_FASTBOOT;
>> -		}
>> +	if (IS_ENABLED(CONFIG_FASTBOOT)) {
>> +		if (gpio_request_by_name_nodev(node, "st,fastboot-gpios", 0,
>> +					       &gpio, GPIOD_IS_IN)) {
>> +			debug("%s: could not find a /config/st,fastboot-gpios\n",
>> +			      __func__);
>> +		} else {
>> +			if (dm_gpio_get_value(&gpio)) {
>> +				puts("Fastboot key pressed, ");
>> +				boot_mode = BOOT_FASTBOOT;
>> +			}
>>  
>> -		dm_gpio_free(NULL, &gpio);
>> +			dm_gpio_free(NULL, &gpio);
>> +		}
>>  	}
>> -#endif
>> -#ifdef CONFIG_CMD_STM32PROG
>> -	if (gpio_request_by_name_nodev(node, "st,stm32prog-gpios", 0,
>> -				       &gpio, GPIOD_IS_IN)) {
>> -		debug("%s: could not find a /config/st,stm32prog-gpios\n",
>> -		      __func__);
>> -	} else {
>> -		if (dm_gpio_get_value(&gpio)) {
>> -			puts("STM32Programmer key pressed, ");
>> -			boot_mode = BOOT_STM32PROG;
>> +	if (IS_ENABLED(CONFIG_CMD_STM32PROG)) {
>> +		if (gpio_request_by_name_nodev(node, "st,stm32prog-gpios", 0,
>> +					       &gpio, GPIOD_IS_IN)) {
>> +			debug("%s: could not find a /config/st,stm32prog-gpios\n",
>> +			      __func__);
>> +		} else {
>> +			if (dm_gpio_get_value(&gpio)) {
>> +				puts("STM32Programmer key pressed, ");
>> +				boot_mode = BOOT_STM32PROG;
>> +			}
>> +			dm_gpio_free(NULL, &gpio);
>>  		}
>> -		dm_gpio_free(NULL, &gpio);
>>  	}
>> -#endif
>> -
>>  	if (boot_mode != BOOT_NORMAL) {
>>  		puts("entering download mode...\n");
>>  		clrsetbits_le32(TAMP_BOOT_CONTEXT,
>>  				TAMP_BOOT_FORCED_MASK,
>>  				boot_mode);
>>  	}
>> -#endif
>>  }
>>  
>>  #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
> Reviewed-by: Patrice Chotard <patrice.chotard at st.com>
>
> Thanks
>
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32 at st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32


More information about the U-Boot mailing list