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>
此提交包含在:
@@ -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);
|
||||
}
|
||||
|
新增問題並參考
封鎖使用者