Hi, Sergei Shtylyov <sergei.shtylyov@xxxxxxxxxxxxxxxxxx> writes: > 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? I don't know (i.e. don't wanna care) how BIT() is implemented. But I still want to be able to: DWC3_DALEPENA_EP(dwc->num_eps - (dep->epnum >> 1) + whatever_number_I_want); -- balbi
Attachment:
signature.asc
Description: PGP signature