Commit d6d4f980 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] Use wipe_partitions() where appropriate

a bunch of places doing invalidate_device() either didn't need it at all
or actually wanted wipe_partitions().  Switched.
parent a4dea1b6
......@@ -1442,12 +1442,7 @@ static int mfm_reread_partitions(kdev_t dev)
maxp = 1 << mfm_gendisk.minor_shift;
start = target << mfm_gendisk.minor_shift;
for (i = maxp - 1; i >= 0; i--) {
int minor = start + i;
invalidate_device (mk_kdev(MAJOR_NR, minor), 1);
mfm_gendisk.part[minor].start_sect = 0;
mfm_gendisk.part[minor].nr_sects = 0;
}
wipe_partitions(mk_kdev(MAJOR_NR, start));
/* Divide by 2, since sectors are 2 times smaller than usual ;-) */
......
......@@ -860,18 +860,9 @@ static int deregister_disk(int ctlr, int logvol)
/* invalidate the devices and deregister the disk */
max_p = 1 << gdev->minor_shift;
start = logvol << gdev->minor_shift;
wipe_partitions(mk_kdev(MAJOR_NR+ctlr, start));
for (i=max_p-1; i>=0; i--)
{
int minor = start+i;
kdev_t kdev = mk_kdev(MAJOR_NR+ctlr, minor);
// printk("invalidating( %d %d)\n", ctlr, minor);
invalidate_device(kdev, 1);
/* so open will now fail */
h->sizes[minor] = 0;
/* so it will no longer appear in /proc/partitions */
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
}
h->sizes[start + i] = 0;
/* check to see if it was the last disk */
if (logvol == h->highest_lun)
{
......@@ -1314,13 +1305,7 @@ static int register_new_disk(kdev_t dev, int ctlr)
max_p = 1 << gdev->minor_shift;
start = logvol<< gdev->minor_shift;
for(i=max_p-1; i>=0; i--) {
int minor = start+i;
kdev = mk_kdev(MAJOR_NR + ctlr, minor);
invalidate_device(kdev, 1);
gdev->part[minor].start_sect = 0;
gdev->part[minor].nr_sects = 0;
}
wipe_partitions(MAJOR_NR + ctlr, start);
++hba[ctlr]->num_luns;
gdev->nr_real = hba[ctlr]->highest_lun + 1;
......
......@@ -65,7 +65,7 @@
#define MM_BLKSIZE 1024 /* 1k blocks */
#define MM_HARDSECT 512 /* 512-byte hardware sectors */
#define MM_SHIFT 6 /* max 64 partitions on 4 cards */
#define DEVICE_NR(device) (MINOR(device)>>MM_SHIFT)
#define DEVICE_NR(device) (minor(device)>>MM_SHIFT)
/*
* Version Information
......@@ -150,7 +150,6 @@ struct cardinfo {
unsigned long last_change;
} battery[2];
atomic_t usage;
spinlock_t lock;
int check_batteries;
......@@ -818,7 +817,7 @@ static int mm_revalidate(kdev_t i_rdev)
{
int i;
int card_number = DEVICE_NR(kdev_val(i_rdev));
int card_number = DEVICE_NR(i_rdev);
/* first partition, # of partitions */
int part1 = (card_number << MM_SHIFT) + 1;
int npart = (1 << MM_SHIFT) -1;
......@@ -905,7 +904,7 @@ static int mm_ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned
*/
static int mm_check_change(kdev_t i_rdev)
{
int card_number = DEVICE_NR(kdev_val(i_rdev));
int card_number = DEVICE_NR(i_rdev);
/* struct cardinfo *dev = cards + card_number; */
if (card_number >= num_cards) /* paranoid */
return 0;
......@@ -920,18 +919,8 @@ static int mm_check_change(kdev_t i_rdev)
*/
static int mm_open(struct inode *i, struct file *filp)
{
int num;
struct cardinfo *card;
num = DEVICE_NR(kdev_val(i->i_rdev));
if (num >= num_cards)
if (DEVICE_NR(i->i_rdev) >= num_cards)
return -ENXIO;
card = cards + num;
atomic_inc(&card->usage);
MOD_INC_USE_COUNT;
return 0;
}
/*
......@@ -941,17 +930,6 @@ static int mm_open(struct inode *i, struct file *filp)
*/
static int mm_do_release(struct inode *i, struct file *filp)
{
int num;
struct cardinfo *card;
num = DEVICE_NR(kdev_val(i->i_rdev));
card = cards + num;
if (atomic_dec_and_test(&card->usage))
invalidate_device(i->i_rdev, 1);
MOD_DEC_USE_COUNT;
return 0;
}
/*
......@@ -1243,7 +1221,7 @@ static struct pci_driver mm_pci_driver = {
static request_queue_t * mm_queue_proc(kdev_t dev)
{
int c = DEVICE_NR(kdev_val(dev));
int c = DEVICE_NR(dev);
if (c < MM_MAXCARDS)
return &cards[c].queue;
......@@ -1293,7 +1271,6 @@ int __init mm_init(void)
blk_dev[MAJOR_NR].queue = mm_queue_proc;
add_gendisk(&mm_gendisk);
blk_size[MAJOR_NR] = mm_gendisk.sizes;
for (i = 0; i < num_cards; i++) {
register_disk(&mm_gendisk, mk_kdev(MAJOR_NR, i<<MM_SHIFT), MM_SHIFT,
&mm_fops, cards[i].mm_size << 1);
......@@ -1325,9 +1302,6 @@ void __exit mm_cleanup(void)
unregister_blkdev(MAJOR_NR, "umem");
for (i = 0; i < (num_cards << MM_SHIFT); i++)
invalidate_device (mk_kdev(MAJOR_NR,i), 1);
blk_size [MAJOR_NR] = NULL;
/*
......
......@@ -1050,13 +1050,7 @@ static int do_i2ob_revalidate(kdev_t dev, int maxu)
return -EBUSY;
}
for( i = 15; i>=0 ; i--)
{
int m = minor+i;
invalidate_device(mk_kdev(MAJOR_NR, m), 1);
i2ob_gendisk.part[m].start_sect = 0;
i2ob_gendisk.part[m].nr_sects = 0;
}
wipe_partitions(mk_kdev(MAJOR_NR, minor), 1);
/*
* Do a physical check and then reconfigure
......@@ -1815,7 +1809,6 @@ int i2o_block_init(void)
* Now fill in the boiler plate
*/
blk_size[MAJOR_NR] = i2ob_sizes;
blk_dev[MAJOR_NR].queue = i2ob_get_queue;
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), i2ob_request);
......
......@@ -880,9 +880,6 @@ static release_t ftl_close(struct inode *inode, struct file *file)
DEBUG(0, "ftl_cs: ftl_close(%d)\n", minor);
/* Flush all writes */
invalidate_device(inode->i_rdev, 1);
/* Wait for any pending erase operations to complete */
if (part->mtd->sync)
part->mtd->sync(part->mtd);
......
......@@ -354,8 +354,6 @@ static release_t mtdblock_release(struct inode *inode, struct file *file)
if (inode == NULL)
release_return(-ENODEV);
invalidate_device(inode->i_rdev, 1);
dev = minor(inode->i_rdev);
mtdblk = mtdblks[dev];
......
......@@ -76,8 +76,6 @@ static release_t mtdblock_release(struct inode *inode, struct file *file)
if (inode == NULL)
release_return(-ENODEV);
invalidate_device(inode->i_rdev, 1);
dev = minor(inode->i_rdev);
mtd = __get_mtd_device(NULL, dev);
......
......@@ -970,8 +970,6 @@ static int nftl_release(struct inode *inode, struct file *fp)
DEBUG(MTD_DEBUG_LEVEL2, "NFTL_release\n");
invalidate_device(inode->i_rdev, 1);
if (thisNFTL->mtd->sync)
thisNFTL->mtd->sync(thisNFTL->mtd);
thisNFTL->usecount--;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment