diff mbox series

[02/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected

Message ID 20200731143152.8812-2-patrick.delaunay@st.com
State Accepted
Commit 6a8713bbe3268060a576a4c9723c7e69de55a054
Delegated to: Patrice Chotard
Headers show
Series [01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check | expand

Commit Message

Patrick DELAUNAY July 31, 2020, 2:31 p.m. UTC
Use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected
and in g_dnl_bind_fixup

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 board/st/stm32mp1/stm32mp1.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Comments

Patrice CHOTARD Aug. 13, 2020, 7:22 a.m. UTC | #1
Hi Patrick

On 7/31/20 4:31 PM, Patrick Delaunay wrote:
> Use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected
> and in g_dnl_bind_fixup
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  board/st/stm32mp1/stm32mp1.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 1ad41796fb..5c84b09c3e 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -182,13 +182,14 @@ static void board_key_check(void)
>  	}
>  }
>  
> -#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
> -#include <usb/dwc2_udc.h>
>  int g_dnl_board_usb_cable_connected(void)
>  {
>  	struct udevice *dwc2_udc_otg;
>  	int ret;
>  
> +	if (!IS_ENABLED(CONFIG_USB_GADGET_DWC2_OTG))
> +		return -ENODEV;
> +
>  	/* if typec stusb160x is present, means DK1 or DK2 board */
>  	ret = stusb160x_cable_connected();
>  	if (ret >= 0)
> @@ -203,14 +204,17 @@ int g_dnl_board_usb_cable_connected(void)
>  	return dwc2_udc_B_session_valid(dwc2_udc_otg);
>  }
>  
> +#ifdef CONFIG_USB_GADGET_DOWNLOAD
>  #define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11
>  #define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afb
>  
>  int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
>  {
> -	if (!strcmp(name, "usb_dnl_dfu"))
> +	if (IS_ENABLED(CONFIG_DFU_OVER_USB) &&
> +	    !strcmp(name, "usb_dnl_dfu"))
>  		put_unaligned(STM32MP1_G_DNL_DFU_PRODUCT_NUM, &dev->idProduct);
> -	else if (!strcmp(name, "usb_dnl_fastboot"))
> +	else if (IS_ENABLED(CONFIG_FASTBOOT) &&
> +		 !strcmp(name, "usb_dnl_fastboot"))
>  		put_unaligned(STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM,
>  			      &dev->idProduct);
>  	else
> @@ -218,8 +222,7 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
>  
>  	return 0;
>  }
> -
> -#endif /* CONFIG_USB_GADGET */
> +#endif /* CONFIG_USB_GADGET_DOWNLOAD */
>  
>  static int get_led(struct udevice **dev, char *led_string)
>  {

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks

Patrice
Patrice CHOTARD Aug. 13, 2020, 9:49 a.m. UTC | #2
On 8/13/20 9:22 AM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 7/31/20 4:31 PM, Patrick Delaunay wrote:
>> Use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected
>> and in g_dnl_bind_fixup
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>> ---
>>
>>  board/st/stm32mp1/stm32mp1.c | 15 +++++++++------
>>  1 file changed, 9 insertions(+), 6 deletions(-)

Applied on u-boot-stm/master

Thanks

>>
>> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
>> index 1ad41796fb..5c84b09c3e 100644
>> --- a/board/st/stm32mp1/stm32mp1.c
>> +++ b/board/st/stm32mp1/stm32mp1.c
>> @@ -182,13 +182,14 @@ static void board_key_check(void)
>>  	}
>>  }
>>  
>> -#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
>> -#include <usb/dwc2_udc.h>
>>  int g_dnl_board_usb_cable_connected(void)
>>  {
>>  	struct udevice *dwc2_udc_otg;
>>  	int ret;
>>  
>> +	if (!IS_ENABLED(CONFIG_USB_GADGET_DWC2_OTG))
>> +		return -ENODEV;
>> +
>>  	/* if typec stusb160x is present, means DK1 or DK2 board */
>>  	ret = stusb160x_cable_connected();
>>  	if (ret >= 0)
>> @@ -203,14 +204,17 @@ int g_dnl_board_usb_cable_connected(void)
>>  	return dwc2_udc_B_session_valid(dwc2_udc_otg);
>>  }
>>  
>> +#ifdef CONFIG_USB_GADGET_DOWNLOAD
>>  #define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11
>>  #define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afb
>>  
>>  int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
>>  {
>> -	if (!strcmp(name, "usb_dnl_dfu"))
>> +	if (IS_ENABLED(CONFIG_DFU_OVER_USB) &&
>> +	    !strcmp(name, "usb_dnl_dfu"))
>>  		put_unaligned(STM32MP1_G_DNL_DFU_PRODUCT_NUM, &dev->idProduct);
>> -	else if (!strcmp(name, "usb_dnl_fastboot"))
>> +	else if (IS_ENABLED(CONFIG_FASTBOOT) &&
>> +		 !strcmp(name, "usb_dnl_fastboot"))
>>  		put_unaligned(STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM,
>>  			      &dev->idProduct);
>>  	else
>> @@ -218,8 +222,7 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
>>  
>>  	return 0;
>>  }
>> -
>> -#endif /* CONFIG_USB_GADGET */
>> +#endif /* CONFIG_USB_GADGET_DOWNLOAD */
>>  
>>  static int get_led(struct udevice **dev, char *led_string)
>>  {
> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
>
> Thanks
>
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32@st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
diff mbox series

Patch

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 1ad41796fb..5c84b09c3e 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -182,13 +182,14 @@  static void board_key_check(void)
 	}
 }
 
-#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
-#include <usb/dwc2_udc.h>
 int g_dnl_board_usb_cable_connected(void)
 {
 	struct udevice *dwc2_udc_otg;
 	int ret;
 
+	if (!IS_ENABLED(CONFIG_USB_GADGET_DWC2_OTG))
+		return -ENODEV;
+
 	/* if typec stusb160x is present, means DK1 or DK2 board */
 	ret = stusb160x_cable_connected();
 	if (ret >= 0)
@@ -203,14 +204,17 @@  int g_dnl_board_usb_cable_connected(void)
 	return dwc2_udc_B_session_valid(dwc2_udc_otg);
 }
 
+#ifdef CONFIG_USB_GADGET_DOWNLOAD
 #define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11
 #define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afb
 
 int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
 {
-	if (!strcmp(name, "usb_dnl_dfu"))
+	if (IS_ENABLED(CONFIG_DFU_OVER_USB) &&
+	    !strcmp(name, "usb_dnl_dfu"))
 		put_unaligned(STM32MP1_G_DNL_DFU_PRODUCT_NUM, &dev->idProduct);
-	else if (!strcmp(name, "usb_dnl_fastboot"))
+	else if (IS_ENABLED(CONFIG_FASTBOOT) &&
+		 !strcmp(name, "usb_dnl_fastboot"))
 		put_unaligned(STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM,
 			      &dev->idProduct);
 	else
@@ -218,8 +222,7 @@  int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
 
 	return 0;
 }
-
-#endif /* CONFIG_USB_GADGET */
+#endif /* CONFIG_USB_GADGET_DOWNLOAD */
 
 static int get_led(struct udevice **dev, char *led_string)
 {