diff mbox series

usb: dwc3: qcom: Provide stubs for dwc3_qcom_read_usb2_speed function

Message ID 1659237530-436-1-git-send-email-quic_kriskura@quicinc.com (mailing list archive)
State Superseded
Headers show
Series usb: dwc3: qcom: Provide stubs for dwc3_qcom_read_usb2_speed function | expand

Commit Message

Krishna Kurapati PSSNV July 31, 2022, 3:18 a.m. UTC
This patch intends to fix a build issue that is occurring due to
dwc3_qcom_read_usb2_speed function which uses usb_hub_find_child API
in its effors to get the speed of devices (HS/FS/LS) connected.

usb_hub_find_child API is a part of usb core compiled into the kernel
when CONFIG_USB=y. In some builds (make randconfig for i386)
CONFIG_USB is not set and the usb core is not compiled into the
kernel causing linking errors.

Provide stubs for dwc3_qcom_read_usb2_speed function to use
usb_hub_find_child API only if CONFIG_USB is set. Else return
USB_SPEED_UNKNOWN.

Fixes: 6895ea55c385 (usb: dwc3: qcom: Configure wakeup interrupts during suspend)
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
---
 drivers/usb/dwc3/dwc3-qcom.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Randy Dunlap July 31, 2022, 5:08 a.m. UTC | #1
Hi--

On 7/30/22 20:18, Krishna Kurapati wrote:
> This patch intends to fix a build issue that is occurring due to
> dwc3_qcom_read_usb2_speed function which uses usb_hub_find_child API
> in its effors to get the speed of devices (HS/FS/LS) connected.
> 
> usb_hub_find_child API is a part of usb core compiled into the kernel
> when CONFIG_USB=y. In some builds (make randconfig for i386)
> CONFIG_USB is not set and the usb core is not compiled into the
> kernel causing linking errors.
> 
> Provide stubs for dwc3_qcom_read_usb2_speed function to use
> usb_hub_find_child API only if CONFIG_USB is set. Else return
> USB_SPEED_UNKNOWN.
> 
> Fixes: 6895ea55c385 (usb: dwc3: qcom: Configure wakeup interrupts during suspend)
> Reported-by: Randy Dunlap <rdunlap@infradead.org>

Suggested-by: Randy Dunlap <rdunlap@infradead.org>

> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>


Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>

Thanks.

> ---
>  drivers/usb/dwc3/dwc3-qcom.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index c5e482f..bd8dc5a 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -299,6 +299,7 @@ static void dwc3_qcom_interconnect_exit(struct dwc3_qcom *qcom)
>  	icc_put(qcom->icc_path_apps);
>  }
>  
> +#ifdef CONFIG_USB
>  static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom)
>  {
>  	struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3);
> @@ -318,6 +319,12 @@ static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom)
>  
>  	return udev->speed;
>  }
> +#else
> +static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom)
> +{
> +	return USB_SPEED_UNKNOWN;
> +}
> +#endif
>  
>  static void dwc3_qcom_enable_wakeup_irq(int irq, unsigned int polarity)
>  {
Dmitry Baryshkov July 31, 2022, 6:33 a.m. UTC | #2
On Sun, 31 Jul 2022 at 06:19, Krishna Kurapati
<quic_kriskura@quicinc.com> wrote:
>
> This patch intends to fix a build issue that is occurring due to

Please refrain from the "This patch" phrase. See the
Documentation/process/submitting-patches.rst for the suggestions for
the commit message.

> dwc3_qcom_read_usb2_speed function which uses usb_hub_find_child API
> in its effors to get the speed of devices (HS/FS/LS) connected.
>
> usb_hub_find_child API is a part of usb core compiled into the kernel
> when CONFIG_USB=y. In some builds (make randconfig for i386)
> CONFIG_USB is not set and the usb core is not compiled into the
> kernel causing linking errors.
>
> Provide stubs for dwc3_qcom_read_usb2_speed function to use
> usb_hub_find_child API only if CONFIG_USB is set. Else return
> USB_SPEED_UNKNOWN.

The commit message describes the issue in terms of CONFIG_USB being
compiled into the kernel or not. It is not clear if the issue
manifests with CONFIG_USB=m (which is also 'not compiled into the
kernel').
If I understand correctly, the cause for linking errors is not in the
CONFIG_USB being not compiled into the kernel, but in CONFIG_USB being
not enabled at all (which is possible since USB_DWC3 depends on USB ||
USB_GADGET).
If my understanding is correct, I'd suggest changing the commit
message to describe the cause rather than just the issue you observed
on randconfig failure.

>
> Fixes: 6895ea55c385 (usb: dwc3: qcom: Configure wakeup interrupts during suspend)
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
> ---
>  drivers/usb/dwc3/dwc3-qcom.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index c5e482f..bd8dc5a 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -299,6 +299,7 @@ static void dwc3_qcom_interconnect_exit(struct dwc3_qcom *qcom)
>         icc_put(qcom->icc_path_apps);
>  }
>
> +#ifdef CONFIG_USB
>  static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom)
>  {
>         struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3);
> @@ -318,6 +319,12 @@ static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom)
>
>         return udev->speed;
>  }
> +#else
> +static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom)
> +{
> +       return USB_SPEED_UNKNOWN;
> +}
> +#endif
>
>  static void dwc3_qcom_enable_wakeup_irq(int irq, unsigned int polarity)
>  {
> --
> 2.7.4
>
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index c5e482f..bd8dc5a 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -299,6 +299,7 @@  static void dwc3_qcom_interconnect_exit(struct dwc3_qcom *qcom)
 	icc_put(qcom->icc_path_apps);
 }
 
+#ifdef CONFIG_USB
 static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom)
 {
 	struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3);
@@ -318,6 +319,12 @@  static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom)
 
 	return udev->speed;
 }
+#else
+static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom)
+{
+	return USB_SPEED_UNKNOWN;
+}
+#endif
 
 static void dwc3_qcom_enable_wakeup_irq(int irq, unsigned int polarity)
 {