tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: (Semi-random) thoughts on device tree structure and devfs

On Thu, 11 Mar 2010, Masao Uebayashi wrote:

> On Thu, Mar 11, 2010 at 6:56 PM, Iain Hibbert 
> <> wrote:
> > On Thu, 11 Mar 2010, Masao Uebayashi wrote:
> >> > We can discard the pseudo-devices concept, if need be.
> >>
> >> In what sense?
> >>
> >> As I explained in the first post, pseudo device is strict definition;
> >> it has no parent in terms of physiical topology.  It may have parents
> >> in terms of components.   I've very carefully investigated those.  I
> >> strictly defferenciate them.  Please re-read the first post in this
> >> thread.
> >
> > If a device has no parent, just attach it at root (similar to mainbus*),
> > with parent == NULL, or even pseudo* at root, and pseudo-dev* at pseudo?
> >
> > It is a frustration when building a 'software' device that there are some
> > differences between the methodology of configuration, and it is not
> > possible to pass configuration arguments from userland into the device
> > attach routine..
> Could you show one (or more) real example(s) / senario(s)?  That would
> help to understand problems & clarify requirements...

Well, a line discipline which takes serial IO and converts it into a soft
device which interacts with the rest of the system. In particular example,
dev/bluetooth/btuart.c does that for a bluetooth device. The open routine
is called from the TIOSLINED ioctl code and does:

        cfdata = malloc(sizeof(struct cfdata), M_DEVBUF, M_WAITOK);
        for (unit = 0; unit < btuart_cd.cd_ndevs; unit++)
                if (device_lookup(&btuart_cd, unit) == NULL)

        cfdata->cf_name = btuart_cd.cd_name;
        cfdata->cf_atname = btuart_cd.cd_name;
        cfdata->cf_unit = unit;
        cfdata->cf_fstate = FSTATE_STAR;

        dev = config_attach_pseudo(cfdata);
        if (dev == NULL) {
                free(cfdata, M_DEVBUF);
                return EIO;

        sc = device_private(dev);
        sc->sc_tp = tp;

here, we must find the device softc and insert some information after
attach has finished (tp == tty pointer) because there is no way to pass
that to the btuart_attach() routine.

There was a thread recently regarding extending this driver,

with Kiyohara wishing to pass some additional configuration that would be
possible with eg

        dev = config_found(NULL, &arg, ...);

and would also solve the (very slight) race condition, and moreover it
would not require malloc of cfdata.

The "parent" argument is mostly unused by autoconfig anyway..


Home | Main Index | Thread Index | Old Index