[linux-dvb] idea on how to break the static dependencies on demodulator modules

Trent Piepho xyzzy at speakeasy.org
Wed Apr 26 23:59:07 CEST 2006

On Tue, 25 Apr 2006, Andrew de Quincey wrote:
> This has had the various feedbacks from various people applied - let me know
> what you think.

I haven't tested this, but what about using this for dvb_attach:

#define dvb_attach(FUNCTION, ARGS...) ({ \
    struct dvb_frontend *__r = NULL; \
    typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
    if (__a) { \
        if (!(__r = __a(ARGS))) symbol_put(FUNCTION); \
    } else printk(KERN_ERR "DVB: Unable to get function "#FUNCTION"()\n"); \
    __r; \

The idea is to use symbol_request, which will try to get the symbol, and if
it's not there and module loading is enabled, it will try to load the module
it is in.  You don't need to specify the module name manually, modprobe knows
which module exports which symbols.  Modules can be renamed, split, combined,
etc. without having to fix all the module names in the card drivers.  It
also doesn't call request_module() if it's not necessary.

More information about the linux-dvb mailing list