Rather than iterate over the global IDE channels list, use instance variables to hold the relevant pointers. This allows us to remove ide_seek_channel() since it is no longer necessary for each IDE device to iterate over the global list in order to locate the drive/channel information.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- drivers/ide.c | 41 +++++++++++++++-------------------------- drivers/ide.h | 1 - 2 files changed, 15 insertions(+), 27 deletions(-)
diff --git a/drivers/ide.c b/drivers/ide.c index e56cb4c..62c20b9 100644 --- a/drivers/ide.c +++ b/drivers/ide.c @@ -73,19 +73,6 @@ static inline void ide_add_channel(struct ide_channel *chan) channels = chan; }
-static struct ide_channel *ide_seek_channel(phandle_t ph) -{ - struct ide_channel *current; - - current = channels; - while (current) { - if (current->ph == ph) - return current; - current = current->next; - } - return NULL; -} - /* * don't be pedantic */ @@ -1230,18 +1217,10 @@ ob_ide_open(int *idx) int ret=1; phandle_t ph; struct ide_drive *drive; - struct ide_channel *chan; - int unit;
- fword("my-unit"); - unit = POP(); - - fword("my-parent"); - fword("ihandle>phandle"); - ph=(phandle_t)POP(); - - chan = ide_seek_channel(ph); - drive = &chan->drives[unit]; + PUSH(find_ih_method("drive", my_self())); + fword("execute"); + drive = cell2pointer(POP()); *(struct ide_drive **)idx = drive;
IDE_DPRINTF("opening channel %d unit %d\n", idx[1], idx[0]); @@ -1437,7 +1416,9 @@ int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
fword("new-device"); dnode = get_cur_dev(); - chan->ph = dnode; + + PUSH(pointer2cell(chan)); + feval("value chan");
BIND_NODE_METHODS(get_cur_dev(), ob_ide_ctrl);
@@ -1500,6 +1481,9 @@ int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0, push_str("block"); fword("device-type");
+ PUSH(pointer2cell(drive)); + feval("value drive"); + BIND_NODE_METHODS(dnode, ob_ide); fword("is-deblocker");
@@ -1626,7 +1610,9 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels)
fword("new-device"); dnode = get_cur_dev(); - chan->ph = dnode; + + PUSH(pointer2cell(chan)); + feval("value chan");
snprintf(nodebuff, sizeof(nodebuff), DEV_NAME "-%d", current_channel); push_str(nodebuff); @@ -1741,6 +1727,9 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) push_str("block"); fword("device-type");
+ PUSH(pointer2cell(drive)); + feval("value drive"); + BIND_NODE_METHODS(dnode, ob_ide); fword("is-deblocker");
diff --git a/drivers/ide.h b/drivers/ide.h index 8983c8e..f6abb7b 100644 --- a/drivers/ide.h +++ b/drivers/ide.h @@ -167,7 +167,6 @@ struct ide_drive {
struct ide_channel {
- phandle_t ph; struct ide_channel *next;
/*