Subject: L68K: patch for amiflop (again) To: Geert.Uytterhoeven@cs.kuleuven.ac.be (Geert Uytterhoeven), Jes.Sorensen@cern.ch (Jes Sorensen), linux-m68k@lists.linux-m68k.org (linux-list) Date: Mon, 19 Jan 1998 08:23:44 +0100 (MET) From: "J." Dorchain Sender: owner-linux-m68k@phil.uni-sb.de Reply-To: jdorchain@i-con.de Hi, this should solve the remaing problems in amiflop. More precisly, - drive recognition for other than DD-drives (with only worked by chance :-() - Skipping over each second sector on disk. This time I tested it more carefully. I don't tell what it was, and have hidden both bad typos in some cosmectic changes, otherwise the stupidity would be too obvious. Joerg --- amiflop.c.09011998 Fri Jan 9 13:21:59 1998 +++ amiflop.c Sun Jan 18 22:19:28 1998 @@ -304,7 +304,7 @@ drive&=3; #ifdef DEBUG -printk("selecting %d\n",drive); + printk("selecting %d\n",drive); #endif if (drive == selected) return; @@ -329,7 +329,7 @@ drive&=3; #ifdef DEBUG -printk("deselecting %d\n",drive); + printk("deselecting %d\n",drive); #endif if (drive != selected) { printk(KERN_WARNING "Deselecting drive %d while %d was selected!\n",drive,selected); @@ -497,7 +497,7 @@ int cnt; #ifdef DEBUG -printk("seeking drive %d to track %d\n",drive,track); + printk("seeking drive %d to track %d\n",drive,track); #endif drive &= 3; get_fdc(drive); @@ -555,7 +555,6 @@ drive&=3; get_fdc(drive); - fd_select(drive); /* set up for ID */ MOTOR_ON; udelay(2); @@ -582,7 +581,6 @@ DESELECT(SELMASK(drive)); } - fd_deselect(drive); rel_fdc(); /* @@ -684,7 +682,7 @@ static void post_write (unsigned long drive) { #ifdef DEBUG -printk("post_write for drive %ld\n",drive); + printk("post_write for drive %ld\n",drive); #endif drive &= 3; custom.dsklen = 0; @@ -1069,8 +1067,8 @@ #ifdef DEBUG static void dbg(unsigned long ptr) { -printk("raw data @%08lx: %08lx, %08lx ,%08lx, %08lx\n",ptr, - ((ulong *)ptr)[0],((ulong *)ptr)[1],((ulong *)ptr)[2],((ulong *)ptr)[3]); + printk("raw data @%08lx: %08lx, %08lx ,%08lx, %08lx\n",ptr, + ((ulong *)ptr)[0],((ulong *)ptr)[1],((ulong *)ptr)[2],((ulong *)ptr)[3]); } #endif @@ -1422,24 +1420,30 @@ goto repeat; } - track = block / floppy->dtype->sects * floppy->type->sect_mult; - sector = block % floppy->dtype->sects * floppy->type->sect_mult; + track = block / (floppy->dtype->sects * floppy->type->sect_mult); + sector = block % (floppy->dtype->sects * floppy->type->sect_mult); data = CURRENT->buffer + 512 * cnt; +#ifdef DEBUG + printk("access to track %d, sector %d, with buffer at 0x%08lx\n", + track, sector, data); +#endif + + if ((CURRENT->cmd != READ) && (CURRENT->cmd != WRITE)) { + printk(KERN_WARNING "do_fd_request: unknown command\n"); + end_request(0); + goto repeat; + } + if (get_track(drive, track) == -1) { + end_request(0); + goto repeat; + } switch (CURRENT->cmd) { case READ: - if (get_track(drive, track) == -1) { - end_request(0); - goto repeat; - } memcpy(data, unit[drive].trackbuf + sector * 512, 512); break; case WRITE: - if (get_track(drive, track) == -1) { - end_request(0); - goto repeat; - } memcpy(unit[drive].trackbuf + sector * 512, data, 512); /* keep the drive spinning while writes are scheduled */ @@ -1462,11 +1466,6 @@ add_timer (flush_track_timer + drive); restore_flags (flags); break; - - default: - printk(KERN_WARNING "do_fd_request: unknown command\n"); - end_request(0); - goto repeat; } } CURRENT->nr_sectors -= CURRENT->current_nr_sectors; @@ -1585,13 +1584,11 @@ unsigned long code; int type; int drive; - int system; drive = dev & 3; code = fd_get_drive_id(drive); /* get drive type */ - unit[drive].type = NULL; for (type = 0; type < num_dr_types; type++) if (drive_types[type].code == code) break; @@ -1603,22 +1600,13 @@ return; } - unit[drive].type = &drive_types[type]; + unit[drive].type = drive_types + type; unit[drive].track = -1; unit[drive].disk = -1; unit[drive].motor = 0; unit[drive].busy = 0; unit[drive].status = -1; - - - system=(dev & 4)>>2; - unit[drive].dtype=&data_types[system]; - unit[drive].blocks=unit[drive].type->heads*unit[drive].type->tracks* - data_types[system].sects*unit[drive].type->sect_mult; - - floppy_sizes[MINOR(dev)] = unit[drive].blocks >> 1; - } /* @@ -1633,7 +1621,7 @@ int system; unsigned long flags; - drive = inode->i_rdev & 3; + drive = MINOR(inode->i_rdev) & 3; old_dev = fd_device[drive]; if (fd_ref[drive]) @@ -1643,7 +1631,9 @@ if (unit[drive].type->code == FD_NODRIVE) return -ENODEV; - if (filp && (filp->f_flags & (O_WRONLY|O_RDWR))) { + if (filp && filp->f_mode & 3) { + check_disk_change(inode->i_rdev); + if (filp->f_mode & 2 ) { int wrprot; get_fdc(drive); @@ -1654,6 +1644,7 @@ if (wrprot) return -EROFS; + } } save_flags(flags); @@ -1669,16 +1660,14 @@ if (old_dev && old_dev != inode->i_rdev) invalidate_buffers(old_dev); - if (filp && filp->f_mode) - check_disk_change(inode->i_rdev); - system=(inode->i_rdev & 4)>>2; unit[drive].dtype=&data_types[system]; unit[drive].blocks=unit[drive].type->heads*unit[drive].type->tracks* data_types[system].sects*unit[drive].type->sect_mult; + floppy_sizes[MINOR(inode->i_rdev)] = unit[drive].blocks >> 1; - printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive,unit[drive].type->name, - data_types[system].name); + printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive, + unit[drive].type->name, data_types[system].name); return 0; } @@ -1744,7 +1733,7 @@ } if (changed) { - fd_probe(dev); + fd_probe(drive); unit[drive].track = -1; unit[drive].dirty = 0; writepending = 0; /* if this was true before, too bad! */