From: Adrian M. <zx8...@us...> - 2002-09-16 22:43:11
|
Update of /cvsroot/linuxdc/linux-sh-dc/fs In directory usw-pr-cvs1:/tmp/cvs-serv2238/fs Modified Files: vmuflash-fs.c Log Message: vmuflash fs module now removable Index: vmuflash-fs.c =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/fs/vmuflash-fs.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- vmuflash-fs.c 15 Sep 2002 22:49:27 -0000 1.2 +++ vmuflash-fs.c 16 Sep 2002 22:43:08 -0000 1.3 @@ -180,9 +180,41 @@ int vmufs_release(struct inode *inode, struct file *filp) { + int dev; + struct vmublk_dev *vmublk; + DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n"); + + if (inode == NULL) + release_return(-ENODEV); + + invalidate_device(inode->i_rdev, 1); + + dev = MINOR(inode->i_rdev); + vmublk = vmublks[dev]; + + + spin_lock(&vmublks_lock); + if (!--vmublk->count) { + /* It was the last usage. Free the device */ + vmublks[dev] = NULL; + spin_unlock(&vmublks_lock); + if (vmublk->mtd->sync) + vmublk->mtd->sync(vmublk->mtd); + put_mtd_device(vmublk->mtd); + + kfree(vmublk); + } else { + spin_unlock(&vmublks_lock); + } + + DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); + + release_return(0); + + + - return 1; } @@ -225,9 +257,24 @@ int vmufs_check_change(kdev_t dev) { + /* Has the device been removed or replaced? */ + int minor = MINOR(dev); + struct mtd_info *mtd = get_mtd_device(NULL, minor); + if (!mtd) + return 1; /* No device */ + /* Have a device, but is it the same one? */ + struct vmublk_dev *vmublk; + + vmublk = vmublks[minor]; + if (vmublk->mtd != mtd) { + put_mtd_device(mtd); + return 1; + } + put_mtd_device(mtd); + - return 1; + return 0; /*Same device */ } @@ -235,8 +282,7 @@ { - - return 1; + return 0; /*Doing nothing at present */ } static int get_vmu_device(const struct request *req) @@ -320,9 +366,10 @@ continue; } status = vmufs_transfer(device, CURRENT); - printk("request %p: cmd %i sec %li (nr. %li)\n", CURRENT, - CURRENT->cmd, CURRENT->sector, - CURRENT->current_nr_sectors); + DEBUG(MTD_DEBUG_LEVEL2, + "request %p: cmd %i sec %li (nr. %li)\n", CURRENT, + CURRENT->cmd, CURRENT->sector, + CURRENT->current_nr_sectors); end_request(1); } } |