patch-2.4.0-test3 linux/drivers/block/floppy.c
Next file: linux/drivers/block/ll_rw_blk.c
Previous file: linux/drivers/block/elevator.c
Back to the patch index
Back to the overall index
- Lines: 107
- Date:
Thu Jul 6 19:42:06 2000
- Orig file:
v2.4.0-test2/linux/drivers/block/floppy.c
- Orig date:
Fri Jun 23 21:55:08 2000
diff -u --recursive --new-file v2.4.0-test2/linux/drivers/block/floppy.c linux/drivers/block/floppy.c
@@ -852,10 +852,10 @@
}
/* locks the driver */
-static int lock_fdc(int drive, int interruptible)
+static int _lock_fdc(int drive, int interruptible, int line)
{
if (!usage_count){
- printk(KERN_ERR "Trying to lock fdc while usage count=0\n");
+ printk(KERN_ERR "Trying to lock fdc while usage count=0 at line %d\n", line);
return -1;
}
if(floppy_grab_irq_and_dma()==-1)
@@ -889,6 +889,8 @@
return 0;
}
+#define lock_fdc(drive,interruptible) _lock_fdc(drive,interruptible, __LINE__)
+
#define LOCK_FDC(drive,interruptible) \
if (lock_fdc(drive,interruptible)) return -EINTR;
@@ -1872,7 +1874,7 @@
if (timer_pending(&fd_timer))
printk("fd_timer.function=%p\n", fd_timer.function);
if (timer_pending(&fd_timeout)){
- printk("timer_table=%p\n",fd_timeout.function);
+ printk("timer_function=%p\n",fd_timeout.function);
printk("expires=%lu\n",fd_timeout.expires-jiffies);
printk("now=%lu\n",jiffies);
}
@@ -2601,6 +2603,11 @@
int aligned_sector_t;
int max_sector, max_size, tracksize, ssize;
+ if(max_buffer_sectors == 0) {
+ printk("VFS: Block I/O scheduled on unopened device\n");
+ return 0;
+ }
+
set_fdc(DRIVE(CURRENT->rq_dev));
raw_cmd = &default_raw_cmd;
@@ -2955,6 +2962,11 @@
static void do_fd_request(request_queue_t * q)
{
+ if(max_buffer_sectors == 0) {
+ printk("VFS: do_fd_request called on non-open device\n");
+ return;
+ }
+
if (usage_count == 0) {
printk("warning: usage count=0, CURRENT=%p exiting\n", CURRENT);
printk("sect=%ld cmd=%d\n", CURRENT->sector, CURRENT->cmd);
@@ -3782,9 +3794,14 @@
return 1;
if (UDP->checkfreq < (int)(jiffies - UDRS->last_checked)) {
+ 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) ||
@@ -3810,6 +3827,10 @@
UTESTF(FD_VERIFY) ||
test_bit(drive, &fake_change) ||
NO_GEOM){
+ if(usage_count == 0) {
+ printk("VFS: revalidate called on non-open device.\n");
+ return -EFAULT;
+ }
lock_fdc(drive,0);
cf = UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY);
if (!(cf || test_bit(drive, &fake_change) || NO_GEOM)){
@@ -3831,7 +3852,7 @@
size = 1024;
if (!(bh = getblk(dev,0,size))){
process_fd_request();
- return 1;
+ return -ENXIO;
}
if (bh && !buffer_uptodate(bh))
ll_rw_block(READ, 1, &bh);
@@ -4109,7 +4130,7 @@
raw_cmd = NULL;
- devfs_handle = devfs_mk_dir (NULL, "floppy", 0, NULL);
+ devfs_handle = devfs_mk_dir (NULL, "floppy", NULL);
if (devfs_register_blkdev(MAJOR_NR,"fd",&floppy_fops)) {
printk("Unable to get major %d for floppy\n",MAJOR_NR);
return -EBUSY;
@@ -4143,6 +4164,7 @@
if (fdc_state[0].address == -1) {
devfs_unregister_blkdev(MAJOR_NR,"fd");
del_timer(&fd_timeout);
+ blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
return -ENODEV;
}
#if N_FDC > 1
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)