]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-tape.c
[ARM] sparse: quieten arch/arm/kernel/irq.c
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-tape.c
index 82c2afe4d28a3a081a30fd5755de01fb17fc2e44..1bce84b566304115c2834a1742f03284e2c25ce9 100644 (file)
@@ -331,11 +331,10 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
        mutex_lock(&idetape_ref_mutex);
        tape = ide_tape_g(disk);
        if (tape) {
-               kref_get(&tape->kref);
-               if (ide_device_get(tape->drive)) {
-                       kref_put(&tape->kref, ide_tape_release);
+               if (ide_device_get(tape->drive))
                        tape = NULL;
-               }
+               else
+                       kref_get(&tape->kref);
        }
        mutex_unlock(&idetape_ref_mutex);
        return tape;
@@ -343,9 +342,11 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
 
 static void ide_tape_put(struct ide_tape_obj *tape)
 {
+       ide_drive_t *drive = tape->drive;
+
        mutex_lock(&idetape_ref_mutex);
-       ide_device_put(tape->drive);
        kref_put(&tape->kref, ide_tape_release);
+       ide_device_put(drive);
        mutex_unlock(&idetape_ref_mutex);
 }