Re: [PATCH v2 1/2] dmaengine: Add an enum for the dmaengine alignment constraints

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

 



On Mon, Jul 20, 2015 at 11:03:25AM +0200, Thomas Petazzoni wrote:
> Maxime,
> 
> On Mon, 20 Jul 2015 10:41:32 +0200, Maxime Ripard wrote:
> 
> >  /**
> > + * enum dmaengine_alignment - defines alignment of the DMA async tx
> > + * buffers
> > + */
> > +enum dmaengine_alignment {
> > +	DMAENGINE_ALIGN_1_BYTE = 0,
> > +	DMAENGINE_ALIGN_2_BYTES = 1,
> > +	DMAENGINE_ALIGN_4_BYTES = 2,
> > +	DMAENGINE_ALIGN_8_BYTES = 3,
> > +	DMAENGINE_ALIGN_16_BYTES = 4,
> > +	DMAENGINE_ALIGN_32_BYTES = 5,
> > +	DMAENGINE_ALIGN_64_BYTES = 6,
> > +};
> 
> Sorry I didn't think about this during the first iteration, but this
> define is just the log2 of the values, no? So maybe you could simply do
> something like:
> 
> static inline unsigned int dmaengine_alignment(size_t bytes)
> {
> 	return ilog2(bytes);
> }

I could, but all the rest of the other similar case so far in
dmaengine are made through enum, so I guess it's still better for
consistency. And we also provide a comprehensive list of the valid
values this way, something a function would not provide (or at least
not at compilation time)

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux