This is all pretty good as a start, but you *can'* use dmesg. Something else has to be used. You also have to decide which is more important- spitting out a config file (logical hierarchy) or printing out the device tree (hardware hierarchy + pseudo device list).