[U-Boot] [PATCH v3 1/8] ehci: cosmetic: Define used constants

Marek Vasut marex at denx.de
Fri Aug 10 03:12:12 CEST 2012


Dear Benoît Thébaudeau,

> Dear Marek Vasut,
> 
> > > > > > > @@ -246,19 +247,20 @@ ehci_submit_async(struct usb_device
> > > > > > > *dev,
> > > > > > > unsigned
> > > > > > > long pipe, void *buffer, */
> > > > > > > 
> > > > > > >  	qh->qh_link = cpu_to_hc32((uint32_t)qh_list |
> > > > > > >  	QH_LINK_TYPE_QH);
> > > > > > >  	c = (usb_pipespeed(pipe) != USB_SPEED_HIGH &&
> > > > > > > 
> > > > > > > -	     usb_pipeendpoint(pipe) == 0) ? 1 : 0;
> > > > > > > -	endpt = (8 << 28) |
> > > > > > > -	    (c << 27) |
> > > > > > > -	    (usb_maxpacket(dev, pipe) << 16) |
> > > > > > > -	    (0 << 15) |
> > > > > > > -	    (1 << 14) |
> > > > > > > -	    (usb_pipespeed(pipe) << 12) |
> > > > > > > -	    (usb_pipeendpoint(pipe) << 8) |
> > > > > > > -	    (0 << 7) | (usb_pipedevice(pipe) << 0);
> > > > > > > +	     usb_pipeendpoint(pipe) == 0);
> > > > > > > +	endpt = (8 << QH_ENDPT1_RL) |
> > > > > > > +	    (c << QH_ENDPT1_C) |
> > > > > > 
> > > > > > Maybe define it as #deifne QH_ENDPT1(x) ((x) << SEOMTHING) ?
> > > > > > [...]
> > > > > 
> > > > > For all of these?
> > > > 
> > > > Yes, do you not think it's better than define the offsets only?
> > > 
> > > Yes, I hesitated with this solution when writing this code.
> > > 
> > > Where the offset is needed, I can instead write additional
> > > extraction
> > > macros.
> > 
> > Oh, there're places where the offset is needed?
> 
> Yes, I think.
> 
> > What about adding
> > both BIT(x)
> > and BIT_OFFSET in such cases ? And BIT(x) (x << BIT_OFFSET) in that
> > case.
> 
> I would prefer:
> #define FIELD(fldval)     (((fldval) & MASK) << OFFSET)
> #define GET_FIELD(regval) (((regval) >> OFFSET) & MASK)

Yes of course.

> Are you OK with that?
> 
> Best regards,
> Benoît

Best regards,
Marek Vasut


More information about the U-Boot mailing list