Usage counter for ide-cd module

Alain Knaff (Alain.Knaff@imag.fr)
Wed, 13 Nov 1996 00:21:25 +0100


When compiling IDE CD support as a module, and mounting a CDROM,
kerneld will remove the driver after a while, even when the CDROM is
still mounted. I traced this back to a missing usage counter
incrementation. The following patch should fix this problem:

diff -ur 2.1.9/linux/drivers/block/ide-cd.c linux/drivers/block/ide-cd.c
--- 2.1.9/linux/drivers/block/ide-cd.c Tue Nov 12 23:31:44 1996
+++ linux/drivers/block/ide-cd.c Tue Nov 12 23:39:36 1996
@@ -2765,13 +2765,19 @@

int ide_cdrom_open (struct inode *ip, struct file *fp, ide_drive_t *drive)
{
- return cdrom_fops.open (ip, fp);
+ int r;
+ MOD_INC_USE_COUNT;
+ r = cdrom_fops.open (ip, fp);
+ if(r)
+ MOD_DEC_USE_COUNT;
+ return r;
}

void ide_cdrom_release (struct inode *inode, struct file *file,
ide_drive_t *drive)
{
cdrom_fops.release (inode, file);
+ MOD_DEC_USE_COUNT;
}

int ide_cdrom_check_media_change (ide_drive_t *drive)

Regards,

Alain