diff options
Diffstat (limited to 'drivers/ide/ide-gd.c')
-rw-r--r-- | drivers/ide/ide-gd.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c index 35c4b43585e3..c4ffd4888939 100644 --- a/drivers/ide/ide-gd.c +++ b/drivers/ide/ide-gd.c | |||
@@ -285,11 +285,12 @@ static int ide_gd_getgeo(struct block_device *bdev, struct hd_geometry *geo) | |||
285 | return 0; | 285 | return 0; |
286 | } | 286 | } |
287 | 287 | ||
288 | static int ide_gd_media_changed(struct gendisk *disk) | 288 | static unsigned int ide_gd_check_events(struct gendisk *disk, |
289 | unsigned int clearing) | ||
289 | { | 290 | { |
290 | struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); | 291 | struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); |
291 | ide_drive_t *drive = idkp->drive; | 292 | ide_drive_t *drive = idkp->drive; |
292 | int ret; | 293 | bool ret; |
293 | 294 | ||
294 | /* do not scan partitions twice if this is a removable device */ | 295 | /* do not scan partitions twice if this is a removable device */ |
295 | if (drive->dev_flags & IDE_DFLAG_ATTACH) { | 296 | if (drive->dev_flags & IDE_DFLAG_ATTACH) { |
@@ -297,10 +298,10 @@ static int ide_gd_media_changed(struct gendisk *disk) | |||
297 | return 0; | 298 | return 0; |
298 | } | 299 | } |
299 | 300 | ||
300 | ret = !!(drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED); | 301 | ret = drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED; |
301 | drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED; | 302 | drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED; |
302 | 303 | ||
303 | return ret; | 304 | return ret ? DISK_EVENT_MEDIA_CHANGE : 0; |
304 | } | 305 | } |
305 | 306 | ||
306 | static void ide_gd_unlock_native_capacity(struct gendisk *disk) | 307 | static void ide_gd_unlock_native_capacity(struct gendisk *disk) |
@@ -318,7 +319,7 @@ static int ide_gd_revalidate_disk(struct gendisk *disk) | |||
318 | struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); | 319 | struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); |
319 | ide_drive_t *drive = idkp->drive; | 320 | ide_drive_t *drive = idkp->drive; |
320 | 321 | ||
321 | if (ide_gd_media_changed(disk)) | 322 | if (ide_gd_check_events(disk, 0)) |
322 | drive->disk_ops->get_capacity(drive); | 323 | drive->disk_ops->get_capacity(drive); |
323 | 324 | ||
324 | set_capacity(disk, ide_gd_capacity(drive)); | 325 | set_capacity(disk, ide_gd_capacity(drive)); |
@@ -340,7 +341,7 @@ static const struct block_device_operations ide_gd_ops = { | |||
340 | .release = ide_gd_release, | 341 | .release = ide_gd_release, |
341 | .ioctl = ide_gd_ioctl, | 342 | .ioctl = ide_gd_ioctl, |
342 | .getgeo = ide_gd_getgeo, | 343 | .getgeo = ide_gd_getgeo, |
343 | .media_changed = ide_gd_media_changed, | 344 | .check_events = ide_gd_check_events, |
344 | .unlock_native_capacity = ide_gd_unlock_native_capacity, | 345 | .unlock_native_capacity = ide_gd_unlock_native_capacity, |
345 | .revalidate_disk = ide_gd_revalidate_disk | 346 | .revalidate_disk = ide_gd_revalidate_disk |
346 | }; | 347 | }; |
@@ -412,6 +413,7 @@ static int ide_gd_probe(ide_drive_t *drive) | |||
412 | if (drive->dev_flags & IDE_DFLAG_REMOVABLE) | 413 | if (drive->dev_flags & IDE_DFLAG_REMOVABLE) |
413 | g->flags = GENHD_FL_REMOVABLE; | 414 | g->flags = GENHD_FL_REMOVABLE; |
414 | g->fops = &ide_gd_ops; | 415 | g->fops = &ide_gd_ops; |
416 | g->events = DISK_EVENT_MEDIA_CHANGE; | ||
415 | add_disk(g); | 417 | add_disk(g); |
416 | return 0; | 418 | return 0; |
417 | 419 | ||