Message ID | 1369930103-11963-2-git-send-email-ludovic.desroches@atmel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thursday 30 May 2013, ludovic.desroches@atmel.com wrote: > +/* > + * Source and/or destination peripheral ID > + */ > +#define AT91_DMA_CFG_PER_ID_MASK (0xff) > +#define AT91_DMA_CFG_PER_ID(id) (id & AT91_DMA_CFG_PER_ID_MASK) > + I'm a little worried about macros like this one spreading in the name of readability, and I don't see this as actual value-add here: The output of the macro is always the same as the input, and passing an invalid number still results in an invalid output and no error message, it actually prevents us from warning about the mistake at run-time. The other macros are fine. Arnd
On Fri, May 31, 2013 at 11:30:29PM +0200, Arnd Bergmann wrote: > On Thursday 30 May 2013, ludovic.desroches@atmel.com wrote: > > +/* > > + * Source and/or destination peripheral ID > > + */ > > +#define AT91_DMA_CFG_PER_ID_MASK (0xff) > > +#define AT91_DMA_CFG_PER_ID(id) (id & AT91_DMA_CFG_PER_ID_MASK) > > + > > I'm a little worried about macros like this one spreading in the name > of readability, and I don't see this as actual value-add here: > > The output of the macro is always the same as the input, and passing > an invalid number still results in an invalid output and no error message, > it actually prevents us from warning about the mistake at run-time. > You are right, this macro is here only for readability in order to not have something like this: dmas = <&dma0 AT91_DMA_CFG_FIFOCFG_ASAP | 13> In this case, I prefer having a macro instead of using a numeric value which can stand for other things than the peripheral id and which could conflict with other parameters such as the FIFO configuration. If adding this macro is really an issue, it could be removed of course but in this case I am in favour of readability. Ludovic > The other macros are fine. > > Arnd
On 03/06/2013 09:32, Ludovic Desroches : > On Fri, May 31, 2013 at 11:30:29PM +0200, Arnd Bergmann wrote: >> On Thursday 30 May 2013, ludovic.desroches@atmel.com wrote: >>> +/* >>> + * Source and/or destination peripheral ID >>> + */ >>> +#define AT91_DMA_CFG_PER_ID_MASK (0xff) >>> +#define AT91_DMA_CFG_PER_ID(id) (id & AT91_DMA_CFG_PER_ID_MASK) >>> + >> >> I'm a little worried about macros like this one spreading in the name >> of readability, and I don't see this as actual value-add here: >> >> The output of the macro is always the same as the input, and passing >> an invalid number still results in an invalid output and no error message, >> it actually prevents us from warning about the mistake at run-time. >> > > You are right, this macro is here only for readability in order to not have > something like this: > > dmas = <&dma0 AT91_DMA_CFG_FIFOCFG_ASAP | 13> > > In this case, I prefer having a macro instead of using a numeric value which > can stand for other things than the peripheral id and which could conflict > with other parameters such as the FIFO configuration. > > If adding this macro is really an issue, it could be removed of course but > in this case I am in favor of readability. Arnd, I think that the case highlighted by Ludovic is indeed a case where someone can be confused by the presentation of data in the cell... even if I like the use of macro as implemented by Ludovic, I do not have a strong opinion about this. Best regards,
diff --git a/include/dt-bindings/dma/at91.h b/include/dt-bindings/dma/at91.h new file mode 100644 index 0000000..e835037 --- /dev/null +++ b/include/dt-bindings/dma/at91.h @@ -0,0 +1,27 @@ +/* + * This header provides macros for at91 dma bindings. + * + * Copyright (C) 2013 Ludovic Desroches <ludovic.desroches@atmel.com> + * + * GPLv2 only + */ + +#ifndef __DT_BINDINGS_AT91_DMA_H__ +#define __DT_BINDINGS_AT91_DMA_H__ + +/* + * Source and/or destination peripheral ID + */ +#define AT91_DMA_CFG_PER_ID_MASK (0xff) +#define AT91_DMA_CFG_PER_ID(id) (id & AT91_DMA_CFG_PER_ID_MASK) + +/* + * FIFO configuration: it defines when a request is serviced. + */ +#define AT91_DMA_CFG_FIFOCFG_OFFSET (8) +#define AT91_DMA_CFG_FIFOCFG_MASK (0xf << AT91_DMA_CFG_FIFOCFG_OFFSET) +#define AT91_DMA_CFG_FIFOCFG_HALF (0x0 << AT91_DMA_CFG_FIFOCFG_OFFSET) /* half FIFO (default behavior) */ +#define AT91_DMA_CFG_FIFOCFG_ALAP (0x1 << AT91_DMA_CFG_FIFOCFG_OFFSET) /* largest defined AHB burst */ +#define AT91_DMA_CFG_FIFOCFG_ASAP (0x2 << AT91_DMA_CFG_FIFOCFG_OFFSET) /* single AHB access */ + +#endif /* __DT_BINDINGS_AT91_DMA_H__ */