Re: [PATCH] usb: dwc3: make macros safe to expression arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

On 4/6/2017 1:17 PM, Felipe Balbi wrote:

From: Roger Quadros <rogerq@xxxxxx>

We must make sure that our macros are safe against expressions passed
as arguments. We have see one problem where GTXFIFOSIZ(n) was failling

   "Seen" and "failing".

when passed the expression (epnum >> 1) as argument. The problem was
caused by operator precedence between >> and *.

To make sure macros are safe, we just wrap argument with () when using
it.

Signed-off-by: Roger Quadros <rogerq@xxxxxx>
Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx>
---

As discussed over IRC, Roger figured out what was the problem
with "Bryan's patch". It turns out that GTXFIFOSIZ() macro wasn't
safe against expression arguments.

Roger provided a patch, which I'm now sending to linux-usb in his
regard.

 drivers/usb/dwc3/core.h | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 459ecf3afa48..8a0fbcd99638 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
[...]
@@ -460,7 +460,7 @@
 #define DWC3_DEPCMD_CMD(x)		((x) & 0xf)

 /* The EP number goes 0..31 so ep0 is always out and ep1 is always in */
-#define DWC3_DALEPENA_EP(n)		BIT(n)
+#define DWC3_DALEPENA_EP(n)		BIT((n))

   Why do we need double parens?

[...]

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux