aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-disk.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-08-21 07:28:24 -0400
committerIngo Molnar <mingo@elte.hu>2008-08-21 07:28:24 -0400
commit470fba7ebe60ad9185056b080b331abad24b4df9 (patch)
treef83bc13d97adaf5dd0e0f1d6a157b890f868577f /drivers/ide/ide-disk.c
parent7225e75144b9718cbbe1820d9c011c809d5773fd (diff)
parent6a55617ed5d1aa62b850de2cf66f5ede2eef4825 (diff)
Merge branch 'linus' into x86/doc
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r--drivers/ide/ide-disk.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 3a2e80237c10..68b9cf0138b0 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -56,24 +56,31 @@ static DEFINE_MUTEX(idedisk_ref_mutex);
56#define ide_disk_g(disk) \ 56#define ide_disk_g(disk) \
57 container_of((disk)->private_data, struct ide_disk_obj, driver) 57 container_of((disk)->private_data, struct ide_disk_obj, driver)
58 58
59static void ide_disk_release(struct kref *);
60
59static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) 61static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
60{ 62{
61 struct ide_disk_obj *idkp = NULL; 63 struct ide_disk_obj *idkp = NULL;
62 64
63 mutex_lock(&idedisk_ref_mutex); 65 mutex_lock(&idedisk_ref_mutex);
64 idkp = ide_disk_g(disk); 66 idkp = ide_disk_g(disk);
65 if (idkp) 67 if (idkp) {
66 kref_get(&idkp->kref); 68 if (ide_device_get(idkp->drive))
69 idkp = NULL;
70 else
71 kref_get(&idkp->kref);
72 }
67 mutex_unlock(&idedisk_ref_mutex); 73 mutex_unlock(&idedisk_ref_mutex);
68 return idkp; 74 return idkp;
69} 75}
70 76
71static void ide_disk_release(struct kref *);
72
73static void ide_disk_put(struct ide_disk_obj *idkp) 77static void ide_disk_put(struct ide_disk_obj *idkp)
74{ 78{
79 ide_drive_t *drive = idkp->drive;
80
75 mutex_lock(&idedisk_ref_mutex); 81 mutex_lock(&idedisk_ref_mutex);
76 kref_put(&idkp->kref, ide_disk_release); 82 kref_put(&idkp->kref, ide_disk_release);
83 ide_device_put(drive);
77 mutex_unlock(&idedisk_ref_mutex); 84 mutex_unlock(&idedisk_ref_mutex);
78} 85}
79 86
@@ -158,7 +165,7 @@ static void ide_tf_set_cmd(ide_drive_t *drive, ide_task_t *task, u8 dma)
158 write = (task->tf_flags & IDE_TFLAG_WRITE) ? 1 : 0; 165 write = (task->tf_flags & IDE_TFLAG_WRITE) ? 1 : 0;
159 166
160 if (dma) 167 if (dma)
161 index = drive->vdma ? 4 : 8; 168 index = 8;
162 else 169 else
163 index = drive->mult_count ? 0 : 4; 170 index = drive->mult_count ? 0 : 4;
164 171