diff options
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r-- | drivers/ide/ide-disk.c | 41 |
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 | ||
1027 | static int idedisk_cleanup (ide_drive_t *drive) | 1027 | static 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 | ||
1055 | static int idedisk_attach(ide_drive_t *drive); | 1057 | static int ide_disk_probe(struct device *dev); |
1056 | 1058 | ||
1057 | static void ide_device_shutdown(struct device *dev) | 1059 | static 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 | */ | ||
1088 | static ide_driver_t idedisk_driver = { | 1087 | static 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 | ||
1108 | static int idedisk_open(struct inode *inode, struct file *filp) | 1106 | static int idedisk_open(struct inode *inode, struct file *filp) |
@@ -1199,8 +1197,9 @@ static struct block_device_operations idedisk_ops = { | |||
1199 | 1197 | ||
1200 | MODULE_DESCRIPTION("ATA DISK Driver"); | 1198 | MODULE_DESCRIPTION("ATA DISK Driver"); |
1201 | 1199 | ||
1202 | static int idedisk_attach(ide_drive_t *drive) | 1200 | static 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 | ||
1260 | out_put_disk: | ||
1261 | put_disk(g); | ||
1262 | out_free_idkp: | 1255 | out_free_idkp: |
1263 | kfree(idkp); | 1256 | kfree(idkp); |
1264 | failed: | 1257 | failed: |
1265 | return 1; | 1258 | return -ENODEV; |
1266 | } | 1259 | } |
1267 | 1260 | ||
1268 | static void __exit idedisk_exit (void) | 1261 | static void __exit idedisk_exit (void) |
1269 | { | 1262 | { |
1270 | ide_unregister_driver(&idedisk_driver); | 1263 | driver_unregister(&idedisk_driver.gen_driver); |
1271 | } | 1264 | } |
1272 | 1265 | ||
1273 | static int idedisk_init (void) | 1266 | static 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 | ||
1278 | module_init(idedisk_init); | 1271 | module_init(idedisk_init); |