Skip to contentSkip to conversation

Multiple virtual bus instances

DISCUSSION Simon White 2 participants 2 messages Feb 7, 2007 – Feb 8, 2007

lore
Share & tools
lore
#0 lore raw

Hi,

I've been working through trying to create a virtual bus. I've
successfuly made it work for a single instance but wanted to
confirm how to create multiple instances of the virtual bus. I
believe to do this you have only one instance of your new
bus_type registered but register multiple instances of struct
device for it. I just wanted to confirm that was correct.

Lastly how do you walk over all devices on a bus instance? I
note bus_for_each_dev but that appears to take a bus_type
rather than struct device instance, hence I assume it will return
all devices from all instances. I know I could compare each
device to see if it is on a certain bus instance but wondered if
there was a better way?

Regards,
Simon

____________________________________________________________________________________
Don't get soaked. Take a quick peak at the forecast with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather

#1 lore raw
Quoted 4 lines · Simon White

Hi,

I've been working through trying to create a virtual bus.

How does this differ from a "real" bus?

Quoted 2 lines

I've successfuly made it work for a single instance but wanted to confirm how to create multiple instances of the virtual bus.

Why would you need that?

Quoted 3 lines

I believe to do this you have only one instance of your new bus_type registered but register multiple instances of struct device for it. I just wanted to confirm that was correct.

That would create multiple devices on the same bus. Is that what you need to do?

Quoted 2 lines

Lastly how do you walk over all devices on a bus
instance?

You usually do this in your bus-specific code somehow.

Quoted 3 lines

I note bus_for_each_dev but that appears to take a bus_type rather than struct device instance, hence I assume it will return all devices from all instances.

No, it will walk the bus that you created. If you need multiple busses, create multiple 'struct bus_type' structures.

Quoted 2 lines

I know I could compare each device to see if it is on a certain bus instance but wondered if there was a better way?

I think you will find that it works the way it is described.

Might I ask what you are trying to do with these multiple busses?

Note that you can have multiple trees of devices, all with the same bus_type, yet not joined together in any other way. Odds are, you probably want to do that, right?

thanks,

greg k-h