[linux-dvb] [PATCH] Moving ALPS BSRV2 tuner handling code to separate file.

Trent Piepho xyzzy at speakeasy.org
Sat Apr 15 22:33:18 CEST 2006


On Sat, 15 Apr 2006, Michael Krufky wrote:
> I'd like to make another point:
>
> If we are putting these commonly used fuctions into nim-specific header
> files, we STILL end up with duplicated binary code.  Since all of the
> code is now in these small header files, the c code is no longer
> duplicated, however, these functions are still being compiled staticly
> into each driver that uses them.
>
> I propose the following:
>
> We should apply Perceval's patch, but instead of creating "bsrv2.h" ,
> that we instead call it, "nim_bsrv2.c", and then we should create a
[...]
>
> This way, instead of the same code being statically compiled into each
> driver, we could compile them once as a module, and have that code
> reused by the other drivers.

This would give you a lot of tiny little modules.  A driver would of course
need to load the modules for every single tuner it supported.  That's going
to be cumbersome, and all that module overhead might well add up to more
than any savings.

What about doing things the old fashioned way, with a library?  Stick all the
nim (WTF is nim?) code into a directory, one nim per c file, and compile them
all into a nim.a library.  Then each driver can link against nim.a and will
get the nim functions it needs, and not the ones it doesn't.  The prototypes
could be in a single nim.h, or in nim_{foo,bar,baz}.h for each nim.

Upside:
The code is in just one place.  It's in c files are not header files (IMHO,
code in headers is a bad practice).  Each driver has just the code it needs
and no more, done automatically by the linker.  You don't have any extra
modules to deal with or any extra module overhead.

Downside:
Each driver has another copy of the code it uses.  If a FEs is used by more
than one driver and the kernel loads both those drivers, then you have two
copies of the code in memory.  Realistically, not that many users have
multiple different DVB cards.  Even for the few that do, the code duplication
is probably less than the overhead of a dozen new modules.



More information about the linux-dvb mailing list