Re: GET_USE_COUNT(THIS_MODULE) and i810_rng driver.

From: Jeff Garzik (jgarzik@mandrakesoft.mandrakesoft.com)
Date: Thu Oct 05 2000 - 14:48:06 EST


On Thu, 5 Oct 2000, Tigran Aivazian wrote:
> I tried to compile Jeff's i810_rng driver statically and I can't because
> of a construct like this:
>
> if (GET_USE_COUNT(THIS_MODULE) > 0)
> MOD_DEC_USE_COUNT;
> if (GET_USE_COUNT(THIS_MODULE) == 0)
> rng_hw_enabled = 0;
>
> A similar thing is used by other drivers but always inside #ifdef
> MODULE. The problem here is that if MODULE is not defined then THIS_MODULE
> is just NULL and GET_USE_COUNT(NULL) is not a very wise thing to be used
> in expressions :)
>
> Any ideas what should one do? To enclose the driver's code inside #ifdef
> MODULE (and check all other drivers) or to provide a magic version of
> GET_USE_COUNT() that will be suitable for static case? E.g. 1? Is 1 good
> enough?

FWIW, i810_rng -used- to use an internal variable for 'use_count', and
maintained MOD_{INC,DEC}_USE_COUNT off of that. I decided to get clever
and do the above, thinking that module.h was completely ok for the
non-modular case.

GET_USE_COUNT breaks the build on Alpha (hence the #ifdef). Further,
for this driver at least, it depends on a -working- module count for
all cases, returning 1 would not be sufficient.

prumpf has since sent me a fix patch which goes back to manually
maintaining the use_count for the static case, and that is the solution
I'm going with...

        Jeff

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Oct 07 2000 - 21:00:17 EST