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-probe.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-probe.c')
-rw-r--r-- | drivers/ide/ide-probe.c | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 554473a95cf7..53b84a84f6cb 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/slab.h> | 47 | #include <linux/slab.h> |
48 | #include <linux/delay.h> | 48 | #include <linux/delay.h> |
49 | #include <linux/ide.h> | 49 | #include <linux/ide.h> |
50 | #include <linux/devfs_fs_kernel.h> | ||
50 | #include <linux/spinlock.h> | 51 | #include <linux/spinlock.h> |
51 | #include <linux/kmod.h> | 52 | #include <linux/kmod.h> |
52 | #include <linux/pci.h> | 53 | #include <linux/pci.h> |
@@ -918,7 +919,7 @@ int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif) | |||
918 | want them on default or a new "empty" class | 919 | want them on default or a new "empty" class |
919 | for hotplug reprobing ? */ | 920 | for hotplug reprobing ? */ |
920 | if (drive->present) { | 921 | if (drive->present) { |
921 | ata_attach(drive); | 922 | device_register(&drive->gendev); |
922 | } | 923 | } |
923 | } | 924 | } |
924 | } | 925 | } |
@@ -1279,10 +1280,51 @@ void ide_init_disk(struct gendisk *disk, ide_drive_t *drive) | |||
1279 | 1280 | ||
1280 | EXPORT_SYMBOL_GPL(ide_init_disk); | 1281 | EXPORT_SYMBOL_GPL(ide_init_disk); |
1281 | 1282 | ||
1283 | static void ide_remove_drive_from_hwgroup(ide_drive_t *drive) | ||
1284 | { | ||
1285 | ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; | ||
1286 | |||
1287 | if (drive == drive->next) { | ||
1288 | /* special case: last drive from hwgroup. */ | ||
1289 | BUG_ON(hwgroup->drive != drive); | ||
1290 | hwgroup->drive = NULL; | ||
1291 | } else { | ||
1292 | ide_drive_t *walk; | ||
1293 | |||
1294 | walk = hwgroup->drive; | ||
1295 | while (walk->next != drive) | ||
1296 | walk = walk->next; | ||
1297 | walk->next = drive->next; | ||
1298 | if (hwgroup->drive == drive) { | ||
1299 | hwgroup->drive = drive->next; | ||
1300 | hwgroup->hwif = hwgroup->drive->hwif; | ||
1301 | } | ||
1302 | } | ||
1303 | BUG_ON(hwgroup->drive == drive); | ||
1304 | } | ||
1305 | |||
1282 | static void drive_release_dev (struct device *dev) | 1306 | static void drive_release_dev (struct device *dev) |
1283 | { | 1307 | { |
1284 | ide_drive_t *drive = container_of(dev, ide_drive_t, gendev); | 1308 | ide_drive_t *drive = container_of(dev, ide_drive_t, gendev); |
1285 | 1309 | ||
1310 | spin_lock_irq(&ide_lock); | ||
1311 | if (drive->devfs_name[0] != '\0') { | ||
1312 | devfs_remove(drive->devfs_name); | ||
1313 | drive->devfs_name[0] = '\0'; | ||
1314 | } | ||
1315 | ide_remove_drive_from_hwgroup(drive); | ||
1316 | if (drive->id != NULL) { | ||
1317 | kfree(drive->id); | ||
1318 | drive->id = NULL; | ||
1319 | } | ||
1320 | drive->present = 0; | ||
1321 | /* Messed up locking ... */ | ||
1322 | spin_unlock_irq(&ide_lock); | ||
1323 | blk_cleanup_queue(drive->queue); | ||
1324 | spin_lock_irq(&ide_lock); | ||
1325 | drive->queue = NULL; | ||
1326 | spin_unlock_irq(&ide_lock); | ||
1327 | |||
1286 | up(&drive->gendev_rel_sem); | 1328 | up(&drive->gendev_rel_sem); |
1287 | } | 1329 | } |
1288 | 1330 | ||
@@ -1306,7 +1348,6 @@ static void init_gendisk (ide_hwif_t *hwif) | |||
1306 | drive->gendev.driver_data = drive; | 1348 | drive->gendev.driver_data = drive; |
1307 | drive->gendev.release = drive_release_dev; | 1349 | drive->gendev.release = drive_release_dev; |
1308 | if (drive->present) { | 1350 | if (drive->present) { |
1309 | device_register(&drive->gendev); | ||
1310 | sprintf(drive->devfs_name, "ide/host%d/bus%d/target%d/lun%d", | 1351 | sprintf(drive->devfs_name, "ide/host%d/bus%d/target%d/lun%d", |
1311 | (hwif->channel && hwif->mate) ? | 1352 | (hwif->channel && hwif->mate) ? |
1312 | hwif->mate->index : hwif->index, | 1353 | hwif->mate->index : hwif->index, |
@@ -1412,7 +1453,7 @@ int ideprobe_init (void) | |||
1412 | hwif->chipset = ide_generic; | 1453 | hwif->chipset = ide_generic; |
1413 | for (unit = 0; unit < MAX_DRIVES; ++unit) | 1454 | for (unit = 0; unit < MAX_DRIVES; ++unit) |
1414 | if (hwif->drives[unit].present) | 1455 | if (hwif->drives[unit].present) |
1415 | ata_attach(&hwif->drives[unit]); | 1456 | device_register(&hwif->drives[unit].gendev); |
1416 | } | 1457 | } |
1417 | } | 1458 | } |
1418 | return 0; | 1459 | return 0; |