aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-03-09 13:54:27 -0500
committerTejun Heo <tj@kernel.org>2011-03-09 13:54:27 -0500
commit1a8a74f03fcde1725ff26520220f3d21dbd8faa1 (patch)
tree5ac4195f4b34f815261ec243357f81967e4384c0
parent5b03a1b140e13a28ff6be1526892a9dc538ddef6 (diff)
floppy,{ami|ata}flop: Convert to bdops->check_events()
Convert the floppy drivers from ->media_changed() to ->check_events(). Both floppy and ataflop buffer media changed state bit and clear them on revalidation and will behave correctly with kernel event polling. I can't tell how amiflop clears its event and it's possible that it may generate spurious events when polled. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: Kay Sievers <kay.sievers@vrfy.org>
-rw-r--r--drivers/block/amiflop.c9
-rw-r--r--drivers/block/ataflop.c14
-rw-r--r--drivers/block/floppy.c10
3 files changed, 19 insertions, 14 deletions
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 7888501ad9ee..5e7d3fe2c13b 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1658,12 +1658,12 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
1658} 1658}
1659 1659
1660/* 1660/*
1661 * floppy-change is never called from an interrupt, so we can relax a bit 1661 * check_events is never called from an interrupt, so we can relax a bit
1662 * here, sleep etc. Note that floppy-on tries to set current_DOR to point 1662 * here, sleep etc. Note that floppy-on tries to set current_DOR to point
1663 * to the desired drive, but it will probably not survive the sleep if 1663 * to the desired drive, but it will probably not survive the sleep if
1664 * several floppies are used at the same time: thus the loop. 1664 * several floppies are used at the same time: thus the loop.
1665 */ 1665 */
1666static int amiga_floppy_change(struct gendisk *disk) 1666static unsigned amiga_check_events(struct gendisk *disk, unsigned int clearing)
1667{ 1667{
1668 struct amiga_floppy_struct *p = disk->private_data; 1668 struct amiga_floppy_struct *p = disk->private_data;
1669 int drive = p - unit; 1669 int drive = p - unit;
@@ -1686,7 +1686,7 @@ static int amiga_floppy_change(struct gendisk *disk)
1686 p->dirty = 0; 1686 p->dirty = 0;
1687 writepending = 0; /* if this was true before, too bad! */ 1687 writepending = 0; /* if this was true before, too bad! */
1688 writefromint = 0; 1688 writefromint = 0;
1689 return 1; 1689 return DISK_EVENT_MEDIA_CHANGE;
1690 } 1690 }
1691 return 0; 1691 return 0;
1692} 1692}
@@ -1697,7 +1697,7 @@ static const struct block_device_operations floppy_fops = {
1697 .release = floppy_release, 1697 .release = floppy_release,
1698 .ioctl = fd_ioctl, 1698 .ioctl = fd_ioctl,
1699 .getgeo = fd_getgeo, 1699 .getgeo = fd_getgeo,
1700 .media_changed = amiga_floppy_change, 1700 .check_events = amiga_check_events,
1701}; 1701};
1702 1702
1703static int __init fd_probe_drives(void) 1703static int __init fd_probe_drives(void)
@@ -1736,6 +1736,7 @@ static int __init fd_probe_drives(void)
1736 disk->major = FLOPPY_MAJOR; 1736 disk->major = FLOPPY_MAJOR;
1737 disk->first_minor = drive; 1737 disk->first_minor = drive;
1738 disk->fops = &floppy_fops; 1738 disk->fops = &floppy_fops;
1739 disk->events = DISK_EVENT_MEDIA_CHANGE;
1739 sprintf(disk->disk_name, "fd%d", drive); 1740 sprintf(disk->disk_name, "fd%d", drive);
1740 disk->private_data = &unit[drive]; 1741 disk->private_data = &unit[drive];
1741 set_capacity(disk, 880*2); 1742 set_capacity(disk, 880*2);
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 605a67e40bbf..c871eae14120 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -1324,23 +1324,24 @@ static void finish_fdc_done( int dummy )
1324 * due to unrecognised disk changes. 1324 * due to unrecognised disk changes.
1325 */ 1325 */
1326 1326
1327static int check_floppy_change(struct gendisk *disk) 1327static unsigned int floppy_check_events(struct gendisk *disk,
1328 unsigned int clearing)
1328{ 1329{
1329 struct atari_floppy_struct *p = disk->private_data; 1330 struct atari_floppy_struct *p = disk->private_data;
1330 unsigned int drive = p - unit; 1331 unsigned int drive = p - unit;
1331 if (test_bit (drive, &fake_change)) { 1332 if (test_bit (drive, &fake_change)) {
1332 /* simulated change (e.g. after formatting) */ 1333 /* simulated change (e.g. after formatting) */
1333 return 1; 1334 return DISK_EVENT_MEDIA_CHANGE;
1334 } 1335 }
1335 if (test_bit (drive, &changed_floppies)) { 1336 if (test_bit (drive, &changed_floppies)) {
1336 /* surely changed (the WP signal changed at least once) */ 1337 /* surely changed (the WP signal changed at least once) */
1337 return 1; 1338 return DISK_EVENT_MEDIA_CHANGE;
1338 } 1339 }
1339 if (UD.wpstat) { 1340 if (UD.wpstat) {
1340 /* WP is on -> could be changed: to be sure, buffers should be 1341 /* WP is on -> could be changed: to be sure, buffers should be
1341 * invalidated... 1342 * invalidated...
1342 */ 1343 */
1343 return 1; 1344 return DISK_EVENT_MEDIA_CHANGE;
1344 } 1345 }
1345 1346
1346 return 0; 1347 return 0;
@@ -1570,7 +1571,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,
1570 * or the next access will revalidate - and clear UDT :-( 1571 * or the next access will revalidate - and clear UDT :-(
1571 */ 1572 */
1572 1573
1573 if (check_floppy_change(disk)) 1574 if (floppy_check_events(disk, 0))
1574 floppy_revalidate(disk); 1575 floppy_revalidate(disk);
1575 1576
1576 if (UD.flags & FTD_MSG) 1577 if (UD.flags & FTD_MSG)
@@ -1904,7 +1905,7 @@ static const struct block_device_operations floppy_fops = {
1904 .open = floppy_unlocked_open, 1905 .open = floppy_unlocked_open,
1905 .release = floppy_release, 1906 .release = floppy_release,
1906 .ioctl = fd_ioctl, 1907 .ioctl = fd_ioctl,
1907 .media_changed = check_floppy_change, 1908 .check_events = floppy_check_events,
1908 .revalidate_disk= floppy_revalidate, 1909 .revalidate_disk= floppy_revalidate,
1909}; 1910};
1910 1911
@@ -1963,6 +1964,7 @@ static int __init atari_floppy_init (void)
1963 unit[i].disk->first_minor = i; 1964 unit[i].disk->first_minor = i;
1964 sprintf(unit[i].disk->disk_name, "fd%d", i); 1965 sprintf(unit[i].disk->disk_name, "fd%d", i);
1965 unit[i].disk->fops = &floppy_fops; 1966 unit[i].disk->fops = &floppy_fops;
1967 unit[i].disk->events = DISK_EVENT_MEDIA_CHANGE;
1966 unit[i].disk->private_data = &unit[i]; 1968 unit[i].disk->private_data = &unit[i];
1967 unit[i].disk->queue = blk_init_queue(do_fd_request, 1969 unit[i].disk->queue = blk_init_queue(do_fd_request,
1968 &ataflop_lock); 1970 &ataflop_lock);
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 77fc76f8aea9..3851dbc03e05 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3770,13 +3770,14 @@ out2:
3770/* 3770/*
3771 * Check if the disk has been changed or if a change has been faked. 3771 * Check if the disk has been changed or if a change has been faked.
3772 */ 3772 */
3773static int check_floppy_change(struct gendisk *disk) 3773static unsigned int floppy_check_events(struct gendisk *disk,
3774 unsigned int clearing)
3774{ 3775{
3775 int drive = (long)disk->private_data; 3776 int drive = (long)disk->private_data;
3776 3777
3777 if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags) || 3778 if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags) ||
3778 test_bit(FD_VERIFY_BIT, &UDRS->flags)) 3779 test_bit(FD_VERIFY_BIT, &UDRS->flags))
3779 return 1; 3780 return DISK_EVENT_MEDIA_CHANGE;
3780 3781
3781 if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) { 3782 if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) {
3782 lock_fdc(drive, false); 3783 lock_fdc(drive, false);
@@ -3788,7 +3789,7 @@ static int check_floppy_change(struct gendisk *disk)
3788 test_bit(FD_VERIFY_BIT, &UDRS->flags) || 3789 test_bit(FD_VERIFY_BIT, &UDRS->flags) ||
3789 test_bit(drive, &fake_change) || 3790 test_bit(drive, &fake_change) ||
3790 drive_no_geom(drive)) 3791 drive_no_geom(drive))
3791 return 1; 3792 return DISK_EVENT_MEDIA_CHANGE;
3792 return 0; 3793 return 0;
3793} 3794}
3794 3795
@@ -3898,7 +3899,7 @@ static const struct block_device_operations floppy_fops = {
3898 .release = floppy_release, 3899 .release = floppy_release,
3899 .ioctl = fd_ioctl, 3900 .ioctl = fd_ioctl,
3900 .getgeo = fd_getgeo, 3901 .getgeo = fd_getgeo,
3901 .media_changed = check_floppy_change, 3902 .check_events = floppy_check_events,
3902 .revalidate_disk = floppy_revalidate, 3903 .revalidate_disk = floppy_revalidate,
3903}; 3904};
3904 3905
@@ -4205,6 +4206,7 @@ static int __init floppy_init(void)
4205 disks[dr]->major = FLOPPY_MAJOR; 4206 disks[dr]->major = FLOPPY_MAJOR;
4206 disks[dr]->first_minor = TOMINOR(dr); 4207 disks[dr]->first_minor = TOMINOR(dr);
4207 disks[dr]->fops = &floppy_fops; 4208 disks[dr]->fops = &floppy_fops;
4209 disks[dr]->events = DISK_EVENT_MEDIA_CHANGE;
4208 sprintf(disks[dr]->disk_name, "fd%d", dr); 4210 sprintf(disks[dr]->disk_name, "fd%d", dr);
4209 4211
4210 init_timer(&motor_off_timer[dr]); 4212 init_timer(&motor_off_timer[dr]);