Commit ff64a6e3 authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://ldm.bkbits.net/linux-2.5-ide

into penguin.transmeta.com:/home/penguin/torvalds/repositories/kernel/linux
parents e38e1e7f ef1e58e7
......@@ -1664,14 +1664,6 @@ static int idedisk_resume(struct device *dev, u32 level)
/* This is just a hook for the overall driver tree.
*/
static struct device_driver idedisk_devdrv = {
.bus = &ide_bus_type,
.name = "IDE disk driver",
.suspend = idedisk_suspend,
.resume = idedisk_resume,
};
static int idedisk_ioctl (ide_drive_t *drive, struct inode *inode,
struct file *file, unsigned int cmd, unsigned long arg)
{
......@@ -1717,12 +1709,6 @@ static void idedisk_setup (ide_drive_t *drive)
drive->doorlocking = 1;
}
}
{
sprintf(drive->disk->disk_dev.name, "ide-disk");
drive->disk->disk_dev.driver = &idedisk_devdrv;
drive->disk->disk_dev.driver_data = drive;
}
#if 1
(void) probe_lba_addressing(drive, 1);
#else
......@@ -1806,7 +1792,6 @@ static int idedisk_cleanup (ide_drive_t *drive)
{
struct gendisk *g = drive->disk;
device_unregister(&drive->disk->disk_dev);
if ((drive->id->cfs_enable_2 & 0x3000) && drive->wcache)
if (do_idedisk_flushcache(drive))
printk (KERN_INFO "%s: Write Cache FAILED Flushing!\n",
......@@ -1905,7 +1890,6 @@ static void __exit idedisk_exit (void)
static int idedisk_init (void)
{
ide_register_driver(&idedisk_driver);
driver_register(&idedisk_devdrv);
return 0;
}
......
......@@ -998,15 +998,6 @@ static void init_gendisk (ide_hwif_t *hwif)
sprintf(disk->disk_name,"hd%c",'a'+hwif->index*MAX_DRIVES+unit);
disk->minor_shift = PARTN_BITS;
disk->fops = ide_fops;
snprintf(disk->disk_dev.bus_id,BUS_ID_SIZE,"%u.%u",
hwif->index,unit);
snprintf(disk->disk_dev.name,DEVICE_NAME_SIZE,
"%s","IDE Drive");
disk->disk_dev.parent = &hwif->gendev;
disk->disk_dev.bus = &ide_bus_type;
if (hwif->drives[unit].present)
device_register(&disk->disk_dev);
hwif->drives[unit].disk = disk;
}
......@@ -1020,6 +1011,20 @@ static void init_gendisk (ide_hwif_t *hwif)
if (hwif->drives[unit].present)
hwif->drives[unit].de = devfs_mk_dir(ide_devfs_handle, name, NULL);
}
for (unit = 0; unit < units; ++unit) {
ide_drive_t * drive = &hwif->drives[unit];
snprintf(drive->gendev.bus_id,BUS_ID_SIZE,"%u.%u",
hwif->index,unit);
snprintf(drive->gendev.name,DEVICE_NAME_SIZE,
"%s","IDE Drive");
drive->gendev.parent = &hwif->gendev;
drive->gendev.bus = &ide_bus_type;
if (drive->present)
device_register(&drive->gendev);
}
return;
err_kmalloc_gd:
......
......@@ -2463,6 +2463,7 @@ int ata_attach(ide_drive_t *drive)
if (driver->attach(drive) == 0) {
if (driver->owner)
__MOD_DEC_USE_COUNT(driver->owner);
drive->gendev.driver = &driver->gen_driver;
return 0;
}
spin_lock(&drivers_lock);
......@@ -3422,6 +3423,21 @@ int ide_unregister_subdriver (ide_drive_t *drive)
EXPORT_SYMBOL(ide_unregister_subdriver);
static int ide_drive_remove(struct device * dev)
{
ide_drive_t * drive = container_of(dev,ide_drive_t,gendev);
ide_driver_t * driver = drive->driver;
if (driver) {
if (driver->standby)
driver->standby(drive);
if (driver->cleanup)
driver->cleanup(drive);
}
return 0;
}
int ide_register_driver(ide_driver_t *driver)
{
struct list_head list;
......@@ -3440,7 +3456,10 @@ int ide_register_driver(ide_driver_t *driver)
list_del_init(&drive->list);
ata_attach(drive);
}
return 0;
driver->gen_driver.name = driver->name;
driver->gen_driver.bus = &ide_bus_type;
driver->gen_driver.remove = ide_drive_remove;
return driver_register(&driver->gen_driver);
}
EXPORT_SYMBOL(ide_register_driver);
......@@ -3491,52 +3510,6 @@ EXPORT_SYMBOL(ide_lock);
EXPORT_SYMBOL(ide_probe);
EXPORT_SYMBOL(ide_devfs_handle);
static int ide_notify_reboot (struct notifier_block *this, unsigned long event, void *x)
{
ide_hwif_t *hwif;
ide_drive_t *drive;
int i, unit;
switch (event) {
case SYS_HALT:
case SYS_POWER_OFF:
case SYS_RESTART:
break;
default:
return NOTIFY_DONE;
}
printk(KERN_INFO "flushing ide devices: ");
for (i = 0; i < MAX_HWIFS; i++) {
hwif = &ide_hwifs[i];
if (!hwif->present)
continue;
for (unit = 0; unit < MAX_DRIVES; ++unit) {
drive = &hwif->drives[unit];
if (!drive->present)
continue;
/* set the drive to standby */
printk("%s ", drive->name);
if (event != SYS_RESTART)
if (drive->driver != NULL && DRIVER(drive)->standby(drive))
continue;
if (drive->driver != NULL && DRIVER(drive)->cleanup(drive))
continue;
}
}
printk("\n");
return NOTIFY_DONE;
}
static struct notifier_block ide_notifier = {
ide_notify_reboot,
NULL,
5
};
struct bus_type ide_bus_type = {
.name = "ide",
};
......@@ -3562,7 +3535,6 @@ int __init ide_init (void)
ide_init_builtin_drivers();
initializing = 0;
register_reboot_notifier(&ide_notifier);
return 0;
}
......@@ -3597,7 +3569,6 @@ void cleanup_module (void)
{
int index;
unregister_reboot_notifier(&ide_notifier);
for (index = 0; index < MAX_HWIFS; ++index) {
ide_unregister(index);
#if defined(CONFIG_BLK_DEV_IDEDMA) && !defined(CONFIG_DMA_NONPCI)
......
......@@ -794,6 +794,7 @@ typedef struct ide_drive_s {
int lun; /* logical unit */
int crc_count; /* crc counter to reduce drive speed */
struct list_head list;
struct device gendev;
struct gendisk *disk;
} ide_drive_t;
......@@ -1199,6 +1200,7 @@ typedef struct ide_driver_s {
int (*attach)(ide_drive_t *);
void (*ata_prebuilder)(ide_drive_t *);
void (*atapi_prebuilder)(ide_drive_t *);
struct device_driver gen_driver;
struct list_head drives;
struct list_head drivers;
} ide_driver_t;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment