[OpenBIOS] [PATCH 4/5] ide: reference IDE channels by phandle, not device name
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Thu Dec 24 20:53:58 CET 2015
Otherwise when two device nodes have the same name property we are unable
to distinguish between them.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
openbios-devel/drivers/ide.c | 20 ++++++++------------
openbios-devel/drivers/ide.h | 2 +-
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/openbios-devel/drivers/ide.c b/openbios-devel/drivers/ide.c
index c63ddd8..5ebaf5a 100644
--- a/openbios-devel/drivers/ide.c
+++ b/openbios-devel/drivers/ide.c
@@ -73,13 +73,13 @@ static inline void ide_add_channel(struct ide_channel *chan)
channels = chan;
}
-static struct ide_channel *ide_seek_channel(const char *name)
+static struct ide_channel *ide_seek_channel(phandle_t ph)
{
struct ide_channel *current;
current = channels;
while (current) {
- if (!strcmp(current->name, name))
+ if (current->ph == ph)
return current;
current = current->next;
}
@@ -1247,11 +1247,10 @@ ob_ide_initialize(int *idx)
static void
ob_ide_open(int *idx)
{
- int ret=1, len;
+ int ret=1;
phandle_t ph;
struct ide_drive *drive;
struct ide_channel *chan;
- char *idename;
int unit;
fword("my-unit");
@@ -1260,9 +1259,8 @@ ob_ide_open(int *idx)
fword("my-parent");
fword("ihandle>phandle");
ph=(phandle_t)POP();
- idename=get_property(ph, "name", &len);
- chan = ide_seek_channel(idename);
+ chan = ide_seek_channel(ph);
drive = &chan->drives[unit];
*(struct ide_drive **)idx = drive;
@@ -1380,9 +1378,6 @@ int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
chan = malloc(sizeof(struct ide_channel));
- snprintf(chan->name, sizeof(chan->name),
- DEV_NAME, current_channel);
-
chan->mmio = 0;
for (j = 0; j < 8; j++)
@@ -1426,6 +1421,8 @@ int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
current_channel);
REGISTER_NAMED_NODE_PHANDLE(ob_ide_ctrl, nodebuff, dnode);
+ chan->ph = dnode;
+
#if !defined(CONFIG_PPC) && !defined(CONFIG_SPARC64)
props[0]=14; props[1]=0;
set_property(dnode, "interrupts",
@@ -1552,9 +1549,6 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels)
chan = malloc(sizeof(struct ide_channel));
- snprintf(chan->name, sizeof(chan->name),
- DEV_NAME, current_channel);
-
chan->mmio = addr + MACIO_IDE_OFFSET + i * MACIO_IDE_SIZE;
chan->obide_inb = macio_ide_inb;
@@ -1594,6 +1588,8 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels)
current_channel);
REGISTER_NAMED_NODE_PHANDLE(ob_ide_ctrl, nodebuff, dnode);
+ chan->ph = dnode;
+
set_property(dnode, "compatible", (is_oldworld() ?
"heathrow-ata" : "keylargo-ata"), 13);
diff --git a/openbios-devel/drivers/ide.h b/openbios-devel/drivers/ide.h
index d6c4b9f..8983c8e 100644
--- a/openbios-devel/drivers/ide.h
+++ b/openbios-devel/drivers/ide.h
@@ -167,7 +167,7 @@ struct ide_drive {
struct ide_channel {
- char name[32];
+ phandle_t ph;
struct ide_channel *next;
/*
--
1.7.10.4
More information about the OpenBIOS
mailing list