Commit 06330ca4 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] put IDE drives on lists

This puts drives on cyclic lists - per-driver ones for drives that had
been claimed by high-level drivers and ata_unused for unclaimed drives.
We put drives on ata_unused in the very end of ideprobe_init() and then
move them to drivers' lists as they are claimed.
parent 86a995ac
......@@ -3083,6 +3083,7 @@ static ide_driver_t ide_cdrom_driver = {
reinit: ide_cdrom_reinit,
ata_prebuilder: NULL,
atapi_prebuilder: NULL,
drives: LIST_HEAD_INIT(ide_cdrom_driver.drives),
};
static ide_module_t ide_cdrom_module = {
......
......@@ -1671,6 +1671,7 @@ static ide_driver_t idedisk_driver = {
reinit: idedisk_reinit,
ata_prebuilder: NULL,
atapi_prebuilder: NULL,
drives: LIST_HEAD_INIT(idedisk_driver.drives),
};
static ide_module_t idedisk_module = {
......
......@@ -2182,6 +2182,7 @@ static ide_driver_t idefloppy_driver = {
reinit: idefloppy_reinit,
ata_prebuilder: NULL,
atapi_prebuilder: NULL,
drives: LIST_HEAD_INIT(idefloppy_driver.drives),
};
static ide_module_t idefloppy_module = {
......
......@@ -988,6 +988,9 @@ static ide_module_t ideprobe_module = {
NULL
};
extern struct list_head ata_unused; /* temporary */
extern spinlock_t ata_drives_lock; /* temporary */
int ideprobe_init (void)
{
unsigned int index;
......@@ -1007,6 +1010,19 @@ int ideprobe_init (void)
for (index = 0; index < MAX_HWIFS; ++index)
if (probe[index])
hwif_init(&ide_hwifs[index]);
for (index = 0; index < MAX_HWIFS; ++index)
if (probe[index]) {
ide_hwif_t *hwif = &ide_hwifs[index];
int unit;
if (!hwif->present)
continue;
for (unit = 0; unit < MAX_DRIVES; ++unit) {
ide_drive_t *drive = &hwif->drives[unit];
spin_lock(&ata_drives_lock);
list_add(&drive->list, &ata_unused);
spin_unlock(&ata_drives_lock);
}
}
if (!ide_probe)
ide_probe = &ideprobe_module;
MOD_DEC_USE_COUNT;
......
......@@ -6344,6 +6344,7 @@ static ide_driver_t idetape_driver = {
reinit: idetape_reinit,
ata_prebuilder: NULL,
atapi_prebuilder: NULL,
drives: LIST_HEAD_INIT(idetape_driver.drives),
};
static ide_module_t idetape_module = {
......
......@@ -277,6 +277,7 @@ static void init_hwif_data (unsigned int index)
drive->name[2] = 'a' + (index * MAX_DRIVES) + unit;
drive->max_failures = IDE_DEFAULT_MAX_FAILURES;
init_waitqueue_head(&drive->wqueue);
INIT_LIST_HEAD(&drive->list);
}
}
......@@ -2002,6 +2003,12 @@ void ide_unregister (unsigned int index)
goto abort;
}
hwif->present = 0;
spin_lock(&ata_drives_lock);
for (unit = 0; unit < MAX_DRIVES; ++unit) {
drive = &hwif->drives[unit];
list_del_init(&drive->list);
}
spin_unlock(&ata_drives_lock);
/*
* All clear? Then blow away the buffer cache
......@@ -3561,6 +3568,10 @@ int ide_register_subdriver (ide_drive_t *drive, ide_driver_t *driver, int versio
drive->driver = driver;
setup_driver_defaults(drive);
spin_unlock_irqrestore(&ide_lock, flags);
spin_lock(&ata_drives_lock);
list_del(&drive->list); /* will die */
list_add(&drive->list, &driver->drives);
spin_unlock(&ata_drives_lock);
if (drive->autotune != 2) {
if (!driver->supports_dma && HWIF(drive)->dmaproc != NULL)
(void) (HWIF(drive)->dmaproc(ide_dma_off_quietly, drive));
......@@ -3576,6 +3587,11 @@ int ide_register_subdriver (ide_drive_t *drive, ide_driver_t *driver, int versio
return 0;
}
LIST_HEAD(ata_unused);
spinlock_t ata_drives_lock = SPIN_LOCK_UNLOCKED;
EXPORT_SYMBOL(ata_unused); /* temporary export */
EXPORT_SYMBOL(ata_drives_lock); /* temporary export */
int ide_unregister_subdriver (ide_drive_t *drive)
{
unsigned long flags;
......@@ -3596,6 +3612,10 @@ int ide_unregister_subdriver (ide_drive_t *drive)
auto_remove_settings(drive);
drive->driver = NULL;
spin_unlock_irqrestore(&ide_lock, flags);
spin_lock(&ata_drives_lock);
list_del(&drive->list);
list_add(&drive->list, &ata_unused);
spin_unlock(&ata_drives_lock);
return 0;
}
......
......@@ -566,6 +566,7 @@ static ide_driver_t idescsi_driver = {
capacity: NULL,
special: NULL,
proc: NULL,
drives: LIST_HEAD_INIT(idescsi_driver.drives),
};
int idescsi_init (void);
......
......@@ -530,6 +530,7 @@ typedef struct ide_drive_s {
byte acoustic; /* acoustic management */
unsigned int failures; /* current failure count */
unsigned int max_failures; /* maximum allowed failure count */
struct list_head list;
} ide_drive_t;
/*
......@@ -917,6 +918,7 @@ typedef struct ide_driver_s {
int (*reinit)(ide_drive_t *);
void (*ata_prebuilder)(ide_drive_t *);
void (*atapi_prebuilder)(ide_drive_t *);
struct list_head drives;
} ide_driver_t;
#define DRIVER(drive) ((drive)->driver)
......
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