Re: [PATCH 4/7] staging: nvec: add NVEC_CALL helper macro

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

 



On Thu, Jun 14, 2012 at 03:09:38PM -0700, Greg KH wrote:
> On Thu, Jun 14, 2012 at 11:57:38PM +0200, Marc Dietrich wrote:
> > Add a helper macro to wrap nvec_{a}sync_writes and to get rid of
> > the various strings distributed all over the nvec code.
> 
> Why can't these be inline functions instead?  That will catch errors
> easier, and make it a bit more "obvious" as to what is going on (hint, I
> have no idea in reading these what they are doing...)

They are not really obvious, but they kind of catch more errors and are shorter to
writer. A nvec "call" consists of a type, a subtype and a payload, so
the calls expand like this:

    nvec_write_async(nvec, {NVEC_FOO, NVEC_FOO_BAR, ...}, length of ... + 2)
    NVEC_CALL(nvec, FOO, BAR, ...)

With an inline function, you would have to use arrays (as nvec_write_async()
does) or variable arguments lists which are not as optimizable, and you would
need to repeat NVEC all over the place. For example, with an inline function
instead of a macro:

    nvec_call(nvec, NVEC_FOO, NVEC_FOO_BAR, [size here?], ...)

This manual size tracking also makes it less reliable.

-- 
Julian Andres Klode  - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux