aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-gd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-gd.c')
-rw-r--r--drivers/ide/ide-gd.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index 7857b209c6df..047109419902 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -25,7 +25,7 @@ module_param(debug_mask, ulong, 0644);
25 25
26static DEFINE_MUTEX(ide_disk_ref_mutex); 26static DEFINE_MUTEX(ide_disk_ref_mutex);
27 27
28static void ide_disk_release(struct kref *); 28static void ide_disk_release(struct device *);
29 29
30static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) 30static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
31{ 31{
@@ -37,7 +37,7 @@ static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
37 if (ide_device_get(idkp->drive)) 37 if (ide_device_get(idkp->drive))
38 idkp = NULL; 38 idkp = NULL;
39 else 39 else
40 kref_get(&idkp->kref); 40 get_device(&idkp->dev);
41 } 41 }
42 mutex_unlock(&ide_disk_ref_mutex); 42 mutex_unlock(&ide_disk_ref_mutex);
43 return idkp; 43 return idkp;
@@ -48,7 +48,7 @@ static void ide_disk_put(struct ide_disk_obj *idkp)
48 ide_drive_t *drive = idkp->drive; 48 ide_drive_t *drive = idkp->drive;
49 49
50 mutex_lock(&ide_disk_ref_mutex); 50 mutex_lock(&ide_disk_ref_mutex);
51 kref_put(&idkp->kref, ide_disk_release); 51 put_device(&idkp->dev);
52 ide_device_put(drive); 52 ide_device_put(drive);
53 mutex_unlock(&ide_disk_ref_mutex); 53 mutex_unlock(&ide_disk_ref_mutex);
54} 54}
@@ -66,17 +66,18 @@ static void ide_gd_remove(ide_drive_t *drive)
66 struct gendisk *g = idkp->disk; 66 struct gendisk *g = idkp->disk;
67 67
68 ide_proc_unregister_driver(drive, idkp->driver); 68 ide_proc_unregister_driver(drive, idkp->driver);
69 69 device_del(&idkp->dev);
70 del_gendisk(g); 70 del_gendisk(g);
71
72 drive->disk_ops->flush(drive); 71 drive->disk_ops->flush(drive);
73 72
74 ide_disk_put(idkp); 73 mutex_lock(&ide_disk_ref_mutex);
74 put_device(&idkp->dev);
75 mutex_unlock(&ide_disk_ref_mutex);
75} 76}
76 77
77static void ide_disk_release(struct kref *kref) 78static void ide_disk_release(struct device *dev)
78{ 79{
79 struct ide_disk_obj *idkp = to_ide_drv(kref, ide_disk_obj); 80 struct ide_disk_obj *idkp = to_ide_drv(dev, ide_disk_obj);
80 ide_drive_t *drive = idkp->drive; 81 ide_drive_t *drive = idkp->drive;
81 struct gendisk *g = idkp->disk; 82 struct gendisk *g = idkp->disk;
82 83
@@ -348,7 +349,12 @@ static int ide_gd_probe(ide_drive_t *drive)
348 349
349 ide_init_disk(g, drive); 350 ide_init_disk(g, drive);
350 351
351 kref_init(&idkp->kref); 352 idkp->dev.parent = &drive->gendev;
353 idkp->dev.release = ide_disk_release;
354 dev_set_name(&idkp->dev, dev_name(&drive->gendev));
355
356 if (device_register(&idkp->dev))
357 goto out_free_disk;
352 358
353 idkp->drive = drive; 359 idkp->drive = drive;
354 idkp->driver = &ide_gd_driver; 360 idkp->driver = &ide_gd_driver;
@@ -373,6 +379,8 @@ static int ide_gd_probe(ide_drive_t *drive)
373 add_disk(g); 379 add_disk(g);
374 return 0; 380 return 0;
375 381
382out_free_disk:
383 put_disk(g);
376out_free_idkp: 384out_free_idkp:
377 kfree(idkp); 385 kfree(idkp);
378failed: 386failed: