Revert "floppy: refactor open() flags handling"
authorJens Axboe <axboe@fb.com>
Thu, 25 Aug 2016 14:56:51 +0000 (08:56 -0600)
committerJens Axboe <axboe@fb.com>
Thu, 25 Aug 2016 14:56:51 +0000 (08:56 -0600)
This reverts commit 09954bad448791ef01202351d437abdd9497a804.

drivers/block/floppy.c

index c557057fe8ae05fd3ce2f93dc8f0c801083cb24f..e3d8e4ced4a23c57d1f36da593e80a64d8b1d142 100644 (file)
@@ -3663,11 +3663,6 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
 
        opened_bdev[drive] = bdev;
 
-       if (!(mode & (FMODE_READ|FMODE_WRITE))) {
-               res = -EINVAL;
-               goto out;
-       }
-
        res = -ENXIO;
 
        if (!floppy_track_buffer) {
@@ -3711,20 +3706,21 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
        if (UFDCS->rawcmd == 1)
                UFDCS->rawcmd = 2;
 
-       UDRS->last_checked = 0;
-       clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags);
-       check_disk_change(bdev);
-       if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags))
-               goto out;
-       if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags))
-               goto out;
-
-       res = -EROFS;
-
-       if ((mode & FMODE_WRITE) &&
-                       !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags))
-               goto out;
-
+       if (!(mode & FMODE_NDELAY)) {
+               if (mode & (FMODE_READ|FMODE_WRITE)) {
+                       UDRS->last_checked = 0;
+                       clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags);
+                       check_disk_change(bdev);
+                       if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags))
+                               goto out;
+                       if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags))
+                               goto out;
+               }
+               res = -EROFS;
+               if ((mode & FMODE_WRITE) &&
+                   !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags))
+                       goto out;
+       }
        mutex_unlock(&open_lock);
        mutex_unlock(&floppy_mutex);
        return 0;