aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-tape.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r--drivers/ide/ide-tape.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 6962ca4891a1..789f3428f072 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -322,23 +322,29 @@ static struct class *idetape_sysfs_class;
322#define ide_tape_g(disk) \ 322#define ide_tape_g(disk) \
323 container_of((disk)->private_data, struct ide_tape_obj, driver) 323 container_of((disk)->private_data, struct ide_tape_obj, driver)
324 324
325static void ide_tape_release(struct kref *);
326
325static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) 327static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
326{ 328{
327 struct ide_tape_obj *tape = NULL; 329 struct ide_tape_obj *tape = NULL;
328 330
329 mutex_lock(&idetape_ref_mutex); 331 mutex_lock(&idetape_ref_mutex);
330 tape = ide_tape_g(disk); 332 tape = ide_tape_g(disk);
331 if (tape) 333 if (tape) {
332 kref_get(&tape->kref); 334 kref_get(&tape->kref);
335 if (ide_device_get(tape->drive)) {
336 kref_put(&tape->kref, ide_tape_release);
337 tape = NULL;
338 }
339 }
333 mutex_unlock(&idetape_ref_mutex); 340 mutex_unlock(&idetape_ref_mutex);
334 return tape; 341 return tape;
335} 342}
336 343
337static void ide_tape_release(struct kref *);
338
339static void ide_tape_put(struct ide_tape_obj *tape) 344static void ide_tape_put(struct ide_tape_obj *tape)
340{ 345{
341 mutex_lock(&idetape_ref_mutex); 346 mutex_lock(&idetape_ref_mutex);
347 ide_device_put(tape->drive);
342 kref_put(&tape->kref, ide_tape_release); 348 kref_put(&tape->kref, ide_tape_release);
343 mutex_unlock(&idetape_ref_mutex); 349 mutex_unlock(&idetape_ref_mutex);
344} 350}