]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-floppy.c
pdc202xx_old: rewrite mode programming code (v2)
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-floppy.c
index d33717c8afd466731855e4a42f01d65c9ee85b2e..f429be88c4f9d568846baeb765181ccefc479ddd 100644 (file)
@@ -279,6 +279,7 @@ typedef struct ide_floppy_obj {
        ide_driver_t    *driver;
        struct gendisk  *disk;
        struct kref     kref;
+       unsigned int    openers;        /* protected by BKL for now */
 
        /* Current packet command */
        idefloppy_pc_t *pc;
@@ -866,7 +867,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
        if (test_and_clear_bit(PC_DMA_IN_PROGRESS, &pc->flags)) {
                printk(KERN_ERR "ide-floppy: The floppy wants to issue "
                        "more interrupts in DMA mode\n");
-               (void)__ide_dma_off(drive);
+               ide_dma_off(drive);
                return ide_do_reset(drive);
        }
 
@@ -1096,9 +1097,9 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
        pc->current_position = pc->buffer;
        bcount.all = min(pc->request_transfer, 63 * 1024);
 
-       if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) {
-               (void)__ide_dma_off(drive);
-       }
+       if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags))
+               ide_dma_off(drive);
+
        feature.all = 0;
 
        if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma)
@@ -1433,7 +1434,8 @@ static int idefloppy_get_capacity (ide_drive_t *drive)
        
        drive->bios_cyl = 0;
        drive->bios_head = drive->bios_sect = 0;
-       floppy->blocks = floppy->bs_factor = 0;
+       floppy->blocks = 0;
+       floppy->bs_factor = 1;
        set_capacity(floppy->disk, 0);
 
        idefloppy_create_read_capacity_cmd(&pc);
@@ -1809,18 +1811,22 @@ static int idefloppy_identify_device (ide_drive_t *drive,struct hd_driveid *id)
        return 0;
 }
 
+#ifdef CONFIG_IDE_PROC_FS
 static void idefloppy_add_settings(ide_drive_t *drive)
 {
        idefloppy_floppy_t *floppy = drive->driver_data;
 
 /*
- *                     drive   setting name    read/write      ioctl   ioctl           data type       min     max     mul_factor      div_factor      data pointer            set function
+ *                     drive   setting name    read/write      data type       min     max     mul_factor      div_factor      data pointer            set function
  */
-       ide_add_setting(drive,  "bios_cyl",             SETTING_RW,                                     -1,                     -1,                     TYPE_INT,       0,      1023,                           1,      1,      &drive->bios_cyl,               NULL);
-       ide_add_setting(drive,  "bios_head",            SETTING_RW,                                     -1,                     -1,                     TYPE_BYTE,      0,      255,                            1,      1,      &drive->bios_head,              NULL);
-       ide_add_setting(drive,  "bios_sect",            SETTING_RW,                                     -1,                     -1,                     TYPE_BYTE,      0,      63,                             1,      1,      &drive->bios_sect,              NULL);
-       ide_add_setting(drive,  "ticks",                SETTING_RW,                                     -1,                     -1,                     TYPE_BYTE,      0,      255,                            1,      1,      &floppy->ticks,         NULL);
+       ide_add_setting(drive,  "bios_cyl",     SETTING_RW,     TYPE_INT,       0,      1023,           1,              1,      &drive->bios_cyl,       NULL);
+       ide_add_setting(drive,  "bios_head",    SETTING_RW,     TYPE_BYTE,      0,      255,            1,              1,      &drive->bios_head,      NULL);
+       ide_add_setting(drive,  "bios_sect",    SETTING_RW,     TYPE_BYTE,      0,      63,             1,              1,      &drive->bios_sect,      NULL);
+       ide_add_setting(drive,  "ticks",        SETTING_RW,     TYPE_BYTE,      0,      255,            1,              1,      &floppy->ticks,         NULL);
 }
