usb: dwc3: qcom: only parse 'maximum-speed' once
authorJohan Hovold <johan+linaro@kernel.org>
Fri, 5 Aug 2022 07:44:59 +0000 (09:44 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Aug 2022 09:04:58 +0000 (11:04 +0200)
Add a temporary variable to the interconnect-initialisation helper to
avoid parsing and decoding the 'maximum-speed' devicetree property
twice.

Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20220805074500.21469-2-johan+linaro@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/dwc3-qcom.c

index c5e482f53e9db13f8232f6519fa7016a645d7887..f5f38002b751aef0ae2e1178dba1c372f333211a 100644 (file)
@@ -244,6 +244,7 @@ static int dwc3_qcom_interconnect_disable(struct dwc3_qcom *qcom)
  */
 static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom)
 {
+       enum usb_device_speed max_speed;
        struct device *dev = qcom->dev;
        int ret;
 
@@ -264,8 +265,8 @@ static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom)
                return PTR_ERR(qcom->icc_path_apps);
        }
 
-       if (usb_get_maximum_speed(&qcom->dwc3->dev) >= USB_SPEED_SUPER ||
-                       usb_get_maximum_speed(&qcom->dwc3->dev) == USB_SPEED_UNKNOWN)
+       max_speed = usb_get_maximum_speed(&qcom->dwc3->dev);
+       if (max_speed >= USB_SPEED_SUPER || max_speed == USB_SPEED_UNKNOWN)
                ret = icc_set_bw(qcom->icc_path_ddr,
                        USB_MEMORY_AVG_SS_BW, USB_MEMORY_PEAK_SS_BW);
        else