From: Paul M. <pm...@mv...> - 2001-11-22 00:19:16
|
On Wed, Nov 21, 2001 at 08:58:06PM +0000, Adrian McMenamin wrote: > But rmmod produces "Device busy" error message. >=20 This is to be expected.. as you're misusing MOD_{INC,DEC}_USE_COUNT. > Any ideas? Is it simply because this is not a properly registered driver = yet=20 > - or is there a coding problem? >=20 > Any and all help etc.... >=20 [snip] > static int __init init_aica (void) > { > MOD_INC_USE_COUNT; //increment count [snip] This is not at all what you want to do. You're forcing its usage count up on an initialization even though nothing is actually using it. The proper way = to do this would be to setup an aica_open() and stick your MOD_INC_USE_COUNT in there, and then decrement it on an aico_close(), then hand that off to a fi= le operations structure when you register. > } >=20 > static void __exit exit_aica(void) > { > /*set low bit of register to 1*/ > printk("<1>AICA sound driver being unloaded...\n"); > SET_AICA_REG(0x2c00) |=3D 1; > MOD_DEC_USE_COUNT; > =20 > } >=20 Same deal here, MOD_DEC_USE_COUNT should only ever be used by a close call. Think of the following scenario .. you bring up the device, and open() /dev/dsp .. this should accordingly increment its usage count, as it's in u= se by the application that open()'ed it. Later on .. when you close() the file descriptor, its usage count is decremented. Checking /proc/modules will always report the current status of a module and its usage count.. a module can't be unloaded if it's in use. Regards, --=20 Paul Mundt <pm...@mv...> MontaVista Software, Inc. |