+#else
+static inline void idefloppy_add_settings(ide_drive_t *drive) { ; }
+#endif
 
 /*
  *     Driver initialization.
@@ -1871,7 +1877,7 @@ static void ide_floppy_remove(ide_drive_t *drive)
        idefloppy_floppy_t *floppy = drive->driver_data;
        struct gendisk *g = floppy->disk;
 
-       ide_unregister_subdriver(drive, floppy->driver);
+       ide_proc_unregister_driver(drive, floppy->driver);
 
        del_gendisk(g);
 
@@ -1890,8 +1896,7 @@ static void ide_floppy_release(struct kref *kref)
        kfree(floppy);
 }
 
-#ifdef CONFIG_PROC_FS
-
+#ifdef CONFIG_IDE_PROC_FS
 static int proc_idefloppy_read_capacity
        (char *page, char **start, off_t off, int count, int *eof, void *data)
 {
@@ -1907,12 +1912,7 @@ static ide_proc_entry_t idefloppy_proc[] = {
        { "geometry",   S_IFREG|S_IRUGO,        proc_ide_read_geometry, NULL },
        { NULL, 0, NULL, NULL }
 };
-
-#else
-
-#define        idefloppy_proc  NULL
-
-#endif /* CONFIG_PROC_FS */
+#endif /* CONFIG_IDE_PROC_FS */
 
 static int ide_floppy_probe(ide_drive_t *);
 
@@ -1931,7 +1931,9 @@ static ide_driver_t idefloppy_driver = {
        .end_request            = idefloppy_do_end_request,
        .error                  = __ide_error,
        .abort                  = __ide_abort,
+#ifdef CONFIG_IDE_PROC_FS
        .proc                   = idefloppy_proc,
+#endif
 };
 
 static int idefloppy_open(struct inode *inode, struct file *filp)
@@ -1949,9 +1951,9 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
 
        drive = floppy->drive;
 
-       drive->usage++;
+       floppy->openers++;
 
-       if (drive->usage == 1) {
+       if (floppy->openers == 1) {
                clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
                /* Just in case */
 
@@ -1969,13 +1971,11 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
                    ** capacity of the drive or begin the format - Sam
                    */
                    ) {
-                       drive->usage--;
                        ret = -EIO;
                        goto out_put_floppy;
                }
 
                if (floppy->wp && (filp->f_mode & 2)) {
-                       drive->usage--;
                        ret = -EROFS;
                        goto out_put_floppy;
                }
@@ -1987,13 +1987,13 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
                }
                check_disk_change(inode->i_bdev);
        } else if (test_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags)) {
-               drive->usage--;
                ret = -EBUSY;
                goto out_put_floppy;
        }
        return 0;
 
 out_put_floppy:
+       floppy->openers--;
        ide_floppy_put(floppy);
        return ret;
 }
@@ -2007,7 +2007,7 @@ static int idefloppy_release(struct inode *inode, struct file *filp)
        
        debug_log(KERN_INFO "Reached idefloppy_release\n");
 
-       if (drive->usage == 1) {
+       if (floppy->openers == 1) {
                /* IOMEGA Clik! drives do not support lock/unlock commands */
                 if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) {
                        idefloppy_create_prevent_cmd(&pc, 0);
@@ -2016,7 +2016,8 @@ static int idefloppy_release(struct inode *inode, struct file *filp)
 
                clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
        }
-       drive->usage--;
+
+       floppy->openers--;
 
        ide_floppy_put(floppy);
 
@@ -2050,7 +2051,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,
                prevent = 0;
                /* fall through */
        case CDROM_LOCKDOOR:
-               if (drive->usage > 1)
+               if (floppy->openers > 1)
                        return -EBUSY;
 
                /* The IOMEGA Clik! Drive doesn't support this command - no room for an eject mechanism */
@@ -2072,7 +2073,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,
                if (!(file->f_mode & 2))
                        return -EPERM;
 
-               if (drive->usage > 1) {
+               if (floppy->openers > 1) {
                        /* Don't format if someone is using the disk */
 
                        clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS,
@@ -2158,7 +2159,7 @@ static int ide_floppy_probe(ide_drive_t *drive)
 
        ide_init_disk(g, drive);
 
-       ide_register_subdriver(drive, &idefloppy_driver);
+       ide_proc_register_driver(drive, &idefloppy_driver);
 
        kref_init(&floppy->kref);