aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/ide-cd.c12
-rw-r--r--drivers/ide/ide-disk.c11
-rw-r--r--drivers/ide/ide-floppy.c11
-rw-r--r--drivers/ide/ide-tape.c11
-rw-r--r--drivers/scsi/ide-scsi.c11
5 files changed, 31 insertions, 25 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index e617cf08aef6..e19caa1453a3 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -66,11 +66,11 @@ static struct cdrom_info *ide_cd_get(struct gendisk *disk)
66 mutex_lock(&idecd_ref_mutex); 66 mutex_lock(&idecd_ref_mutex);
67 cd = ide_cd_g(disk); 67 cd = ide_cd_g(disk);
68 if (cd) { 68 if (cd) {
69 kref_get(&cd->kref); 69 if (ide_device_get(cd->drive))
70 if (ide_device_get(cd->drive)) {
71 kref_put(&cd->kref, ide_cd_release);
72 cd = NULL; 70 cd = NULL;
73 } 71 else
72 kref_get(&cd->kref);
73
74 } 74 }
75 mutex_unlock(&idecd_ref_mutex); 75 mutex_unlock(&idecd_ref_mutex);
76 return cd; 76 return cd;
@@ -78,9 +78,11 @@ static struct cdrom_info *ide_cd_get(struct gendisk *disk)
78 78
79static void ide_cd_put(struct cdrom_info *cd) 79static void ide_cd_put(struct cdrom_info *cd)
80{ 80{
81 ide_drive_t *drive = cd->drive;
82
81 mutex_lock(&idecd_ref_mutex); 83 mutex_lock(&idecd_ref_mutex);
82 ide_device_put(cd->drive);
83 kref_put(&cd->kref, ide_cd_release); 84 kref_put(&cd->kref, ide_cd_release);
85 ide_device_put(drive);
84 mutex_unlock(&idecd_ref_mutex); 86 mutex_unlock(&idecd_ref_mutex);
85} 87}
86 88
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 28d85b410f7c..68b9cf0138b0 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -65,11 +65,10 @@ static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
65 mutex_lock(&idedisk_ref_mutex); 65 mutex_lock(&idedisk_ref_mutex);
66 idkp = ide_disk_g(disk); 66 idkp = ide_disk_g(disk);
67 if (idkp) { 67 if (idkp) {
68 kref_get(&idkp->kref); 68 if (ide_device_get(idkp->drive))
69 if (ide_device_get(idkp->drive)) {
70 kref_put(&idkp->kref, ide_disk_release);
71 idkp = NULL; 69 idkp = NULL;
72 } 70 else
71 kref_get(&idkp->kref);
73 } 72 }
74 mutex_unlock(&idedisk_ref_mutex); 73 mutex_unlock(&idedisk_ref_mutex);
75 return idkp; 74 return idkp;
@@ -77,9 +76,11 @@ static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
77 76
78static void ide_disk_put(struct ide_disk_obj *idkp) 77static void ide_disk_put(struct ide_disk_obj *idkp)
79{ 78{
79 ide_drive_t *drive = idkp->drive;
80
80 mutex_lock(&idedisk_ref_mutex); 81 mutex_lock(&idedisk_ref_mutex);
81 ide_device_put(idkp->drive);
82 kref_put(&idkp->kref, ide_disk_release); 82 kref_put(&idkp->kref, ide_disk_release);
83 ide_device_put(drive);
83 mutex_unlock(&idedisk_ref_mutex); 84 mutex_unlock(&idedisk_ref_mutex);
84} 85}
85 86
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index ca11a26746f1..e9034c0125f3 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -167,11 +167,10 @@ static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk)
167 mutex_lock(&idefloppy_ref_mutex); 167 mutex_lock(&idefloppy_ref_mutex);
168 floppy = ide_floppy_g(disk); 168 floppy = ide_floppy_g(disk);
169 if (floppy) { 169 if (floppy) {
170 kref_get(&floppy->kref); 170 if (ide_device_get(floppy->drive))
171 if (ide_device_get(floppy->drive)) {
172 kref_put(&floppy->kref, idefloppy_cleanup_obj);
173 floppy = NULL; 171 floppy = NULL;
174 } 172 else
173 kref_get(&floppy->kref);
175 } 174 }
176 mutex_unlock(&idefloppy_ref_mutex); 175 mutex_unlock(&idefloppy_ref_mutex);
177 return floppy; 176 return floppy;
@@ -179,9 +178,11 @@ static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk)
179 178
180static void ide_floppy_put(struct ide_floppy_obj *floppy) 179static void ide_floppy_put(struct ide_floppy_obj *floppy)
181{ 180{
181 ide_drive_t *drive = floppy->drive;
182
182 mutex_lock(&idefloppy_ref_mutex); 183 mutex_lock(&idefloppy_ref_mutex);
183 ide_device_put(floppy->drive);
184 kref_put(&floppy->kref, idefloppy_cleanup_obj); 184 kref_put(&floppy->kref, idefloppy_cleanup_obj);
185 ide_device_put(drive);
185 mutex_unlock(&idefloppy_ref_mutex); 186 mutex_unlock(&idefloppy_ref_mutex);
186} 187}
187 188
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 82c2afe4d28a..1bce84b56630 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -331,11 +331,10 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
331 mutex_lock(&idetape_ref_mutex); 331 mutex_lock(&idetape_ref_mutex);
332 tape = ide_tape_g(disk); 332 tape = ide_tape_g(disk);
333 if (tape) { 333 if (tape) {
334 kref_get(&tape->kref); 334 if (ide_device_get(tape->drive))
335 if (ide_device_get(tape->drive)) {
336 kref_put(&tape->kref, ide_tape_release);
337 tape = NULL; 335 tape = NULL;
338 } 336 else
337 kref_get(&tape->kref);
339 } 338 }
340 mutex_unlock(&idetape_ref_mutex); 339 mutex_unlock(&idetape_ref_mutex);
341 return tape; 340 return tape;
@@ -343,9 +342,11 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
343 342
344static void ide_tape_put(struct ide_tape_obj *tape) 343static void ide_tape_put(struct ide_tape_obj *tape)
345{ 344{
345 ide_drive_t *drive = tape->drive;
346
346 mutex_lock(&idetape_ref_mutex); 347 mutex_lock(&idetape_ref_mutex);
347 ide_device_put(tape->drive);
348 kref_put(&tape->kref, ide_tape_release); 348 kref_put(&tape->kref, ide_tape_release);
349 ide_device_put(drive);
349 mutex_unlock(&idetape_ref_mutex); 350 mutex_unlock(&idetape_ref_mutex);
350} 351}
351 352
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index b40a673985aa..461331d3dc45 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -102,11 +102,10 @@ static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk)
102 mutex_lock(&idescsi_ref_mutex); 102 mutex_lock(&idescsi_ref_mutex);
103 scsi = ide_scsi_g(disk); 103 scsi = ide_scsi_g(disk);
104 if (scsi) { 104 if (scsi) {
105 scsi_host_get(scsi->host); 105 if (ide_device_get(scsi->drive))
106 if (ide_device_get(scsi->drive)) {
107 scsi_host_put(scsi->host);
108 scsi = NULL; 106 scsi = NULL;
109 } 107 else
108 scsi_host_get(scsi->host);
110 } 109 }
111 mutex_unlock(&idescsi_ref_mutex); 110 mutex_unlock(&idescsi_ref_mutex);
112 return scsi; 111 return scsi;
@@ -114,9 +113,11 @@ static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk)
114 113
115static void ide_scsi_put(struct ide_scsi_obj *scsi) 114static void ide_scsi_put(struct ide_scsi_obj *scsi)
116{ 115{
116 ide_drive_t *drive = scsi->drive;
117
117 mutex_lock(&idescsi_ref_mutex); 118 mutex_lock(&idescsi_ref_mutex);
118 ide_device_put(scsi->drive);
119 scsi_host_put(scsi->host); 119 scsi_host_put(scsi->host);
120 ide_device_put(drive);
120 mutex_unlock(&idescsi_ref_mutex); 121 mutex_unlock(&idescsi_ref_mutex);
121} 122}
122 123