#include <linux/timer.h>
#include <linux/workqueue.h>
#include <linux/version.h>
-#define FDPATCHES
#include <linux/fdreg.h>
+#include <linux/blkdev.h>
+#include <linux/blkpg.h>
+#include <linux/cdrom.h> /* for the compatibility eject ioctl */
+#include <linux/completion.h>
/*
* 1998/1/21 -- Richard Gooch <rgooch@atnf.csiro.au> -- devfs support
#include <linux/fd.h>
#define FLOPPY98_MOTOR_MASK 0x08
-#define FDPATCHES
#include <linux/hdreg.h>
#define FD98_STATUS (0 + FD_IOPORT )
#define FD98_DATA (2 + FD_IOPORT )
*/
static spinlock_t floppy_lock = SPIN_LOCK_UNLOCKED;
+static struct completion device_release;
static unsigned short virtual_dma_port=0x3f0;
-void floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs);
+irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs);
static int set_mode(char mask, char data);
static void register_devfs_entries (int drive) __init;
static DECLARE_WORK(floppy_work, NULL, NULL);
-static void schedule_bh( void (*handler)(void*) )
+static void schedule_bh(void (*handler) (void))
{
- PREPARE_WORK(&floppy_work, handler, NULL);
+ PREPARE_WORK(&floppy_work, (void (*)(void *))handler, NULL);
schedule_work(&floppy_work);
}
}
/* interrupt handler. Note that this can be called externally on the Sparc */
-void floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs)
{
void (*handler)(void) = do_floppy;
int do_print;
printk("floppy interrupt on bizarre fdc %d\n",fdc);
printk("handler=%p\n", handler);
is_alive("bizarre fdc");
- return;
+ return IRQ_NONE;
}
FDCS->reset = 0;
* activity.
*/
- do_print = !handler && !initialising;
+ do_print = !handler && print_unex && !initialising;
inr = result();
if (inr && do_print)
} while ((ST0 & 0x83) != UNIT(current_drive) && inr == 2);
}
if (handler) {
- schedule_bh( (void *)(void *) handler);
+ schedule_bh(handler);
} else {
#if 0
FDCS->reset = 1;
#endif
}
is_alive("normal interrupt end");
+
+ /* FIXME! Was it really for us? */
+ return IRQ_HANDLED;
}
static void recalibrate_floppy(void)
static int have_no_fdc= -ENODEV;
+static void floppy_device_release(struct device *dev)
+{
+ complete(&device_release);
+}
+
static struct platform_device floppy_device = {
.name = "floppy",
.id = 0,
.dev = {
- .name = "Floppy Drive",
+ .release = floppy_device_release,
},
};
}
devfs_mk_dir (NULL, "floppy", NULL);
- if (register_blkdev(FLOPPY_MAJOR,"fd")) {
- err = -EBUSY;
+ if ((err = register_blkdev(FLOPPY_MAJOR,"fd")))
goto out;
- }
for (i=0; i<N_DRIVE; i++) {
disks[i]->major = FLOPPY_MAJOR;
else
floppy_sizes[i] = MAX_DISK_SIZE << 1;
- floppy_queue = blk_init_queue(do_fd_request, &floppy_lock)
+ floppy_queue = blk_init_queue(do_fd_request, &floppy_lock);
if (!floppy_queue)
goto out_queue;
{
int drive;
+ init_completion(&device_release);
platform_device_unregister(&floppy_device);
blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
unregister_blkdev(FLOPPY_MAJOR, "fd");
+
for (drive = 0; drive < N_DRIVE; drive++) {
+ del_timer_sync(&motor_off_timer[drive]);
+
if ((allowed_drive_mask & (1 << drive)) &&
fdc_state[FDC(drive)].version != FDC_NONE) {
del_gendisk(disks[drive]);
}
devfs_remove("floppy");
+ del_timer_sync(&fd_timeout);
+ del_timer_sync(&fd_timer);
blk_cleanup_queue(floppy_queue);
+
+ if (usage_count)
+ floppy_release_irq_and_dma();
+
/* eject disk, if any */
fd_eject(0);
+
+ wait_for_completion(&device_release);
}
MODULE_PARM(floppy,"s");