X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fblock%2Ffloppy.c;h=3f1b38276e96e123e6ec772cb08a605dd8d08032;hb=refs%2Fheads%2Fvserver;hp=dff1e67b1dd4e2768447ac92465caf8e1cceb97a;hpb=43bc926fffd92024b46cafaf7350d669ba9ca884;p=linux-2.6.git diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index dff1e67b1..3f1b38276 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -177,7 +177,6 @@ static int print_unex = 1; #include #include #include -#include #include #include /* for invalidate_buffers() */ #include @@ -222,9 +221,8 @@ static DEFINE_SPINLOCK(floppy_lock); static struct completion device_release; static unsigned short virtual_dma_port = 0x3f0; -irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs *regs); +irqreturn_t floppy_interrupt(int irq, void *dev_id); static int set_dor(int fdc, char mask, char data); -static void register_devfs_entries(int drive) __init; #define K_64 0x10000 /* 64KB */ @@ -251,18 +249,6 @@ static int irqdma_allocated; #include /* for the compatibility eject ioctl */ #include -/* - * Interrupt freeing also means /proc VFS work - dont do it - * from interrupt context. We push this work into keventd: - */ -static void fd_free_irq_fn(void *data) -{ - fd_free_irq(); -} - -static DECLARE_WORK(fd_free_irq_work, fd_free_irq_fn, NULL); - - static struct request *current_req; static struct request_queue *floppy_queue; static void do_fd_request(request_queue_t * q); @@ -828,15 +814,6 @@ static int set_dor(int fdc, char mask, char data) UDRS->select_date = jiffies; } } - /* - * We should propagate failures to grab the resources back - * nicely from here. Actually we ought to rewrite the fd - * driver some day too. - */ - if (newdor & FLOPPY_MOTOR_MASK) - floppy_grab_irq_and_dma(); - if (olddor & FLOPPY_MOTOR_MASK) - floppy_release_irq_and_dma(); return olddor; } @@ -894,8 +871,6 @@ static int _lock_fdc(int drive, int interruptible, int line) line); return -1; } - if (floppy_grab_irq_and_dma() == -1) - return -EBUSY; if (test_and_set_bit(0, &fdc_busy)) { DECLARE_WAITQUEUE(wait, current); @@ -917,6 +892,8 @@ static int _lock_fdc(int drive, int interruptible, int line) set_current_state(TASK_RUNNING); remove_wait_queue(&fdc_wait, &wait); + + flush_scheduled_work(); } command_status = FD_COMMAND_NONE; @@ -950,7 +927,6 @@ static inline void unlock_fdc(void) if (elv_next_request(floppy_queue)) do_fd_request(floppy_queue); spin_unlock_irqrestore(&floppy_lock, flags); - floppy_release_irq_and_dma(); wake_up(&fdc_wait); } @@ -1016,11 +992,11 @@ static void empty(void) { } -static DECLARE_WORK(floppy_work, NULL, NULL); +static DECLARE_WORK(floppy_work, NULL); static void schedule_bh(void (*handler) (void)) { - PREPARE_WORK(&floppy_work, (void (*)(void *))handler, NULL); + PREPARE_WORK(&floppy_work, (work_func_t)handler); schedule_work(&floppy_work); } @@ -1032,7 +1008,7 @@ static void cancel_activity(void) spin_lock_irqsave(&floppy_lock, flags); do_floppy = NULL; - PREPARE_WORK(&floppy_work, (void *)empty, NULL); + PREPARE_WORK(&floppy_work, (work_func_t)empty); del_timer(&fd_timer); spin_unlock_irqrestore(&floppy_lock, flags); } @@ -1750,7 +1726,7 @@ static void print_result(char *message, int inr) } /* interrupt handler. Note that this can be called externally on the Sparc */ -irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs *regs) +irqreturn_t floppy_interrupt(int irq, void *dev_id) { void (*handler) (void) = do_floppy; int do_print; @@ -1892,7 +1868,7 @@ static void show_floppy(void) printk("fdc_busy=%lu\n", fdc_busy); if (do_floppy) printk("do_floppy=%p\n", do_floppy); - if (floppy_work.pending) + if (work_pending(&floppy_work)) printk("floppy_work.func=%p\n", floppy_work.func); if (timer_pending(&fd_timer)) printk("fd_timer.function=%p\n", fd_timer.function); @@ -3015,8 +2991,8 @@ static void do_fd_request(request_queue_t * q) if (usage_count == 0) { printk("warning: usage count=0, current_req=%p exiting\n", current_req); - printk("sect=%ld flags=%lx\n", (long)current_req->sector, - current_req->flags); + printk("sect=%ld type=%x flags=%x\n", (long)current_req->sector, + current_req->cmd_type, current_req->cmd_flags); return; } if (test_bit(0, &fdc_busy)) { @@ -3676,7 +3652,6 @@ static void __init config_types(void) first = 0; } printk("%s fd%d is %s", prepend, drive, name); - register_devfs_entries(drive); } *UDP = *params; } @@ -3697,8 +3672,8 @@ static int floppy_release(struct inode *inode, struct file *filp) } if (!UDRS->fd_ref) opened_bdev[drive] = NULL; - floppy_release_irq_and_dma(); mutex_unlock(&open_lock); + return 0; } @@ -3729,9 +3704,6 @@ static int floppy_open(struct inode *inode, struct file *filp) if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_flags & O_EXCL))) goto out2; - if (floppy_grab_irq_and_dma()) - goto out2; - if (filp->f_flags & O_EXCL) UDRS->fd_ref = -1; else @@ -3808,7 +3780,6 @@ out: UDRS->fd_ref--; if (!UDRS->fd_ref) opened_bdev[drive] = NULL; - floppy_release_irq_and_dma(); out2: mutex_unlock(&open_lock); return res; @@ -3825,14 +3796,9 @@ static int check_floppy_change(struct gendisk *disk) return 1; if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) { - if (floppy_grab_irq_and_dma()) { - return 1; - } - lock_fdc(drive, 0); poll_drive(0, 0); process_fd_request(); - floppy_release_irq_and_dma(); } if (UTESTF(FD_DISK_CHANGED) || @@ -3954,37 +3920,6 @@ static struct block_device_operations floppy_fops = { .media_changed = check_floppy_change, .revalidate_disk = floppy_revalidate, }; -static char *table[] = { - "", "d360", "h1200", "u360", "u720", "h360", "h720", - "u1440", "u2880", "CompaQ", "h1440", "u1680", "h410", - "u820", "h1476", "u1722", "h420", "u830", "h1494", "u1743", - "h880", "u1040", "u1120", "h1600", "u1760", "u1920", - "u3200", "u3520", "u3840", "u1840", "u800", "u1600", - NULL -}; -static int t360[] = { 1, 0 }, - t1200[] = { 2, 5, 6, 10, 12, 14, 16, 18, 20, 23, 0 }, - t3in[] = { 8, 9, 26, 27, 28, 7, 11, 15, 19, 24, 25, 29, 31, 3, 4, 13, - 17, 21, 22, 30, 0 }; -static int *table_sup[] = - { NULL, t360, t1200, t3in + 5 + 8, t3in + 5, t3in, t3in }; - -static void __init register_devfs_entries(int drive) -{ - int base_minor = (drive < 4) ? drive : (124 + drive); - - if (UDP->cmos < ARRAY_SIZE(default_drive_params)) { - int i = 0; - do { - int minor = base_minor + (table_sup[UDP->cmos][i] << 2); - - devfs_mk_bdev(MKDEV(FLOPPY_MAJOR, minor), - S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP | - S_IWGRP, "floppy/%d%s", drive, - table[table_sup[UDP->cmos][i]]); - } while (table_sup[UDP->cmos][i++]); - } -} /* * Floppy Driver initialization @@ -4242,6 +4177,11 @@ static int __init floppy_init(void) int i, unit, drive; int err, dr; +#if defined(CONFIG_PPC_MERGE) + if (check_legacy_ioport(FDC1)) + return -ENODEV; +#endif + raw_cmd = NULL; for (dr = 0; dr < N_DRIVE; dr++) { @@ -4261,11 +4201,9 @@ static int __init floppy_init(void) motor_off_timer[dr].function = motor_off_callback; } - devfs_mk_dir("floppy"); - err = register_blkdev(FLOPPY_MAJOR, "fd"); if (err) - goto out_devfs_remove; + goto out_put_disk; floppy_queue = blk_init_queue(do_fd_request, &floppy_lock); if (!floppy_queue) { @@ -4301,13 +4239,6 @@ static int __init floppy_init(void) } use_virtual_dma = can_use_virtual_dma & 1; -#if defined(CONFIG_PPC_MERGE) - if (check_legacy_ioport(FDC1)) { - del_timer(&fd_timeout); - err = -ENODEV; - goto out_unreg_region; - } -#endif fdc_state[0].address = FDC1; if (fdc_state[0].address == -1) { del_timer(&fd_timeout); @@ -4382,7 +4313,6 @@ static int __init floppy_init(void) fdc = 0; del_timer(&fd_timeout); current_drive = 0; - floppy_release_irq_and_dma(); initialising = 0; if (have_no_fdc) { DPRINT("no floppy controllers found\n"); @@ -4424,8 +4354,6 @@ out_unreg_region: blk_cleanup_queue(floppy_queue); out_unreg_blkdev: unregister_blkdev(FLOPPY_MAJOR, "fd"); -out_devfs_remove: - devfs_remove("floppy"); out_put_disk: while (dr--) { del_timer(&motor_off_timer[dr]); @@ -4542,7 +4470,7 @@ static void floppy_release_irq_and_dma(void) if (irqdma_allocated) { fd_disable_dma(); fd_free_dma(); - schedule_work(&fd_free_irq_work); + fd_free_irq(); irqdma_allocated = 0; } set_dor(0, ~0, 8); @@ -4570,7 +4498,7 @@ static void floppy_release_irq_and_dma(void) printk("floppy timer still active:%s\n", timeout_message); if (timer_pending(&fd_timer)) printk("auxiliary floppy timer still active\n"); - if (floppy_work.pending) + if (work_pending(&floppy_work)) printk("work still pending\n"); #endif old_fdc = fdc; @@ -4586,19 +4514,6 @@ static void floppy_release_irq_and_dma(void) static char *floppy; -static void unregister_devfs_entries(int drive) -{ - int i; - - if (UDP->cmos < ARRAY_SIZE(default_drive_params)) { - i = 0; - do { - devfs_remove("floppy/%d%s", drive, - table[table_sup[UDP->cmos][i]]); - } while (table_sup[UDP->cmos][i++]); - } -} - static void __init parse_floppy_cfg_string(char *cfg) { char *ptr; @@ -4635,13 +4550,11 @@ void cleanup_module(void) if ((allowed_drive_mask & (1 << drive)) && fdc_state[FDC(drive)].version != FDC_NONE) { del_gendisk(disks[drive]); - unregister_devfs_entries(drive); device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos); platform_device_unregister(&floppy_device[drive]); } put_disk(disks[drive]); } - devfs_remove("floppy"); del_timer_sync(&fd_timeout); del_timer_sync(&fd_timer); @@ -4653,8 +4566,6 @@ void cleanup_module(void) /* eject disk, if any */ fd_eject(0); - flush_scheduled_work(); /* fd_free_irq() might be pending */ - wait_for_completion(&device_release); }