Subject: Re: Device configuration question
To: Martin Husemann <martin@rumolt.teuto.de>
From: Paul Goyette <paul@whooppee.com>
List: tech-kern
Date: 08/11/1997 05:58:22
Thanks - that's just what I was looking for. I just wasn't sure if it was
"OK" to traverse the dv_parent link...
On Mon, 11 Aug 1997, Martin Husemann wrote:
> Paul Goyette wrote:
>
> > So, given a pointer to the grf_softc for a particular grf, how can I
> > determine, in a supported way, if there is an ite attached to that grf?
> > Keeping in mind, of course, that an ite might be attached to any of
> > several grfs...
>
> I'm no expert on this and don't know the Mac port, so just a few tries:
>
> For frequent use: cast the "struct device *parent" passed to ite_attach
> to grf_softc and fill in a pointer to the ite_softc (initialized to NULL
> by grp_attach before)? Not good, if there's any chance of an ite attaching
> to something completely different. Not good information hidding, no clean
> encapsulation.
>
> Do something like scsi device drivers do with scsibusses: the bus passes
> the address of a struct scsi_link to the attaching device, which fills in
> his adress?
>
> For infrequent use (like yours sound) something like this?
>
> static struct device *
> find_ite_at_grf(grf)
> struct device *grf;
> {
> struct device *dev;
> for (dev = alldevs.tqh_first; dev; dev = dev->dv_list.tqe_next)
> if (strcmp(dev->dv_cfdata->cf_driver->cd_name, "ite") == 0)
> if (dev->dv_parent == grf)
> return dev;
> return NULL;
> }
>
> I hope this is OK, as I've just done something similar in my code over the
> weekend ;-)
>
>
> Martin
>
-----------------------------------------------------------------------------
| Paul Goyette | PGP Public Key fingerprint: | E-mail addresses: |
| Network Consultant | 0E 40 D2 FC 2A 13 74 A0 | paul@whooppee.com |
| and kernel hacker | E4 69 D5 BE 65 E4 56 C6 | paul_goyette@ins.com |
-----------------------------------------------------------------------------