aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-cd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r--drivers/ide/ide-cd.c49
1 files changed, 19 insertions, 30 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 33a020faeabd..f0bd242e030f 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1933,7 +1933,7 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1933 /* 1933 /*
1934 * check if dma is safe 1934 * check if dma is safe
1935 */ 1935 */
1936 if ((rq->data_len & mask) || (addr & mask)) 1936 if ((rq->data_len & 3) || (addr & mask))
1937 info->dma = 0; 1937 info->dma = 0;
1938 } 1938 }
1939 1939
@@ -3255,16 +3255,12 @@ sector_t ide_cdrom_capacity (ide_drive_t *drive)
3255 return capacity * sectors_per_frame; 3255 return capacity * sectors_per_frame;
3256} 3256}
3257 3257
3258static 3258static int ide_cd_remove(struct device *dev)
3259int ide_cdrom_cleanup(ide_drive_t *drive)
3260{ 3259{
3260 ide_drive_t *drive = to_ide_device(dev);
3261 struct cdrom_info *info = drive->driver_data; 3261 struct cdrom_info *info = drive->driver_data;
3262 3262
3263 if (ide_unregister_subdriver(drive)) { 3263 ide_unregister_subdriver(drive, info->driver);
3264 printk(KERN_ERR "%s: %s: failed to ide_unregister_subdriver\n",
3265 __FUNCTION__, drive->name);
3266 return 1;
3267 }
3268 3264
3269 del_gendisk(info->disk); 3265 del_gendisk(info->disk);
3270 3266
@@ -3297,7 +3293,7 @@ static void ide_cd_release(struct kref *kref)
3297 kfree(info); 3293 kfree(info);
3298} 3294}
3299 3295
3300static int ide_cdrom_attach (ide_drive_t *drive); 3296static int ide_cd_probe(struct device *);
3301 3297
3302#ifdef CONFIG_PROC_FS 3298#ifdef CONFIG_PROC_FS
3303static int proc_idecd_read_capacity 3299static int proc_idecd_read_capacity
@@ -3320,19 +3316,20 @@ static ide_proc_entry_t idecd_proc[] = {
3320 3316
3321static ide_driver_t ide_cdrom_driver = { 3317static ide_driver_t ide_cdrom_driver = {
3322 .owner = THIS_MODULE, 3318 .owner = THIS_MODULE,
3323 .name = "ide-cdrom", 3319 .gen_driver = {
3320 .name = "ide-cdrom",
3321 .bus = &ide_bus_type,
3322 .probe = ide_cd_probe,
3323 .remove = ide_cd_remove,
3324 },
3324 .version = IDECD_VERSION, 3325 .version = IDECD_VERSION,
3325 .media = ide_cdrom, 3326 .media = ide_cdrom,
3326 .busy = 0,
3327 .supports_dsc_overlap = 1, 3327 .supports_dsc_overlap = 1,
3328 .cleanup = ide_cdrom_cleanup,
3329 .do_request = ide_do_rw_cdrom, 3328 .do_request = ide_do_rw_cdrom,
3330 .end_request = ide_end_request, 3329 .end_request = ide_end_request,
3331 .error = __ide_error, 3330 .error = __ide_error,
3332 .abort = __ide_abort, 3331 .abort = __ide_abort,
3333 .proc = idecd_proc, 3332 .proc = idecd_proc,
3334 .attach = ide_cdrom_attach,
3335 .drives = LIST_HEAD_INIT(ide_cdrom_driver.drives),
3336}; 3333};
3337 3334
3338static int idecd_open(struct inode * inode, struct file * file) 3335static int idecd_open(struct inode * inode, struct file * file)
@@ -3418,8 +3415,9 @@ static char *ignore = NULL;
3418module_param(ignore, charp, 0400); 3415module_param(ignore, charp, 0400);
3419MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); 3416MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
3420 3417
3421static int ide_cdrom_attach (ide_drive_t *drive) 3418static int ide_cd_probe(struct device *dev)
3422{ 3419{
3420 ide_drive_t *drive = to_ide_device(dev);
3423 struct cdrom_info *info; 3421 struct cdrom_info *info;
3424 struct gendisk *g; 3422 struct gendisk *g;
3425 struct request_sense sense; 3423 struct request_sense sense;
@@ -3453,11 +3451,8 @@ static int ide_cdrom_attach (ide_drive_t *drive)
3453 3451
3454 ide_init_disk(g, drive); 3452 ide_init_disk(g, drive);
3455 3453
3456 if (ide_register_subdriver(drive, &ide_cdrom_driver)) { 3454 ide_register_subdriver(drive, &ide_cdrom_driver);
3457 printk(KERN_ERR "%s: Failed to register the driver with ide.c\n", 3455
3458 drive->name);
3459 goto out_put_disk;
3460 }
3461 memset(info, 0, sizeof (struct cdrom_info)); 3456 memset(info, 0, sizeof (struct cdrom_info));
3462 3457
3463 kref_init(&info->kref); 3458 kref_init(&info->kref);
@@ -3470,7 +3465,6 @@ static int ide_cdrom_attach (ide_drive_t *drive)
3470 3465
3471 drive->driver_data = info; 3466 drive->driver_data = info;
3472 3467
3473 DRIVER(drive)->busy++;
3474 g->minors = 1; 3468 g->minors = 1;
3475 snprintf(g->devfs_name, sizeof(g->devfs_name), 3469 snprintf(g->devfs_name, sizeof(g->devfs_name),
3476 "%s/cd", drive->devfs_name); 3470 "%s/cd", drive->devfs_name);
@@ -3478,8 +3472,7 @@ static int ide_cdrom_attach (ide_drive_t *drive)
3478 g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE; 3472 g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE;
3479 if (ide_cdrom_setup(drive)) { 3473 if (ide_cdrom_setup(drive)) {
3480 struct cdrom_device_info *devinfo = &info->devinfo; 3474 struct cdrom_device_info *devinfo = &info->devinfo;
3481 DRIVER(drive)->busy--; 3475 ide_unregister_subdriver(drive, &ide_cdrom_driver);
3482 ide_unregister_subdriver(drive);
3483 if (info->buffer != NULL) 3476 if (info->buffer != NULL)
3484 kfree(info->buffer); 3477 kfree(info->buffer);
3485 if (info->toc != NULL) 3478 if (info->toc != NULL)
@@ -3492,7 +3485,6 @@ static int ide_cdrom_attach (ide_drive_t *drive)
3492 drive->driver_data = NULL; 3485 drive->driver_data = NULL;
3493 goto failed; 3486 goto failed;
3494 } 3487 }
3495 DRIVER(drive)->busy--;
3496 3488
3497 cdrom_read_toc(drive, &sense); 3489 cdrom_read_toc(drive, &sense);
3498 g->fops = &idecd_ops; 3490 g->fops = &idecd_ops;
@@ -3500,23 +3492,20 @@ static int ide_cdrom_attach (ide_drive_t *drive)
3500 add_disk(g); 3492 add_disk(g);
3501 return 0; 3493 return 0;
3502 3494
3503out_put_disk:
3504 put_disk(g);
3505out_free_cd: 3495out_free_cd:
3506 kfree(info); 3496 kfree(info);
3507failed: 3497failed:
3508 return 1; 3498 return -ENODEV;
3509} 3499}
3510 3500
3511static void __exit ide_cdrom_exit(void) 3501static void __exit ide_cdrom_exit(void)
3512{ 3502{
3513 ide_unregister_driver(&ide_cdrom_driver); 3503 driver_unregister(&ide_cdrom_driver.gen_driver);
3514} 3504}
3515 3505
3516static int ide_cdrom_init(void) 3506static int ide_cdrom_init(void)
3517{ 3507{
3518 ide_register_driver(&ide_cdrom_driver); 3508 return driver_register(&ide_cdrom_driver.gen_driver);
3519 return 0;
3520} 3509}
3521 3510
3522module_init(ide_cdrom_init); 3511module_init(ide_cdrom_init);