Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[powerpc.git] / drivers / ide / ide-floppy.c
index adbe9f7..57cd21c 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;
@@ -588,7 +589,7 @@ static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs)
        /* Why does this happen? */
        if (!rq)
                return 0;
-       if (!(rq->flags & REQ_SPECIAL)) { //if (!IDEFLOPPY_RQ_CMD (rq->cmd)) {
+       if (!blk_special_request(rq)) {
                /* our real local end request function */
                ide_end_request(drive, uptodate, nsecs);
                return 0;
@@ -689,7 +690,7 @@ static void idefloppy_queue_pc_head (ide_drive_t *drive,idefloppy_pc_t *pc,struc
 
        ide_init_drive_cmd(rq);
        rq->buffer = (char *) pc;
-       rq->flags = REQ_SPECIAL;        //rq->cmd = IDEFLOPPY_PC_RQ;
+       rq->cmd_type = REQ_TYPE_SPECIAL;
        rq->rq_disk = floppy->disk;
        (void) ide_do_drive_cmd(drive, rq, ide_preempt);
 }
@@ -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)
@@ -1250,7 +1251,7 @@ static void idefloppy_create_rw_cmd (idefloppy_floppy_t *floppy, idefloppy_pc_t
        pc->callback = &idefloppy_rw_callback;
        pc->rq = rq;
        pc->b_count = cmd == READ ? 0 : rq->bio->bi_size;
-       if (rq->flags & REQ_RW)
+       if (rq->cmd_flags & REQ_RW)
                set_bit(PC_WRITING, &pc->flags);
        pc->buffer = NULL;
        pc->request_transfer = pc->buffer_size = blocks * floppy->block_size;
@@ -1281,8 +1282,7 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request
        idefloppy_pc_t *pc;
        unsigned long block = (unsigned long)block_s;
 
-       debug_log(KERN_INFO "rq_status: %d, dev: %s, flags: %lx, errors: %d\n",
-                       rq->rq_status,
+       debug_log(KERN_INFO "dev: %s, flags: %lx, errors: %d\n",
                        rq->rq_disk ? rq->rq_disk->disk_name : "?",
                        rq->flags, rq->errors);
        debug_log(KERN_INFO "sector: %ld, nr_sectors: %ld, "
@@ -1303,7 +1303,7 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request
                idefloppy_do_end_request(drive, 0, 0);
                return ide_stopped;
        }
-       if (rq->flags & REQ_CMD) {
+       if (blk_fs_request(rq)) {
                if (((long)rq->sector % floppy->bs_factor) ||
                    (rq->nr_sectors % floppy->bs_factor)) {
                        printk("%s: unsupported r/w request size\n",
@@ -1313,9 +1313,9 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request
                }
                pc = idefloppy_next_pc_storage(drive);
                idefloppy_create_rw_cmd(floppy, pc, rq, block);
-       } else if (rq->flags & REQ_SPECIAL) {
+       } else if (blk_special_request(rq)) {
                pc = (idefloppy_pc_t *) rq->buffer;
-       } else if (rq->flags & REQ_BLOCK_PC) {
+       } else if (blk_pc_request(rq)) {
                pc = idefloppy_next_pc_storage(drive);
                if (idefloppy_blockpc_cmd(floppy, pc, rq)) {
                        idefloppy_do_end_request(drive, 0, 0);
@@ -1343,7 +1343,7 @@ static int idefloppy_queue_pc_tail (ide_drive_t *drive,idefloppy_pc_t *pc)
 
        ide_init_drive_cmd (&rq);
        rq.buffer = (char *) pc;
-       rq.flags = REQ_SPECIAL;         //      rq.cmd = IDEFLOPPY_PC_RQ;
+       rq.cmd_type = REQ_TYPE_SPECIAL;
        rq.rq_disk = floppy->disk;
 
        return ide_do_drive_cmd(drive, &rq, ide_wait);
@@ -1434,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);
@@ -1636,7 +1637,7 @@ static int idefloppy_begin_format(ide_drive_t *drive, int __user *arg)
 /*
 ** Get ATAPI_FORMAT_UNIT progress indication.
 **
-** Userland gives a pointer to an int.  The int is set to a progresss
+** Userland gives a pointer to an int.  The int is set to a progress
 ** indicator 0-65536, with 65536=100%.
 **
 ** If the drive does not support format progress indication, we just check
@@ -1950,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 */
 
@@ -1970,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;
                }
@@ -1988,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;
 }
@@ -2008,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);
@@ -2017,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);
 
@@ -2051,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 */
@@ -2073,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,
@@ -2148,7 +2148,7 @@ static int ide_floppy_probe(ide_drive_t *drive)
                printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name);
                goto failed;
        }
-       if ((floppy = (idefloppy_floppy_t *) kzalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) {
+       if ((floppy = kzalloc(sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) {
                printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
                goto failed;
        }