From 2275c22f7e5b5eafcc58639995d3ed21421456a4 Mon Sep 17 00:00:00 2001
From: Tobias Pisani <mail@topisani.dev>
Date: Sun, 1 Dec 2024 14:43:15 +0100
Subject: [PATCH] drivers: udc: stm32: add kconfig dependency on !USB_DC_STM32

If both new and old stm32 usb drivers are enabled, the HAL callbacks will raise multiple definition linker errors.
By adding this kconfig dependency, this will be reported as a kconfig warning that should be easier to understand.
This will happen when trying to run samples with -DCONF_FILE=usbd_next_prj.conf for boards that automatically
enable the legacy usb stack (e.g. arduino_portenta/stm32h747xx/m7).

Signed-off-by: Tobias Pisani <mail@topisani.dev>
---
 drivers/usb/udc/Kconfig.stm32 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/udc/Kconfig.stm32 b/drivers/usb/udc/Kconfig.stm32
index 44feca68ff811d7..c2fbac5f0455d2b 100644
--- a/drivers/usb/udc/Kconfig.stm32
+++ b/drivers/usb/udc/Kconfig.stm32
@@ -6,6 +6,7 @@ config UDC_STM32
 	depends on DT_HAS_ST_STM32_OTGFS_ENABLED \
 		|| DT_HAS_ST_STM32_OTGHS_ENABLED \
 		|| DT_HAS_ST_STM32_USB_ENABLED
+	depends on !USB_DC_STM32
 	select USE_STM32_LL_USB
 	select USE_STM32_HAL_PCD
 	select USE_STM32_HAL_PCD_EX