]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide.c
ide: add device flags
[linux-2.6-omap-h63xx.git] / drivers / ide / ide.c
index 9dcf5aed92cbcd1f1bf390cef2678ef7f6d1afa2..78776bbb537e01aa03757adee980886f957c6a0f 100644 (file)
@@ -138,7 +138,7 @@ static void __ide_port_unregister_devices(ide_hwif_t *hwif)
        for (i = 0; i < MAX_DRIVES; i++) {
                ide_drive_t *drive = &hwif->drives[i];
 
-               if (drive->present) {
+               if (drive->dev_flags & IDE_DFLAG_PRESENT) {
                        spin_unlock_irq(&ide_lock);
                        device_unregister(&drive->gendev);
                        wait_for_completion(&drive->gendev_rel_comp);
@@ -254,7 +254,7 @@ ide_devset_get(io_32bit, io_32bit);
 
 static int set_io_32bit(ide_drive_t *drive, int arg)
 {
-       if (drive->no_io_32bit)
+       if (drive->dev_flags & IDE_DFLAG_NO_IO_32BIT)
                return -EPERM;
 
        if (arg < 0 || arg > 1 + (SUPPORT_VLB_SYNC << 1))
@@ -265,19 +265,22 @@ static int set_io_32bit(ide_drive_t *drive, int arg)
        return 0;
 }
 
-ide_devset_get(ksettings, keep_settings);
+ide_devset_get_flag(ksettings, IDE_DFLAG_KEEP_SETTINGS);
 
 static int set_ksettings(ide_drive_t *drive, int arg)
 {
        if (arg < 0 || arg > 1)
                return -EINVAL;
 
-       drive->keep_settings = arg;
+       if (arg)
+               drive->dev_flags |= IDE_DFLAG_KEEP_SETTINGS;
+       else
+               drive->dev_flags &= ~IDE_DFLAG_KEEP_SETTINGS;
 
        return 0;
 }
 
-ide_devset_get(using_dma, using_dma);
+ide_devset_get_flag(using_dma, IDE_DFLAG_USING_DMA);
 
 static int set_using_dma(ide_drive_t *drive, int arg)
 {
@@ -339,17 +342,20 @@ static int set_pio_mode(ide_drive_t *drive, int arg)
        return 0;
 }
 
-ide_devset_get(unmaskirq, unmask);
+ide_devset_get_flag(unmaskirq, IDE_DFLAG_UNMASK);
 
 static int set_unmaskirq(ide_drive_t *drive, int arg)
 {
-       if (drive->no_unmask)
+       if (drive->dev_flags & IDE_DFLAG_NO_UNMASK)
                return -EPERM;
 
        if (arg < 0 || arg > 1)
                return -EINVAL;
 
-       drive->unmask = arg;
+       if (arg)
+               drive->dev_flags |= IDE_DFLAG_UNMASK;
+       else
+               drive->dev_flags &= ~IDE_DFLAG_UNMASK;
 
        return 0;
 }
@@ -365,15 +371,15 @@ __IDE_DEVSET(pio_mode, 0, NULL, set_pio_mode);
 
 static int generic_ide_suspend(struct device *dev, pm_message_t mesg)
 {
-       ide_drive_t *drive = dev->driver_data;
+       ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive);
        ide_hwif_t *hwif = HWIF(drive);
        struct request *rq;
        struct request_pm_state rqpm;
        ide_task_t args;
        int ret;
 
-       /* Call ACPI _GTM only once */
-       if (!(drive->dn % 2))
+       /* call ACPI _GTM only once */
+       if ((drive->dn & 1) == 0 || pair == NULL)
                ide_acpi_get_timing(hwif);
 
        memset(&rqpm, 0, sizeof(rqpm));
@@ -389,26 +395,25 @@ static int generic_ide_suspend(struct device *dev, pm_message_t mesg)
 
        ret = blk_execute_rq(drive->queue, NULL, rq, 0);
        blk_put_request(rq);
-       /* only call ACPI _PS3 after both drivers are suspended */
-       if (!ret && (((drive->dn % 2) && hwif->drives[0].present
-                && hwif->drives[1].present)
-                || !hwif->drives[0].present
-                || !hwif->drives[1].present))
+
+       /* call ACPI _PS3 only after both devices are suspended */
+       if (ret == 0 && ((drive->dn & 1) || pair == NULL))
                ide_acpi_set_state(hwif, 0);
+
        return ret;
 }
 
 static int generic_ide_resume(struct device *dev)
 {
-       ide_drive_t *drive = dev->driver_data;
+       ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive);
        ide_hwif_t *hwif = HWIF(drive);
        struct request *rq;
        struct request_pm_state rqpm;
        ide_task_t args;
        int err;
 
-       /* Call ACPI _STM only once */
-       if (!(drive->dn % 2)) {
+       /* call ACPI _PS0 / _STM only once */
+       if ((drive->dn & 1) == 0 || pair == NULL) {
                ide_acpi_set_state(hwif, 1);
                ide_acpi_push_timing(hwif);
        }
@@ -714,16 +719,16 @@ static void ide_dev_apply_params(ide_drive_t *drive)
 
        if (ide_nodma & (1 << i)) {
                printk(KERN_INFO "ide: disallowing DMA for %s\n", drive->name);
-               drive->nodma = 1;
+               drive->dev_flags |= IDE_DFLAG_NODMA;
        }
        if (ide_noflush & (1 << i)) {
                printk(KERN_INFO "ide: disabling flush requests for %s\n",
                                 drive->name);
-               drive->noflush = 1;
+               drive->dev_flags |= IDE_DFLAG_NOFLUSH;
        }
        if (ide_noprobe & (1 << i)) {
                printk(KERN_INFO "ide: skipping probe for %s\n", drive->name);
-               drive->noprobe = 1;
+               drive->dev_flags |= IDE_DFLAG_NOPROBE;
        }
        if (ide_nowerr & (1 << i)) {
                printk(KERN_INFO "ide: ignoring the ATA_DF bit for %s\n",
@@ -732,7 +737,7 @@ static void ide_dev_apply_params(ide_drive_t *drive)
        }
        if (ide_cdroms & (1 << i)) {
                printk(KERN_INFO "ide: forcing %s as a CD-ROM\n", drive->name);
-               drive->present = 1;
+               drive->dev_flags |= IDE_DFLAG_PRESENT;
                drive->media = ide_cdrom;
                /* an ATAPI device ignores DRDY */
                drive->ready_stat = 0;
@@ -741,11 +746,12 @@ static void ide_dev_apply_params(ide_drive_t *drive)
                drive->cyl  = drive->bios_cyl  = ide_disks_chs[i].cyl;
                drive->head = drive->bios_head = ide_disks_chs[i].head;
                drive->sect = drive->bios_sect = ide_disks_chs[i].sect;
-               drive->forced_geom = 1;
+
                printk(KERN_INFO "ide: forcing %s as a disk (%d/%d/%d)\n",
                                 drive->name,
                                 drive->cyl, drive->head, drive->sect);
-               drive->present = 1;
+
+               drive->dev_flags |= IDE_DFLAG_FORCED_GEOM | IDE_DFLAG_PRESENT;
                drive->media = ide_disk;
                drive->ready_stat = ATA_DRDY;
        }