aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-cd.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-cd.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-cd.c')
-rw-r--r--drivers/ide/ide-cd.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 4e73aeee4053..8f253e5f26a8 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -57,23 +57,29 @@ static DEFINE_MUTEX(idecd_ref_mutex);
57#define ide_cd_g(disk) \ 57#define ide_cd_g(disk) \
58 container_of((disk)->private_data, struct cdrom_info, driver) 58 container_of((disk)->private_data, struct cdrom_info, driver)
59 59
60static void ide_cd_release(struct kref *);
61
60static struct cdrom_info *ide_cd_get(struct gendisk *disk) 62static struct cdrom_info *ide_cd_get(struct gendisk *disk)
61{ 63{
62 struct cdrom_info *cd = NULL; 64 struct cdrom_info *cd = NULL;
63 65
64 mutex_lock(&idecd_ref_mutex); 66 mutex_lock(&idecd_ref_mutex);
65 cd = ide_cd_g(disk); 67 cd = ide_cd_g(disk);
66 if (cd) 68 if (cd) {
67 kref_get(&cd->kref); 69 kref_get(&cd->kref);
70 if (ide_device_get(cd->drive)) {
71 kref_put(&cd->kref, ide_cd_release);
72 cd = NULL;
73 }
74 }
68 mutex_unlock(&idecd_ref_mutex); 75 mutex_unlock(&idecd_ref_mutex);
69 return cd; 76 return cd;
70} 77}
71 78
72static void ide_cd_release(struct kref *);
73
74static void ide_cd_put(struct cdrom_info *cd) 79static void ide_cd_put(struct cdrom_info *cd)
75{ 80{
76 mutex_lock(&idecd_ref_mutex); 81 mutex_lock(&idecd_ref_mutex);
82 ide_device_put(cd->drive);
77 kref_put(&cd->kref, ide_cd_release); 83 kref_put(&cd->kref, ide_cd_release);
78 mutex_unlock(&idecd_ref_mutex); 84 mutex_unlock(&idecd_ref_mutex);
79} 85}