diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-24 16:53:15 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-24 16:53:15 -0400 |
commit | 08da591e14cf87247ec09b17c350235157a92fc3 (patch) | |
tree | d00a02154071c7013c31bc8dd1d3c12c86d5daca /drivers/ide/ide-tape.c | |
parent | 6cdf6eb357c2681596b7b1672b92396ba82333d4 (diff) |
ide: add ide_device_{get,put}() helpers
* Add 'struct ide_host *host' field to ide_hwif_t and set it
in ide_host_alloc_all().
* Add ide_device_{get,put}() helpers loosely based on SCSI's
scsi_device_{get,put}() ones.
* Convert IDE device drivers to use ide_device_{get,put}().
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r-- | drivers/ide/ide-tape.c | 12 |
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 | ||
325 | static void ide_tape_release(struct kref *); | ||
326 | |||
325 | static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) | 327 | static 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 | ||
337 | static void ide_tape_release(struct kref *); | ||
338 | |||
339 | static void ide_tape_put(struct ide_tape_obj *tape) | 344 | static 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 | } |