diff options
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 0bfeb0c79d6e..ddfbea41d296 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -55,7 +55,7 @@ | |||
55 | 55 | ||
56 | static DEFINE_MUTEX(idecd_ref_mutex); | 56 | static DEFINE_MUTEX(idecd_ref_mutex); |
57 | 57 | ||
58 | static void ide_cd_release(struct kref *); | 58 | static void ide_cd_release(struct device *); |
59 | 59 | ||
60 | static struct cdrom_info *ide_cd_get(struct gendisk *disk) | 60 | static struct cdrom_info *ide_cd_get(struct gendisk *disk) |
61 | { | 61 | { |
@@ -67,7 +67,7 @@ static struct cdrom_info *ide_cd_get(struct gendisk *disk) | |||
67 | if (ide_device_get(cd->drive)) | 67 | if (ide_device_get(cd->drive)) |
68 | cd = NULL; | 68 | cd = NULL; |
69 | else | 69 | else |
70 | kref_get(&cd->kref); | 70 | get_device(&cd->dev); |
71 | 71 | ||
72 | } | 72 | } |
73 | mutex_unlock(&idecd_ref_mutex); | 73 | mutex_unlock(&idecd_ref_mutex); |
@@ -79,7 +79,7 @@ static void ide_cd_put(struct cdrom_info *cd) | |||
79 | ide_drive_t *drive = cd->drive; | 79 | ide_drive_t *drive = cd->drive; |
80 | 80 | ||
81 | mutex_lock(&idecd_ref_mutex); | 81 | mutex_lock(&idecd_ref_mutex); |
82 | kref_put(&cd->kref, ide_cd_release); | 82 | put_device(&cd->dev); |
83 | ide_device_put(drive); | 83 | ide_device_put(drive); |
84 | mutex_unlock(&idecd_ref_mutex); | 84 | mutex_unlock(&idecd_ref_mutex); |
85 | } | 85 | } |
@@ -194,6 +194,14 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
194 | bio_sectors = max(bio_sectors(failed_command->bio), 4U); | 194 | bio_sectors = max(bio_sectors(failed_command->bio), 4U); |
195 | sector &= ~(bio_sectors - 1); | 195 | sector &= ~(bio_sectors - 1); |
196 | 196 | ||
197 | /* | ||
198 | * The SCSI specification allows for the value | ||
199 | * returned by READ CAPACITY to be up to 75 2K | ||
200 | * sectors past the last readable block. | ||
201 | * Therefore, if we hit a medium error within the | ||
202 | * last 75 2K sectors, we decrease the saved size | ||
203 | * value. | ||
204 | */ | ||
197 | if (sector < get_capacity(info->disk) && | 205 | if (sector < get_capacity(info->disk) && |
198 | drive->probed_capacity - sector < 4 * 75) | 206 | drive->probed_capacity - sector < 4 * 75) |
199 | set_capacity(info->disk, sector); | 207 | set_capacity(info->disk, sector); |
@@ -1790,15 +1798,17 @@ static void ide_cd_remove(ide_drive_t *drive) | |||
1790 | ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); | 1798 | ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); |
1791 | 1799 | ||
1792 | ide_proc_unregister_driver(drive, info->driver); | 1800 | ide_proc_unregister_driver(drive, info->driver); |
1793 | 1801 | device_del(&info->dev); | |
1794 | del_gendisk(info->disk); | 1802 | del_gendisk(info->disk); |
1795 | 1803 | ||
1796 | ide_cd_put(info); | 1804 | mutex_lock(&idecd_ref_mutex); |
1805 | put_device(&info->dev); | ||
1806 | mutex_unlock(&idecd_ref_mutex); | ||
1797 | } | 1807 | } |
1798 | 1808 | ||
1799 | static void ide_cd_release(struct kref *kref) | 1809 | static void ide_cd_release(struct device *dev) |
1800 | { | 1810 | { |
1801 | struct cdrom_info *info = to_ide_drv(kref, cdrom_info); | 1811 | struct cdrom_info *info = to_ide_drv(dev, cdrom_info); |
1802 | struct cdrom_device_info *devinfo = &info->devinfo; | 1812 | struct cdrom_device_info *devinfo = &info->devinfo; |
1803 | ide_drive_t *drive = info->drive; | 1813 | ide_drive_t *drive = info->drive; |
1804 | struct gendisk *g = info->disk; | 1814 | struct gendisk *g = info->disk; |
@@ -1997,7 +2007,12 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
1997 | 2007 | ||
1998 | ide_init_disk(g, drive); | 2008 | ide_init_disk(g, drive); |
1999 | 2009 | ||
2000 | kref_init(&info->kref); | 2010 | info->dev.parent = &drive->gendev; |
2011 | info->dev.release = ide_cd_release; | ||
2012 | dev_set_name(&info->dev, dev_name(&drive->gendev)); | ||
2013 | |||
2014 | if (device_register(&info->dev)) | ||
2015 | goto out_free_disk; | ||
2001 | 2016 | ||
2002 | info->drive = drive; | 2017 | info->drive = drive; |
2003 | info->driver = &ide_cdrom_driver; | 2018 | info->driver = &ide_cdrom_driver; |
@@ -2011,7 +2026,7 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
2011 | g->driverfs_dev = &drive->gendev; | 2026 | g->driverfs_dev = &drive->gendev; |
2012 | g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE; | 2027 | g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE; |
2013 | if (ide_cdrom_setup(drive)) { | 2028 | if (ide_cdrom_setup(drive)) { |
2014 | ide_cd_release(&info->kref); | 2029 | put_device(&info->dev); |
2015 | goto failed; | 2030 | goto failed; |
2016 | } | 2031 | } |
2017 | 2032 | ||
@@ -2021,6 +2036,8 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
2021 | add_disk(g); | 2036 | add_disk(g); |
2022 | return 0; | 2037 | return 0; |
2023 | 2038 | ||
2039 | out_free_disk: | ||
2040 | put_disk(g); | ||
2024 | out_free_cd: | 2041 | out_free_cd: |
2025 | kfree(info); | 2042 | kfree(info); |
2026 | failed: | 2043 | failed: |