]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] do not scan partitions twice for removable devices
authorBartlomiej Zolnierkiewicz <b.zolnierkiewicz@elka.pw.edu.pl>
Thu, 7 Aug 2003 03:16:14 +0000 (20:16 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Thu, 7 Aug 2003 03:16:14 +0000 (20:16 -0700)
fixes kobject_register() oops

drivers/ide/ide-disk.c
drivers/ide/ide-floppy.c
include/linux/ide.h

index ef40a6dc71db0fbafe99ba4628b242bc61f053fb..2fecccdf9facc604f570050cb60acaf2cd2ba60e 100644 (file)
@@ -1790,6 +1790,12 @@ static int idedisk_ioctl(struct inode *inode, struct file *file,
 static int idedisk_media_changed(struct gendisk *disk)
 {
        ide_drive_t *drive = disk->private_data;
+
+       /* do not scan partitions twice if this is a removable device */
+       if (drive->attach) {
+               drive->attach = 0;
+               return 0;
+       }
        /* if removable, always assume it was changed */
        return drive->removable;
 }
@@ -1848,6 +1854,7 @@ static int idedisk_attach(ide_drive_t *drive)
        g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0;
        set_capacity(g, current_capacity(drive));
        g->fops = &idedisk_ops;
+       drive->attach = 1;
        add_disk(g);
        return 0;
 failed:
index 3efd052fe5888ce922a815abfc60a9ef8449824f..2c14e13668bc10c2f2827375301a7babcfdf4a4c 100644 (file)
@@ -2006,7 +2006,12 @@ static int idefloppy_media_changed(struct gendisk *disk)
 {
        ide_drive_t *drive = disk->private_data;
        idefloppy_floppy_t *floppy = drive->driver_data;
-       
+
+       /* do not scan partitions twice if this is a removable device */
+       if (drive->attach) {
+               drive->attach = 0;
+               return 0;
+       }
        return test_and_clear_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags);
 }
 
@@ -2061,6 +2066,7 @@ static int idefloppy_attach (ide_drive_t *drive)
        strcpy(g->devfs_name, drive->devfs_name);
        g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0;
        g->fops = &idefloppy_ops;
+       drive->attach = 1;
        add_disk(g);
        return 0;
 failed:
index 86bfa8b02767fa778f7dd83b9327bd198c3bb2fa..ae1459a53dd063f70b4ca439cd0c0e8150f43fae 100644 (file)
@@ -711,6 +711,7 @@ typedef struct ide_drive_s {
        unsigned id_read        : 1;    /* 1=id read from disk 0 = synthetic */
        unsigned noprobe        : 1;    /* from:  hdx=noprobe */
        unsigned removable      : 1;    /* 1 if need to do check_media_change */
+       unsigned attach         : 1;    /* needed for removable devices */
        unsigned is_flash       : 1;    /* 1 if probed as flash */
        unsigned forced_geom    : 1;    /* 1 if hdx=c,h,s was given at boot */
        unsigned no_unmask      : 1;    /* disallow setting unmask bit */