aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-disk.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@elka.pw.edu.pl>2005-05-26 08:55:34 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@elka.pw.edu.pl>2005-05-26 08:55:34 -0400
commit8604affde9d4f52f04342d6a37c77d95fa167e7a (patch)
tree12143c1be244c69c7c2b488a34856f60d0625e03 /drivers/ide/ide-disk.c
parentbef9c558841604116704e10b3d9ff3dbf4939423 (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-disk.c')
-rw-r--r--drivers/ide/ide-disk.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 5d54f7756100..3302cd8eab4c 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1024,14 +1024,16 @@ static void ide_cacheflush_p(ide_drive_t *drive)
1024 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name); 1024 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name);
1025} 1025}
1026 1026
1027static int idedisk_cleanup (ide_drive_t *drive) 1027static int ide_disk_remove(struct device *dev)
1028{ 1028{
1029 ide_drive_t *drive = to_ide_device(dev);
1029 struct ide_disk_obj *idkp = drive->driver_data; 1030 struct ide_disk_obj *idkp = drive->driver_data;
1030 struct gendisk *g = idkp->disk; 1031 struct gendisk *g = idkp->disk;
1031 1032
1032 ide_cacheflush_p(drive); 1033 ide_cacheflush_p(drive);
1033 if (ide_unregister_subdriver(drive)) 1034
1034 return 1; 1035 ide_unregister_subdriver(drive, idkp->driver);
1036
1035 del_gendisk(g); 1037 del_gendisk(g);
1036 1038
1037 ide_disk_put(idkp); 1039 ide_disk_put(idkp);
@@ -1052,7 +1054,7 @@ static void ide_disk_release(struct kref *kref)
1052 kfree(idkp); 1054 kfree(idkp);
1053} 1055}
1054 1056
1055static int idedisk_attach(ide_drive_t *drive); 1057static int ide_disk_probe(struct device *dev);
1056 1058
1057static void ide_device_shutdown(struct device *dev) 1059static void ide_device_shutdown(struct device *dev)
1058{ 1060{
@@ -1082,27 +1084,23 @@ static void ide_device_shutdown(struct device *dev)
1082 dev->bus->suspend(dev, PMSG_SUSPEND); 1084 dev->bus->suspend(dev, PMSG_SUSPEND);
1083} 1085}
1084 1086
1085/*
1086 * IDE subdriver functions, registered with ide.c
1087 */
1088static ide_driver_t idedisk_driver = { 1087static ide_driver_t idedisk_driver = {
1089 .owner = THIS_MODULE, 1088 .owner = THIS_MODULE,
1090 .gen_driver = { 1089 .gen_driver = {
1090 .name = "ide-disk",
1091 .bus = &ide_bus_type,
1092 .probe = ide_disk_probe,
1093 .remove = ide_disk_remove,
1091 .shutdown = ide_device_shutdown, 1094 .shutdown = ide_device_shutdown,
1092 }, 1095 },
1093 .name = "ide-disk",
1094 .version = IDEDISK_VERSION, 1096 .version = IDEDISK_VERSION,
1095 .media = ide_disk, 1097 .media = ide_disk,
1096 .busy = 0,
1097 .supports_dsc_overlap = 0, 1098 .supports_dsc_overlap = 0,
1098 .cleanup = idedisk_cleanup,
1099 .do_request = ide_do_rw_disk, 1099 .do_request = ide_do_rw_disk,
1100 .end_request = ide_end_request, 1100 .end_request = ide_end_request,
1101 .error = __ide_error, 1101 .error = __ide_error,
1102 .abort = __ide_abort, 1102 .abort = __ide_abort,
1103 .proc = idedisk_proc, 1103 .proc = idedisk_proc,
1104 .attach = idedisk_attach,
1105 .drives = LIST_HEAD_INIT(idedisk_driver.drives),
1106}; 1104};
1107 1105
1108static int idedisk_open(struct inode *inode, struct file *filp) 1106static int idedisk_open(struct inode *inode, struct file *filp)
@@ -1199,8 +1197,9 @@ static struct block_device_operations idedisk_ops = {
1199 1197
1200MODULE_DESCRIPTION("ATA DISK Driver"); 1198MODULE_DESCRIPTION("ATA DISK Driver");
1201 1199
1202static int idedisk_attach(ide_drive_t *drive) 1200static int ide_disk_probe(struct device *dev)
1203{ 1201{
1202 ide_drive_t *drive = to_ide_device(dev);
1204 struct ide_disk_obj *idkp; 1203 struct ide_disk_obj *idkp;
1205 struct gendisk *g; 1204 struct gendisk *g;
1206 1205
@@ -1222,10 +1221,7 @@ static int idedisk_attach(ide_drive_t *drive)
1222 1221
1223 ide_init_disk(g, drive); 1222 ide_init_disk(g, drive);
1224 1223
1225 if (ide_register_subdriver(drive, &idedisk_driver)) { 1224 ide_register_subdriver(drive, &idedisk_driver);
1226 printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name);
1227 goto out_put_disk;
1228 }
1229 1225
1230 memset(idkp, 0, sizeof(*idkp)); 1226 memset(idkp, 0, sizeof(*idkp));
1231 1227
@@ -1239,7 +1235,6 @@ static int idedisk_attach(ide_drive_t *drive)
1239 1235
1240 drive->driver_data = idkp; 1236 drive->driver_data = idkp;
1241 1237
1242 DRIVER(drive)->busy++;
1243 idedisk_setup(drive); 1238 idedisk_setup(drive);
1244 if ((!drive->head || drive->head > 16) && !drive->select.b.lba) { 1239 if ((!drive->head || drive->head > 16) && !drive->select.b.lba) {
1245 printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n", 1240 printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n",
@@ -1247,7 +1242,7 @@ static int idedisk_attach(ide_drive_t *drive)
1247 drive->attach = 0; 1242 drive->attach = 0;
1248 } else 1243 } else
1249 drive->attach = 1; 1244 drive->attach = 1;
1250 DRIVER(drive)->busy--; 1245
1251 g->minors = 1 << PARTN_BITS; 1246 g->minors = 1 << PARTN_BITS;
1252 strcpy(g->devfs_name, drive->devfs_name); 1247 strcpy(g->devfs_name, drive->devfs_name);
1253 g->driverfs_dev = &drive->gendev; 1248 g->driverfs_dev = &drive->gendev;
@@ -1257,22 +1252,20 @@ static int idedisk_attach(ide_drive_t *drive)
1257 add_disk(g); 1252 add_disk(g);
1258 return 0; 1253 return 0;
1259 1254
1260out_put_disk:
1261 put_disk(g);
1262out_free_idkp: 1255out_free_idkp:
1263 kfree(idkp); 1256 kfree(idkp);
1264failed: 1257failed:
1265 return 1; 1258 return -ENODEV;
1266} 1259}
1267 1260
1268static void __exit idedisk_exit (void) 1261static void __exit idedisk_exit (void)
1269{ 1262{
1270 ide_unregister_driver(&idedisk_driver); 1263 driver_unregister(&idedisk_driver.gen_driver);
1271} 1264}
1272 1265
1273static int idedisk_init (void) 1266static int idedisk_init (void)
1274{ 1267{
1275 return ide_register_driver(&idedisk_driver); 1268 return driver_register(&idedisk_driver.gen_driver);
1276} 1269}
1277 1270
1278module_init(idedisk_init); 1271module_init(idedisk_init);