Commit 433d21ce authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

swim: simplify media change handling

floppy_revalidate mostly duplicates work already done in floppy_open
despite only beeing called from floppy_open.  Remove the function and
just clear the ->ejected flag directly under the right condition.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 7fe76fc0
...@@ -217,8 +217,6 @@ extern int swim_read_sector_header(struct swim __iomem *base, ...@@ -217,8 +217,6 @@ extern int swim_read_sector_header(struct swim __iomem *base,
extern int swim_read_sector_data(struct swim __iomem *base, extern int swim_read_sector_data(struct swim __iomem *base,
unsigned char *data); unsigned char *data);
static int floppy_revalidate(struct gendisk *disk);
static DEFINE_MUTEX(swim_mutex); static DEFINE_MUTEX(swim_mutex);
static inline void set_swim_mode(struct swim __iomem *base, int enable) static inline void set_swim_mode(struct swim __iomem *base, int enable)
{ {
...@@ -640,8 +638,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) ...@@ -640,8 +638,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
return 0; return 0;
if (mode & (FMODE_READ|FMODE_WRITE)) { if (mode & (FMODE_READ|FMODE_WRITE)) {
if (bdev_check_media_change(bdev)) if (bdev_check_media_change(bdev) && fs->disk_in)
floppy_revalidate(bdev->bd_disk); fs->ejected = 0;
if ((mode & FMODE_WRITE) && fs->write_protected) { if ((mode & FMODE_WRITE) && fs->write_protected) {
err = -EROFS; err = -EROFS;
goto out; goto out;
...@@ -738,24 +736,6 @@ static unsigned int floppy_check_events(struct gendisk *disk, ...@@ -738,24 +736,6 @@ static unsigned int floppy_check_events(struct gendisk *disk,
return fs->ejected ? DISK_EVENT_MEDIA_CHANGE : 0; return fs->ejected ? DISK_EVENT_MEDIA_CHANGE : 0;
} }
static int floppy_revalidate(struct gendisk *disk)
{
struct floppy_state *fs = disk->private_data;
struct swim __iomem *base = fs->swd->base;
swim_drive(base, fs->location);
if (fs->ejected)
setup_medium(fs);
if (!fs->disk_in)
swim_motor(base, OFF);
else
fs->ejected = 0;
return !fs->disk_in;
}
static const struct block_device_operations floppy_fops = { static const struct block_device_operations floppy_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = floppy_unlocked_open, .open = floppy_unlocked_open,
......
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