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>
此提交包含在:
Bartlomiej Zolnierkiewicz
2008-07-24 22:53:15 +02:00
父節點 6cdf6eb357
當前提交 08da591e14
共有 8 個檔案被更改,包括 99 行新增13 行删除

查看文件

@@ -322,23 +322,29 @@ static struct class *idetape_sysfs_class;
#define ide_tape_g(disk) \
container_of((disk)->private_data, struct ide_tape_obj, driver)
static void ide_tape_release(struct kref *);
static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
{
struct ide_tape_obj *tape = NULL;
mutex_lock(&idetape_ref_mutex);
tape = ide_tape_g(disk);
if (tape)
if (tape) {
kref_get(&tape->kref);
if (ide_device_get(tape->drive)) {
kref_put(&tape->kref, ide_tape_release);
tape = NULL;
}
}
mutex_unlock(&idetape_ref_mutex);
return tape;
}
static void ide_tape_release(struct kref *);
static void ide_tape_put(struct ide_tape_obj *tape)
{
mutex_lock(&idetape_ref_mutex);
ide_device_put(tape->drive);
kref_put(&tape->kref, ide_tape_release);
mutex_unlock(&idetape_ref_mutex);
}