Merge branch 'for-jens' of git://git.drbd.org/linux-drbd into for-3.6/drivers
[pandora-kernel.git] / drivers / block / floppy.c
index 48e1d70..8d4afc8 100644 (file)
@@ -191,6 +191,7 @@ static int print_unex = 1;
 #include <linux/mutex.h>
 #include <linux/io.h>
 #include <linux/uaccess.h>
+#include <linux/async.h>
 
 /*
  * PS/2 floppies have much slower step rates than regular floppies.
@@ -671,6 +672,7 @@ static void __reschedule_timeout(int drive, const char *message)
 
        if (drive == current_reqD)
                drive = current_drive;
+       __cancel_delayed_work(&fd_timeout);
 
        if (drive < 0 || drive >= N_DRIVE) {
                delay = 20UL * HZ;
@@ -3607,9 +3609,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
 
        mutex_lock(&floppy_mutex);
        mutex_lock(&open_lock);
-       if (UDRS->fd_ref < 0)
-               UDRS->fd_ref = 0;
-       else if (!UDRS->fd_ref--) {
+       if (!UDRS->fd_ref--) {
                DPRINT("floppy_release with fd_ref == 0");
                UDRS->fd_ref = 0;
        }
@@ -3645,13 +3645,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
                set_bit(FD_VERIFY_BIT, &UDRS->flags);
        }
 
-       if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (mode & FMODE_EXCL)))
-               goto out2;
-
-       if (mode & FMODE_EXCL)
-               UDRS->fd_ref = -1;
-       else
-               UDRS->fd_ref++;
+       UDRS->fd_ref++;
 
        opened_bdev[drive] = bdev;
 
@@ -3714,10 +3708,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
        mutex_unlock(&floppy_mutex);
        return 0;
 out:
-       if (UDRS->fd_ref < 0)
-               UDRS->fd_ref = 0;
-       else
-               UDRS->fd_ref--;
+       UDRS->fd_ref--;
+
        if (!UDRS->fd_ref)
                opened_bdev[drive] = NULL;
 out2:
@@ -4132,7 +4124,7 @@ static struct kobject *floppy_find(dev_t dev, int *part, void *data)
        return get_disk(disks[drive]);
 }
 
-static int __init floppy_init(void)
+static int __init do_floppy_init(void)
 {
        int i, unit, drive;
        int err, dr;
@@ -4347,6 +4339,24 @@ out_put_disk:
        return err;
 }
 
+#ifndef MODULE
+static __init void floppy_async_init(void *data, async_cookie_t cookie)
+{
+       do_floppy_init();
+}
+#endif
+
+static int __init floppy_init(void)
+{
+#ifdef MODULE
+       return do_floppy_init();
+#else
+       /* Don't hold up the bootup by the floppy initialization */
+       async_schedule(floppy_async_init, NULL);
+       return 0;
+#endif
+}
+
 static const struct io_region {
        int offset;
        int size;