Ok, this basically a resend of the IDE driver model update from two days,
with two changes:
- Add and use a struct device in ide_drive_t.
- Remove ->release() method() and move call to driver's cleanup() into
->remove() (mimicking previous behavior of reboot notifier).
Please apply.
Thanks,
-pat
Please pull from
bk://ldm.bkbits.net/linux-2.5-ide
This will update the following files:
drivers/ide/ide-disk.c | 18 -----------
drivers/ide/ide-probe.c | 23 +++++++++------
drivers/ide/ide.c | 73 ++++++++++++++----------------------------------
include/linux/ide.h | 2 +
4 files changed, 39 insertions(+), 77 deletions(-)
through these ChangeSets:
<[email protected]> (02/10/09 1.730)
IDE: make ide_drive_remove() call driver's ->cleanup().
This was accidentally dropped before, but re-added now to completely mimic
behavior of the reboot notifier IDE used to have.
<[email protected]> (02/10/09 1.729)
IDE: Add generic remove() method for drives; remove reboot notifier.
The remove() method is generic for all drives, and set in ide_driver_t::gen_driver.
The call simply forwards the call to ide_driver_t::standby().
This obviates the need for IDE reboot notifier. The core iterates over all present
devices in device_shutdown() and unregisters each one.
<[email protected]> (02/10/09 1.728)
IDE: register ide driver for all ide drives; not just for disk drives.
This adds
struct device_driver gen_driver;
to ide_driver_t, which is filled in with necessary fields when an ide
driver calls ide_register_driver(). That then registers the driver with
the driver model core.
As a result, this gives us the following output in driverfs:
# tree -d /sys/bus/ide/drivers/
/sys/bus/ide/drivers/
|-- ide-cdrom
`-- ide-disk
The suspend/resume callbacks in ide-disk.c have been temporarily
disabled until the ide core implements generic methods which forward
the calls to the drive drivers.
<[email protected]> (02/10/09 1.727)
IDE: add struct device to ide_drive_t and use that for IDE drives
... instead of the one in struct gendisk.
[email protected], 2002-10-09 10:52:46-07:00, [email protected]
IDE: register ide driver for all ide drives; not just for disk drives.
This adds
struct device_driver gen_driver;
to ide_driver_t, which is filled in with necessary fields when an ide
driver calls ide_register_driver(). That then registers the driver with
the driver model core.
As a result, this gives us the following output in driverfs:
# tree -d /sys/bus/ide/drivers/
/sys/bus/ide/drivers/
|-- ide-cdrom
`-- ide-disk
The suspend/resume callbacks in ide-disk.c have been temporarily
disabled until the ide core implements generic methods which forward
the calls to the drive drivers.
diff -Nru a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
--- a/drivers/ide/ide-disk.c Wed Oct 9 11:41:39 2002
+++ b/drivers/ide/ide-disk.c Wed Oct 9 11:41:39 2002
@@ -1664,14 +1664,6 @@
/* 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 @@
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,7 @@
{
struct gendisk *g = drive->disk;
- device_unregister(&drive->disk->disk_dev);
+ device_unregister(&drive->gendev);
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 +1891,6 @@
static int idedisk_init (void)
{
ide_register_driver(&idedisk_driver);
- driver_register(&idedisk_devdrv);
return 0;
}
diff -Nru a/drivers/ide/ide.c b/drivers/ide/ide.c
--- a/drivers/ide/ide.c Wed Oct 9 11:41:39 2002
+++ b/drivers/ide/ide.c Wed Oct 9 11:41:39 2002
@@ -3440,7 +3440,9 @@
list_del_init(&drive->list);
ata_attach(drive);
}
- return 0;
+ driver->gen_driver.name = driver->name;
+ driver->gen_driver.bus = &ide_bus_type;
+ return driver_register(&driver->gen_driver);
}
EXPORT_SYMBOL(ide_register_driver);
diff -Nru a/include/linux/ide.h b/include/linux/ide.h
--- a/include/linux/ide.h Wed Oct 9 11:41:39 2002
+++ b/include/linux/ide.h Wed Oct 9 11:41:39 2002
@@ -1200,6 +1200,7 @@
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;
[email protected], 2002-10-09 11:40:34-07:00, [email protected]
IDE: make ide_drive_remove() call driver's ->cleanup().
This was accidentally dropped before, but re-added now to completely mimic
behavior of the reboot notifier IDE used to have.
diff -Nru a/drivers/ide/ide.c b/drivers/ide/ide.c
--- a/drivers/ide/ide.c Wed Oct 9 11:41:35 2002
+++ b/drivers/ide/ide.c Wed Oct 9 11:41:35 2002
@@ -3428,8 +3428,13 @@
ide_drive_t * drive = container_of(dev,ide_drive_t,gendev);
ide_driver_t * driver = drive->driver;
- if (driver && driver->standby)
- driver->standby(drive);
+ if (driver) {
+ if (driver->standby)
+ driver->standby(drive);
+ if (driver->cleanup)
+ driver->cleanup(drive);
+ }
+
return 0;
}
[email protected], 2002-10-09 10:29:48-07:00, [email protected]
IDE: add struct device to ide_drive_t and use that for IDE drives
... instead of the one in struct gendisk.
diff -Nru a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
--- a/drivers/ide/ide-probe.c Wed Oct 9 11:41:41 2002
+++ b/drivers/ide/ide-probe.c Wed Oct 9 11:41:41 2002
@@ -998,15 +998,6 @@
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 @@
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:
diff -Nru a/include/linux/ide.h b/include/linux/ide.h
--- a/include/linux/ide.h Wed Oct 9 11:41:41 2002
+++ b/include/linux/ide.h Wed Oct 9 11:41:41 2002
@@ -794,6 +794,7 @@
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;
[email protected], 2002-10-09 11:18:47-07:00, [email protected]
IDE: Add generic remove() method for drives; remove reboot notifier.
The remove() method is generic for all drives, and set in ide_driver_t::gen_driver.
The call simply forwards the call to ide_driver_t::standby().
This obviates the need for IDE reboot notifier. The core iterates over all present
devices in device_shutdown() and unregisters each one.
diff -Nru a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
--- a/drivers/ide/ide-disk.c Wed Oct 9 11:41:37 2002
+++ b/drivers/ide/ide-disk.c Wed Oct 9 11:41:37 2002
@@ -1792,7 +1792,6 @@
{
struct gendisk *g = drive->disk;
- device_unregister(&drive->gendev);
if ((drive->id->cfs_enable_2 & 0x3000) && drive->wcache)
if (do_idedisk_flushcache(drive))
printk (KERN_INFO "%s: Write Cache FAILED Flushing!\n",
diff -Nru a/drivers/ide/ide.c b/drivers/ide/ide.c
--- a/drivers/ide/ide.c Wed Oct 9 11:41:37 2002
+++ b/drivers/ide/ide.c Wed Oct 9 11:41:37 2002
@@ -2463,6 +2463,7 @@
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,16 @@
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 && driver->standby)
+ driver->standby(drive);
+ return 0;
+}
+
int ide_register_driver(ide_driver_t *driver)
{
struct list_head list;
@@ -3442,6 +3453,7 @@
}
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);
}
@@ -3493,52 +3505,6 @@
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",
};
@@ -3564,7 +3530,6 @@
ide_init_builtin_drivers();
initializing = 0;
- register_reboot_notifier(&ide_notifier);
return 0;
}
@@ -3599,7 +3564,6 @@
{
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)
Hi!
> The suspend/resume callbacks in ide-disk.c have been temporarily
> disabled until the ide core implements generic methods which forward
> the calls to the drive drivers.
Do you have patches to implement this?
Pavel
--
When do you have heart between your knees?
On Mon, 14 Oct 2002, Pavel Machek wrote:
> Hi!
>
> > The suspend/resume callbacks in ide-disk.c have been temporarily
> > disabled until the ide core implements generic methods which forward
> > the calls to the drive drivers.
>
> Do you have patches to implement this?
Not yet. Expect them in the next day or so..
-pat