Skip to content

Commit

Permalink
swim: simplify media change handling
Browse files Browse the repository at this point in the history
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: Christoph Hellwig <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Sep 10, 2020
1 parent 7fe76fc commit 433d21c
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions drivers/block/swim.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ extern int swim_read_sector_header(struct swim __iomem *base,
extern int swim_read_sector_data(struct swim __iomem *base,
unsigned char *data);

static int floppy_revalidate(struct gendisk *disk);

static DEFINE_MUTEX(swim_mutex);
static inline void set_swim_mode(struct swim __iomem *base, int enable)
{
Expand Down Expand Up @@ -640,8 +638,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
return 0;

if (mode & (FMODE_READ|FMODE_WRITE)) {
if (bdev_check_media_change(bdev))
floppy_revalidate(bdev->bd_disk);
if (bdev_check_media_change(bdev) && fs->disk_in)
fs->ejected = 0;
if ((mode & FMODE_WRITE) && fs->write_protected) {
err = -EROFS;
goto out;
Expand Down Expand Up @@ -738,24 +736,6 @@ static unsigned int floppy_check_events(struct gendisk *disk,
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 = {
.owner = THIS_MODULE,
.open = floppy_unlocked_open,
Expand Down

0 comments on commit 433d21c

Please sign in to comment.