aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-disk.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-24 16:53:15 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-24 16:53:15 -0400
commit08da591e14cf87247ec09b17c350235157a92fc3 (patch)
treed00a02154071c7013c31bc8dd1d3c12c86d5daca /drivers/ide/ide-disk.c
parent6cdf6eb357c2681596b7b1672b92396ba82333d4 (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-disk.c')
-rw-r--r--drivers/ide/ide-disk.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index df5fe5756871..28d85b410f7c 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -56,23 +56,29 @@ static DEFINE_MUTEX(idedisk_ref_mutex);
56#define ide_disk_g(disk) \ 56#define ide_disk_g(disk) \
57 container_of((disk)->private_data, struct ide_disk_obj, driver) 57 container_of((disk)->private_data, struct ide_disk_obj, driver)
58 58
59static void ide_disk_release(struct kref *);
60
59static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) 61static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
60{ 62{
61 struct ide_disk_obj *idkp = NULL; 63 struct ide_disk_obj *idkp = NULL;
62 64
63 mutex_lock(&idedisk_ref_mutex); 65 mutex_lock(&idedisk_ref_mutex);
64 idkp = ide_disk_g(disk); 66 idkp = ide_disk_g(disk);
65 if (idkp) 67 if (idkp) {
66 kref_get(&idkp->kref); 68 kref_get(&idkp->kref);
69 if (ide_device_get(idkp->drive)) {
70 kref_put(&idkp->kref, ide_disk_release);
71 idkp = NULL;
72 }
73 }
67 mutex_unlock(&idedisk_ref_mutex); 74 mutex_unlock(&idedisk_ref_mutex);
68 return idkp; 75 return idkp;
69} 76}
70 77
71static void ide_disk_release(struct kref *);
72
73static void ide_disk_put(struct ide_disk_obj *idkp) 78static void ide_disk_put(struct ide_disk_obj *idkp)
74{ 79{
75 mutex_lock(&idedisk_ref_mutex); 80 mutex_lock(&idedisk_ref_mutex);
81 ide_device_put(idkp->drive);
76 kref_put(&idkp->kref, ide_disk_release); 82 kref_put(&idkp->kref, ide_disk_release);
77 mutex_unlock(&idedisk_ref_mutex); 83 mutex_unlock(&idedisk_ref_mutex);
78} 84}