X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fblock%2Ffloppy.c;h=bce3fc0e6e4f32b252c1b24319406619a19bf8aa;hb=af20d436230b2df6d73a406b6f1b31ae000775cb;hp=70375a056fa11fe2c972b3a7768394fcaebb5a1e;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 70375a056..bce3fc0e6 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -155,7 +155,6 @@ static int print_unex = 1; #include #include #include -#include #define FDPATCHES #include @@ -217,7 +216,7 @@ static int use_virtual_dma; * record each buffers capabilities */ -static spinlock_t floppy_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(floppy_lock); static struct completion device_release; static unsigned short virtual_dma_port = 0x3f0; @@ -922,7 +921,7 @@ static inline void unlock_fdc(void) { unsigned long flags; - raw_cmd = 0; + raw_cmd = NULL; if (!test_bit(0, &fdc_busy)) DPRINT("FDC access conflict!\n"); @@ -1073,7 +1072,7 @@ static int fd_wait_for_completion(unsigned long delay, timeout_fn function) return 0; } -static spinlock_t floppy_hlt_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(floppy_hlt_lock); static int hlt_disabled; static void floppy_disable_hlt(void) { @@ -1787,10 +1786,11 @@ irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs *regs) } while ((ST0 & 0x83) != UNIT(current_drive) && inr == 2 && max_sensei); } - if (handler) - schedule_bh(handler); - else + if (!handler) { FDCS->reset = 1; + return IRQ_NONE; + } + schedule_bh(handler); is_alive("normal interrupt end"); /* FIXME! Was it really for us? */ @@ -2021,7 +2021,7 @@ static void floppy_start(void) static void do_wakeup(void) { reschedule_timeout(MAXTIMEOUT, "do wakeup", 0); - cont = 0; + cont = NULL; command_status += 2; wake_up(&command_done); } @@ -3191,7 +3191,7 @@ static void raw_cmd_free(struct floppy_raw_cmd **ptr) struct floppy_raw_cmd *next, *this; this = *ptr; - *ptr = 0; + *ptr = NULL; while (this) { if (this->buffer_length) { fd_dma_mem_free((unsigned long)this->kernel_data, @@ -3211,7 +3211,7 @@ static inline int raw_cmd_copyin(int cmd, char __user *param, int ret; int i; - *rcmd = 0; + *rcmd = NULL; while (1) { ptr = (struct floppy_raw_cmd *) kmalloc(sizeof(struct floppy_raw_cmd), GFP_USER); @@ -3219,7 +3219,7 @@ static inline int raw_cmd_copyin(int cmd, char __user *param, return -ENOMEM; *rcmd = ptr; COPYIN(*ptr); - ptr->next = 0; + ptr->next = NULL; ptr->buffer_length = 0; param += sizeof(struct floppy_raw_cmd); if (ptr->cmd_count > 33) @@ -3236,7 +3236,7 @@ static inline int raw_cmd_copyin(int cmd, char __user *param, for (i = 0; i < 16; i++) ptr->reply[i] = 0; ptr->resultcode = 0; - ptr->kernel_data = 0; + ptr->kernel_data = NULL; if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) { if (ptr->length <= 0) @@ -3318,11 +3318,6 @@ static int invalidate_drive(struct block_device *bdev) return 0; } -static inline void clear_write_error(int drive) -{ - CLEARSTRUCT(UDRWE); -} - static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, int drive, int type, struct block_device *bdev) { @@ -4124,33 +4119,33 @@ static struct param_table { int *var; int def_param; int param2; -} config_params[] = { - {"allowed_drive_mask", 0, &allowed_drive_mask, 0xff, 0}, /* obsolete */ - {"all_drives", 0, &allowed_drive_mask, 0xff, 0}, /* obsolete */ - {"asus_pci", 0, &allowed_drive_mask, 0x33, 0}, - {"irq", 0, &FLOPPY_IRQ, 6, 0}, - {"dma", 0, &FLOPPY_DMA, 2, 0}, - {"daring", daring, 0, 1, 0}, +} config_params[] __initdata = { + {"allowed_drive_mask", NULL, &allowed_drive_mask, 0xff, 0}, /* obsolete */ + {"all_drives", NULL, &allowed_drive_mask, 0xff, 0}, /* obsolete */ + {"asus_pci", NULL, &allowed_drive_mask, 0x33, 0}, + {"irq", NULL, &FLOPPY_IRQ, 6, 0}, + {"dma", NULL, &FLOPPY_DMA, 2, 0}, + {"daring", daring, NULL, 1, 0}, #if N_FDC > 1 - {"two_fdc", 0, &FDC2, 0x370, 0}, - {"one_fdc", 0, &FDC2, 0, 0}, + {"two_fdc", NULL, &FDC2, 0x370, 0}, + {"one_fdc", NULL, &FDC2, 0, 0}, #endif - {"thinkpad", floppy_set_flags, 0, 1, FD_INVERTED_DCL}, - {"broken_dcl", floppy_set_flags, 0, 1, FD_BROKEN_DCL}, - {"messages", floppy_set_flags, 0, 1, FTD_MSG}, - {"silent_dcl_clear", floppy_set_flags, 0, 1, FD_SILENT_DCL_CLEAR}, - {"debug", floppy_set_flags, 0, 1, FD_DEBUG}, - {"nodma", 0, &can_use_virtual_dma, 1, 0}, - {"omnibook", 0, &can_use_virtual_dma, 1, 0}, - {"yesdma", 0, &can_use_virtual_dma, 0, 0}, - {"fifo_depth", 0, &fifo_depth, 0xa, 0}, - {"nofifo", 0, &no_fifo, 0x20, 0}, - {"usefifo", 0, &no_fifo, 0, 0}, - {"cmos", set_cmos, 0, 0, 0}, - {"slow", 0, &slow_floppy, 1, 0}, - {"unexpected_interrupts", 0, &print_unex, 1, 0}, - {"no_unexpected_interrupts", 0, &print_unex, 0, 0}, - {"L40SX", 0, &print_unex, 0, 0} + {"thinkpad", floppy_set_flags, NULL, 1, FD_INVERTED_DCL}, + {"broken_dcl", floppy_set_flags, NULL, 1, FD_BROKEN_DCL}, + {"messages", floppy_set_flags, NULL, 1, FTD_MSG}, + {"silent_dcl_clear", floppy_set_flags, NULL, 1, FD_SILENT_DCL_CLEAR}, + {"debug", floppy_set_flags, NULL, 1, FD_DEBUG}, + {"nodma", NULL, &can_use_virtual_dma, 1, 0}, + {"omnibook", NULL, &can_use_virtual_dma, 1, 0}, + {"yesdma", NULL, &can_use_virtual_dma, 0, 0}, + {"fifo_depth", NULL, &fifo_depth, 0xa, 0}, + {"nofifo", NULL, &no_fifo, 0x20, 0}, + {"usefifo", NULL, &no_fifo, 0, 0}, + {"cmos", set_cmos, NULL, 0, 0}, + {"slow", NULL, &slow_floppy, 1, 0}, + {"unexpected_interrupts", NULL, &print_unex, 1, 0}, + {"no_unexpected_interrupts", NULL, &print_unex, 0, 0}, + {"L40SX", NULL, &print_unex, 0, 0} EXTRA_FLOPPY_PARAMS }; @@ -4190,7 +4185,7 @@ static int __init floppy_setup(char *str) printk("\n"); } else DPRINT("botched floppy option\n"); - DPRINT("Read linux/Documentation/floppy.txt\n"); + DPRINT("Read Documentation/floppy.txt\n"); return 0; } @@ -4228,7 +4223,6 @@ int __init floppy_init(void) int err, dr; raw_cmd = NULL; - i = 0; for (dr = 0; dr < N_DRIVE; dr++) { disks[dr] = alloc_disk(1); @@ -4287,6 +4281,13 @@ int __init floppy_init(void) } use_virtual_dma = can_use_virtual_dma & 1; +#if defined(CONFIG_PPC64) + 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); @@ -4316,6 +4317,12 @@ int __init floppy_init(void) floppy_track_buffer = NULL; max_buffer_sectors = 0; } + /* + * Small 10 msec delay to let through any interrupt that + * initialization might have triggered, to not + * confuse detection: + */ + msleep(10); for (i = 0; i < N_FDC; i++) { fdc = i; @@ -4408,7 +4415,7 @@ out_put_disk: return err; } -static spinlock_t floppy_usage_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(floppy_usage_lock); static int floppy_grab_irq_and_dma(void) { @@ -4583,8 +4590,6 @@ static void __init parse_floppy_cfg_string(char *cfg) int init_module(void) { - printk(KERN_INFO "inserting floppy driver for " UTS_RELEASE "\n"); - if (floppy) parse_floppy_cfg_string(floppy); return floppy_init(); @@ -4624,9 +4629,9 @@ void cleanup_module(void) wait_for_completion(&device_release); } -MODULE_PARM(floppy, "s"); -MODULE_PARM(FLOPPY_IRQ, "i"); -MODULE_PARM(FLOPPY_DMA, "i"); +module_param(floppy, charp, 0); +module_param(FLOPPY_IRQ, int, 0); +module_param(FLOPPY_DMA, int, 0); MODULE_AUTHOR("Alain L. Knaff"); MODULE_SUPPORTED_DEVICE("fd"); MODULE_LICENSE("GPL");