]> err.no Git - linux-2.6/blobdiff - drivers/ide/ide-disk.c
ALSA: wm8750: add missing VREF output
[linux-2.6] / drivers / ide / ide-disk.c
index 3a2e80237c10f5d6daa1a0f377769428af2ba17d..68b9cf0138b05f017427b24c958750bd77356ee8 100644 (file)
@@ -56,24 +56,31 @@ static DEFINE_MUTEX(idedisk_ref_mutex);
 #define ide_disk_g(disk) \
        container_of((disk)->private_data, struct ide_disk_obj, driver)
 
+static void ide_disk_release(struct kref *);
+
 static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
 {
        struct ide_disk_obj *idkp = NULL;
 
        mutex_lock(&idedisk_ref_mutex);
        idkp = ide_disk_g(disk);
-       if (idkp)
-               kref_get(&idkp->kref);
+       if (idkp) {
+               if (ide_device_get(idkp->drive))
+                       idkp = NULL;
+               else
+                       kref_get(&idkp->kref);
+       }
        mutex_unlock(&idedisk_ref_mutex);
        return idkp;
 }
 
-static void ide_disk_release(struct kref *);
-
 static void ide_disk_put(struct ide_disk_obj *idkp)
 {
+       ide_drive_t *drive = idkp->drive;
+
        mutex_lock(&idedisk_ref_mutex);
        kref_put(&idkp->kref, ide_disk_release);
+       ide_device_put(drive);
        mutex_unlock(&idedisk_ref_mutex);
 }
 
@@ -158,7 +165,7 @@ static void ide_tf_set_cmd(ide_drive_t *drive, ide_task_t *task, u8 dma)
        write = (task->tf_flags & IDE_TFLAG_WRITE) ? 1 : 0;
 
        if (dma)
-               index = drive->vdma ? 4 : 8;
+               index = 8;
        else
                index = drive->mult_count ? 0 : 4;