Commit bab73009 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Linus Torvalds

[PATCH] do not scan partitions twice for removable devices

fixes kobject_register() oops
parent fc8183c1
...@@ -1790,6 +1790,12 @@ static int idedisk_ioctl(struct inode *inode, struct file *file, ...@@ -1790,6 +1790,12 @@ static int idedisk_ioctl(struct inode *inode, struct file *file,
static int idedisk_media_changed(struct gendisk *disk) static int idedisk_media_changed(struct gendisk *disk)
{ {
ide_drive_t *drive = disk->private_data; 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 */ /* if removable, always assume it was changed */
return drive->removable; return drive->removable;
} }
...@@ -1848,6 +1854,7 @@ static int idedisk_attach(ide_drive_t *drive) ...@@ -1848,6 +1854,7 @@ static int idedisk_attach(ide_drive_t *drive)
g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0; g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0;
set_capacity(g, current_capacity(drive)); set_capacity(g, current_capacity(drive));
g->fops = &idedisk_ops; g->fops = &idedisk_ops;
drive->attach = 1;
add_disk(g); add_disk(g);
return 0; return 0;
failed: failed:
......
...@@ -2006,7 +2006,12 @@ static int idefloppy_media_changed(struct gendisk *disk) ...@@ -2006,7 +2006,12 @@ static int idefloppy_media_changed(struct gendisk *disk)
{ {
ide_drive_t *drive = disk->private_data; ide_drive_t *drive = disk->private_data;
idefloppy_floppy_t *floppy = drive->driver_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); return test_and_clear_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags);
} }
...@@ -2061,6 +2066,7 @@ static int idefloppy_attach (ide_drive_t *drive) ...@@ -2061,6 +2066,7 @@ static int idefloppy_attach (ide_drive_t *drive)
strcpy(g->devfs_name, drive->devfs_name); strcpy(g->devfs_name, drive->devfs_name);
g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0; g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0;
g->fops = &idefloppy_ops; g->fops = &idefloppy_ops;
drive->attach = 1;
add_disk(g); add_disk(g);
return 0; return 0;
failed: failed:
......
...@@ -711,6 +711,7 @@ typedef struct ide_drive_s { ...@@ -711,6 +711,7 @@ typedef struct ide_drive_s {
unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */ unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */
unsigned noprobe : 1; /* from: hdx=noprobe */ unsigned noprobe : 1; /* from: hdx=noprobe */
unsigned removable : 1; /* 1 if need to do check_media_change */ 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 is_flash : 1; /* 1 if probed as flash */
unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */ unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */
unsigned no_unmask : 1; /* disallow setting unmask bit */ unsigned no_unmask : 1; /* disallow setting unmask bit */
......
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