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-cd.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-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 12 |
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 | ||
60 | static void ide_cd_release(struct kref *); | ||
61 | |||
60 | static struct cdrom_info *ide_cd_get(struct gendisk *disk) | 62 | static 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 | ||
72 | static void ide_cd_release(struct kref *); | ||
73 | |||
74 | static void ide_cd_put(struct cdrom_info *cd) | 79 | static 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 | } |