diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@elka.pw.edu.pl> | 2005-05-26 08:55:34 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@elka.pw.edu.pl> | 2005-05-26 08:55:34 -0400 |
commit | 8604affde9d4f52f04342d6a37c77d95fa167e7a (patch) | |
tree | 12143c1be244c69c7c2b488a34856f60d0625e03 /drivers/ide/ide-cd.c | |
parent | bef9c558841604116704e10b3d9ff3dbf4939423 (diff) |
[PATCH] convert IDE device drivers to driver-model
* add ide_bus_match() and export ide_bus_type
* split ide_remove_driver_from_hwgroup() out of ide_unregister()
* move device cleanup from ide_unregister() to drive_release_dev()
* convert ide_driver_t->name to driver->name
* convert ide_driver_t->{attach,cleanup} to driver->{probe,remove}
* remove ide_driver_t->busy as ide_bus_type->subsys.rwsem
protects against concurrent ->{probe,remove} calls
* make ide_{un}register_driver() void as it cannot fail now
* use driver_{un}register() directly, remove ide_{un}register_driver()
* use device_register() instead of ata_attach(), remove ata_attach()
* add proc_print_driver() and ide_drivers_show(), remove ide_drivers_op
* fix ide_replace_subdriver() and move it to ide-proc.c
* remove ide_driver_t->drives, ide_drives and drives_lock
* remove ide_driver_t->drivers, drivers and drivers_lock
* remove ide_drive_t->driver and DRIVER() macro
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@elka.pw.edu.pl>
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 4f7ce7056228..f0bd242e030f 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -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 | ||
3258 | static | 3258 | static int ide_cd_remove(struct device *dev) |
3259 | int 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 | ||
3300 | static int ide_cdrom_attach (ide_drive_t *drive); | 3296 | static int ide_cd_probe(struct device *); |
3301 | 3297 | ||
3302 | #ifdef CONFIG_PROC_FS | 3298 | #ifdef CONFIG_PROC_FS |
3303 | static int proc_idecd_read_capacity | 3299 | static int proc_idecd_read_capacity |
@@ -3320,19 +3316,20 @@ static ide_proc_entry_t idecd_proc[] = { | |||
3320 | 3316 | ||
3321 | static ide_driver_t ide_cdrom_driver = { | 3317 | static 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 | ||
3338 | static int idecd_open(struct inode * inode, struct file * file) | 3335 | static int idecd_open(struct inode * inode, struct file * file) |
@@ -3418,8 +3415,9 @@ static char *ignore = NULL; | |||
3418 | module_param(ignore, charp, 0400); | 3415 | module_param(ignore, charp, 0400); |
3419 | MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); | 3416 | MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); |
3420 | 3417 | ||
3421 | static int ide_cdrom_attach (ide_drive_t *drive) | 3418 | static 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 | ||
3503 | out_put_disk: | ||
3504 | put_disk(g); | ||
3505 | out_free_cd: | 3495 | out_free_cd: |
3506 | kfree(info); | 3496 | kfree(info); |
3507 | failed: | 3497 | failed: |
3508 | return 1; | 3498 | return -ENODEV; |
3509 | } | 3499 | } |
3510 | 3500 | ||
3511 | static void __exit ide_cdrom_exit(void) | 3501 | static 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 | ||
3516 | static int ide_cdrom_init(void) | 3506 | static 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 | ||
3522 | module_init(ide_cdrom_init); | 3511 | module_init(ide_cdrom_init); |