[patch] 2.2.16 ide-floppy support for iomega Clik drive

From: Paul Bristow (paul.bristow@technologist.com)
Date: Sun Jun 11 2000 - 10:27:15 EST


Andre,

I am sending this to you as Gadi seems to be busy with other things.
This patch to ide-floppy.c from kernel 2.2.16 gives support for the
Iomega PCMCIA Clik drive. It has been extensively tested by over 50
people now (that I know of) from kernel 2.2.13 onwards. I have done my
best to ensure it won't break anything else and would appreciate if this
could be included in the standard kernel distribution as it is very
frustrating to go around with my linux laptop knowing I can only share
files with other windows laptops.

Instructions on using the modified ide-floppy.c are available at
http://paulbristow.net/linux/clik.html

Comments, questions etc are welcome.

Thanks,

-- 

Paul

Web: http://paulbristow.net Email: paul.bristow@technologist.com ICQ: #11965223

Patch follows:

--- ide-floppy.c Sun Jun 11 15:15:49 2000 +++ ide-floppy.c Sun Jun 11 16:33:33 2000 @@ -29,9 +29,11 @@ * Ver 0.9 Jul 4 99 Fix a bug which might have caused the number of * bytes requested on each interrupt to be zero. * Thanks to <shanos@es.co.nz> for pointing this out. + * Ver 0.91 Dec 11 99 Added IOMEGA Clik! drive support by + * <paul.bristow@technologist.com> */ -#define IDEFLOPPY_VERSION "0.9" +#define IDEFLOPPY_VERSION "0.91" #include <linux/config.h> #include <linux/module.h> @@ -874,7 +877,7 @@ if (status.b.check || test_bit (PC_DMA_ERROR, &pc->flags)) { /* Error detected */ #if IDEFLOPPY_DEBUG_LOG - printk (KERN_INFO "ide-floppy: %s: I/O error\n",drive->name); + printk (KERN_INFO "ide-floppy: %s: I/O error status.b.check\n",drive->name); #endif /* IDEFLOPPY_DEBUG_LOG */ rq->errors++; if (pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD) { @@ -1012,6 +1015,7 @@ dma_ok=!HWIF(drive)->dmaproc(test_bit (PC_WRITING, &pc->flags) ? ide_dma_write : ide_dma_read, drive); #endif /* CONFIG_BLK_DEV_IDEDMA */ + if (IDE_CONTROL_REG) OUT_BYTE (drive->ctl,IDE_CONTROL_REG); OUT_BYTE (dma_ok ? 1:0,IDE_FEATURE_REG); /* Use PIO/DMA */ OUT_BYTE (bcount.b.high,IDE_BCOUNTH_REG); @@ -1152,7 +1156,7 @@ printk (KERN_ERR "ide-floppy: %s: I/O error, pc = %2x, key = %2x, asc = %2x, ascq = %2x\n", drive->name, floppy->failed_pc->c[0], floppy->sense_key, floppy->asc, floppy->ascq); else - printk (KERN_ERR "ide-floppy: %s: I/O error\n", drive->name); + printk (KERN_ERR "ide-floppy: %s: I/O error in idefloppy_do_request\n", drive->name); idefloppy_end_request (0, HWGROUP(drive)); return ide_stopped; } @@ -1205,6 +1209,15 @@ idefloppy_flexible_disk_page_t *page; int capacity, lba_capacity; + /* Inserted by Paul Bristow + * The IOMEGA Clik! drive does not support this command + * so I removed it and fake the important parameters. + * This does not appear to have any major side effects, + * so I hope everything is OK. + */ + if (!strstr(drive->id->model,"Clik")) { + + idefloppy_create_mode_sense_cmd (&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE, MODE_SENSE_CURRENT); if (idefloppy_queue_pc_tail (drive,&pc)) { printk (KERN_ERR "ide-floppy: Can't get flexible disk page parameters\n"); @@ -1235,6 +1248,14 @@ capacity = IDEFLOPPY_MIN(capacity, lba_capacity); floppy->blocks = floppy->block_size ? capacity / floppy->block_size : 0; } + } + else { + /* It is an IOMEGA Clik! Drive, which does not support the above command */ + printk (KERN_INFO "Forcing Clik! Parameters\n"); + floppy->blocks=78882; + floppy->block_size=512; + floppy->bs_factor=1; + } return 0; } @@ -1287,9 +1308,10 @@ } (void) idefloppy_get_flexible_disk_page (drive); drive->part[0].nr_sects = floppy->blocks * floppy->bs_factor; - return rc; + return rc ; } + /* * Our special ide-floppy ioctl's. * @@ -1303,8 +1325,11 @@ if (cmd == CDROMEJECT) { if (drive->usage > 1) return -EBUSY; + /* The IOMEGA CLik! Drive doesn't support this command */ + if (!strstr(drive->id->model,"Clik")) { idefloppy_create_prevent_cmd (&pc, 0); (void) idefloppy_queue_pc_tail (drive, &pc); + } idefloppy_create_start_stop_cmd (&pc, 2); (void) idefloppy_queue_pc_tail (drive, &pc); return 0; @@ -1326,14 +1351,22 @@ MOD_INC_USE_COUNT; if (drive->usage == 1) { + printk (KERN_INFO "Testing if unit is ready...\n"); + /* Send are you ready command */ + /* Will fail if no disk... */ idefloppy_create_test_unit_ready_cmd(&pc); if (idefloppy_queue_pc_tail(drive, &pc)) { + printk (KERN_INFO "Not ready, issuing start command\n"); + /* This will also fail for a Clik! drive if no disk... */ idefloppy_create_start_stop_cmd (&pc, 1); (void) idefloppy_queue_pc_tail (drive, &pc); + } else + { printk (KERN_INFO "Yes unit is ready\n"); } if (idefloppy_get_capacity (drive)) { drive->usage--; MOD_DEC_USE_COUNT; + printk (KERN_INFO "I/O Error Getting Capacity\n"); return -EIO; } if (floppy->wp && (filp->f_mode & 2)) { @@ -1342,8 +1375,11 @@ return -EROFS; } set_bit (IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); + /* IOMEGA Clik! drives do not support lock/unlock commands */ + if (!strstr(drive->id->model,"Clik")) { idefloppy_create_prevent_cmd (&pc, 1); (void) idefloppy_queue_pc_tail (drive, &pc); + } check_disk_change(inode->i_rdev); } return 0; @@ -1359,9 +1395,12 @@ if (!drive->usage) { invalidate_buffers (inode->i_rdev); + /* IOMEGA Clik! drives do not support lock/unlock commands */ + if (!strstr(drive->id->model,"Clik")) { idefloppy_create_prevent_cmd (&pc, 0); (void) idefloppy_queue_pc_tail (drive, &pc); } + } MOD_DEC_USE_COUNT; } @@ -1542,6 +1581,16 @@ for (i = 0; i < 1 << PARTN_BITS; i++) max_sectors[major][minor + i] = 64; } + /* + * Guess what? The IOMEGA Clik! drive also needs the + * above fix. It makes nasty clicking noises without + * it, so please don't remove this. + */ + if (strcmp(drive->id->model, "IOMEGA Clik! 40 CZ ATAPI") == 0) + { + for (i = 0; i < 1 << PARTN_BITS; i++) + max_sectors[major][minor + i] = 64; + } (void) idefloppy_get_capacity (drive); idefloppy_add_settings(drive);

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jun 15 2000 - 21:00:23 EST