Skip to content

Commit cedd120

Browse files
committed
ide-disk: use IDE_DFLAG_MEDIA_CHANGED
Set IDE_DFLAG_MEDIA_CHANGED in ide_gd_open() to signalize ide_gd_media_changed() that that media has changed (instead of relying on IDE_DFLAG_REMOVABLE). There should be no functional changes caused by this patch. Acked-by: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent 5fef0e5 commit cedd120

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎drivers/ide/ide-gd.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ static int ide_gd_open(struct inode *inode, struct file *filp)
160160
* and the door_lock is irrelevant at this point.
161161
*/
162162
ide_disk_set_doorlock(drive, 1);
163+
drive->dev_flags |= IDE_DFLAG_MEDIA_CHANGED;
163164
check_disk_change(inode->i_bdev);
164165
}
165166
return 0;
@@ -199,15 +200,18 @@ static int ide_gd_media_changed(struct gendisk *disk)
199200
{
200201
struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
201202
ide_drive_t *drive = idkp->drive;
203+
int ret;
202204

203205
/* do not scan partitions twice if this is a removable device */
204206
if (drive->dev_flags & IDE_DFLAG_ATTACH) {
205207
drive->dev_flags &= ~IDE_DFLAG_ATTACH;
206208
return 0;
207209
}
208210

209-
/* if removable, always assume it was changed */
210-
return !!(drive->dev_flags & IDE_DFLAG_REMOVABLE);
211+
ret = !!(drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED);
212+
drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED;
213+
214+
return ret;
211215
}
212216

213217
static int ide_gd_revalidate_disk(struct gendisk *disk)

0 commit comments

Comments
 (0)