diff options
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r-- | drivers/ide/ide-disk.c | 12 |
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 | ||
59 | static void ide_disk_release(struct kref *); | ||
60 | |||
59 | static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) | 61 | static 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 | ||
71 | static void ide_disk_release(struct kref *); | ||
72 | |||
73 | static void ide_disk_put(struct ide_disk_obj *idkp) | 78 | static 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 | } |