Skip to contentSkip to conversation

usb: dwc2: hcd_queue: Fix use of floating point literal

PATCH In review Nathan Chancellor 3 participants 3 messages Nov 5, 2021 – Nov 8, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: dwc2: hcd_queue: Fix use of floating point literal

A new commit in LLVM causes an error on the use of 'long double' when '-mno-x87' is used, which the kernel does through an alias, '-mno-80387' (see the LLVM commit below for more details around why it does this).

drivers/usb/dwc2/hcd_queue.c:1744:25: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux-gnu' does not support it

                         delay = ktime_set(0, DWC2_RETRY_WAIT_DELAY);
                                             ^
 drivers/usb/dwc2/hcd_queue.c:62:34: note: expanded from macro 'DWC2_RETRY_WAIT_DELAY'
 #define DWC2_RETRY_WAIT_DELAY (1 * 1E6L)
                                 ^

1 error generated.

This happens due to the use of a 'long double' literal. The 'E6' part of '1E6L' causes the literal to be a 'double' then the 'L' suffix promotes it to 'long double'.

There is no visible reason for a floating point value in this driver, as the value is only used as a parameter to a function that expects an integer type. Use NSEC_PER_MSEC, which is the same integer value as '1E6L', to avoid changing functionality but fix the error.

---

v1 -> v2: https://lore.kernel.org/r/[email protected]/

* Use NSEC_PER_MSEC instead of USEC_PER_SEC, as the units of the second parameter of ktime_set is nanoseconds. Thanks to John Keeping for pointing this out.

* Pick up Nick's review tag.

 drivers/usb/dwc2/hcd_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc2/hcd_queue.c +1 -1
index 89a788326c56..24beff610cf2 100644
@@ -59,7 +59,7 @@
 #define DWC2_UNRESERVE_DELAY (msecs_to_jiffies(5))
 
 /* If we get a NAK, wait this long before retrying */
-#define DWC2_RETRY_WAIT_DELAY (1 * 1E6L)
+#define DWC2_RETRY_WAIT_DELAY (1 * NSEC_PER_MSEC)
 
 /**
  * dwc2_periodic_channel_available() - Checks that a channel is available for a

base-commit: d4439a1189f93d0ac1eaf0197db8e6b3e197d5c7

Signature · 1 line
2.34.0.rc0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 22 lines · Nathan Chancellor

A new commit in LLVM causes an error on the use of 'long double' when '-mno-x87' is used, which the kernel does through an alias, '-mno-80387' (see the LLVM commit below for more details around why it does this).

drivers/usb/dwc2/hcd_queue.c:1744:25: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux-gnu' does not support it

                         delay = ktime_set(0, DWC2_RETRY_WAIT_DELAY);
                                             ^
 drivers/usb/dwc2/hcd_queue.c:62:34: note: expanded from macro 'DWC2_RETRY_WAIT_DELAY'
 #define DWC2_RETRY_WAIT_DELAY (1 * 1E6L)
                                 ^

1 error generated.

This happens due to the use of a 'long double' literal. The 'E6' part of '1E6L' causes the literal to be a 'double' then the 'L' suffix promotes it to 'long double'.

There is no visible reason for a floating point value in this driver, as the value is only used as a parameter to a function that expects an integer type. Use NSEC_PER_MSEC, which is the same integer value as '1E6L', to avoid changing functionality but fix the error.

Quoted 5 lines
Quoted 31 lines

---

v1 -> v2: https://lore.kernel.org/r/[email protected]/

* Use NSEC_PER_MSEC instead of USEC_PER_SEC, as the units of the second parameter of ktime_set is nanoseconds. Thanks to John Keeping for pointing this out.

* Pick up Nick's review tag.

 drivers/usb/dwc2/hcd_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc2/hcd_queue.c +1 -1
index 89a788326c56..24beff610cf2 100644
@@ -59,7 +59,7 @@
 #define DWC2_UNRESERVE_DELAY (msecs_to_jiffies(5))
 
 /* If we get a NAK, wait this long before retrying */
-#define DWC2_RETRY_WAIT_DELAY (1 * 1E6L)
+#define DWC2_RETRY_WAIT_DELAY (1 * NSEC_PER_MSEC)
 
 /**
  * dwc2_periodic_channel_available() - Checks that a channel is available for a

base-commit: d4439a1189f93d0ac1eaf0197db8e6b3e197d5c7

Signature · 1 line
2.34.0.rc0
#2 lore raw
Quoted 23 lines · John Keeping
Quoted 22 lines · Nathan Chancellor

A new commit in LLVM causes an error on the use of 'long double' when '-mno-x87' is used, which the kernel does through an alias, '-mno-80387' (see the LLVM commit below for more details around why it does this).

  drivers/usb/dwc2/hcd_queue.c:1744:25: error: expression requires  'long double' type support, but target 'x86_64-unknown-linux-gnu' does not support it
                          delay = ktime_set(0, DWC2_RETRY_WAIT_DELAY);
                                              ^
  drivers/usb/dwc2/hcd_queue.c:62:34: note: expanded from macro 'DWC2_RETRY_WAIT_DELAY'
  #define DWC2_RETRY_WAIT_DELAY (1 * 1E6L)
                                  ^
  1 error generated.

This happens due to the use of a 'long double' literal. The 'E6' part of '1E6L' causes the literal to be a 'double' then the 'L' suffix promotes it to 'long double'.

There is no visible reason for a floating point value in this driver, as the value is only used as a parameter to a function that expects an integer type. Use NSEC_PER_MSEC, which is the same integer value as '1E6L', to avoid changing functionality but fix the error.

Quoted 7 lines
Quoted 5 lines
Quoted 32 lines
Quoted 32 lines

---

v1 -> v2: https://urldefense.com/v3/__https://lore.kernel.org/r/[email protected]/__;!!A4F2R9G_pg!KuhWEjrjOQ8CCBd81IpZ5GxP7Sksp_VESbrQ2QTDnLQBOWN7E1YrD0iJwwZgtI8$

* Use NSEC_PER_MSEC instead of USEC_PER_SEC, as the units of the second parameter of ktime_set is nanoseconds. Thanks to John Keeping for pointing this out.

* Pick up Nick's review tag.

  drivers/usb/dwc2/hcd_queue.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc2/hcd_queue.c +1 -1
index 89a788326c56..24beff610cf2 100644
@@ -59,7 +59,7 @@
  #define DWC2_UNRESERVE_DELAY (msecs_to_jiffies(5))
 
  /* If we get a NAK, wait this long before retrying */
-#define DWC2_RETRY_WAIT_DELAY (1 * 1E6L)
+#define DWC2_RETRY_WAIT_DELAY (1 * NSEC_PER_MSEC)
 
  /**
   * dwc2_periodic_channel_available() - Checks that a channel is available for a

base-commit: d4439a1189f93d0ac1eaf0197db8e6b3e197d5c7

Signature · 1 line
2.34.0.rc0