Re: How to make a bus with heterogeneous devices?

From: Federico Vaga
Date: Sat Mar 03 2012 - 10:41:04 EST


> Maybe I miss something but it sounds not that different from USB.
>
> You have a bus that enumerates devices and a "bus driver" creates a
> generic device on that bus for everything it finds. These devices stay
> generic, do not have type-specific attributes, but export matches
> again to bind other device-specific drivers, which create _new_ child
> devices below the generic ones with the proper attributes matching
> their individual type of devices. So every "logical" device is always
> represented by one generic device and one type-specific child device.

It sounds like our option 5:

> 5- The real attributes may live in another device, which is a child of
> the one used within the bus abstraction. Here the drawback is using
> an additional device and directory level for no reason.

- I register the generic (empty) device on the bus
- when the device match with a driver
- I register a new device child of the matched one but without connect
it directly on the bus.

The result will be something like (zio is our bus):

/sys/bus/zio/devices/<generic-dev1>/<real-device1>/<attributes>
/sys/bus/zio/devices/<generic-dev2>/<real-device2>/<attributes>
/sys/bus/zio/devices/<generic-devN>/<real-deviceN>/<attributes>

When there is not a driver:

/sys/bus/zio/devices/<generic-dev1>/<device-stuff>
/sys/bus/zio/devices/<generic-devN>/<device-stuff>

Where the generic-dev is an empty device used to make the bus work. Is
it correct?

> All these devices, the generic ones and the type-specific ones can be
> on the same bus (struct bus_type) when they get a "struct device_type"
> assigned which carries the device-type specific set of attributes.

But if all devices can live on the bus (set device->bus for all
devices), when I register the "real-device" (type-specific) the bus try
to match it with a driver (again); but we already matched the device
with its driver. it is better if the type-specific devices are not
directly on the bus but only a child of a device on the bus.

--
Federico Vaga
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/