title: Which is the cleaner way to get a pointer to a struct device in linux?
body: <p>i'd need to obtain a pointer to a particular device registered in linux. Briefly, this device represents a <code>mii_bus</code> object. The problem is that this device seems doesn't belong to a bus (its <code>dev-&gt;bus</code> is <code>NULL</code>) so i can't use for example the function <code>bus_for_each_dev</code>. The device is however registered by the Open Firmware layer and i can see the relative <code>of_device</code> (which is the parent of the device i'm interested in) in <code>/sys/bus/of_platform</code>. My device is also registered in a <code>class</code> so i can find it in <code>/sys/class/mdio_bus</code>. Now the questions:</p>
  
  <ol>
  <li><p>It's possible to obtain the pointer using the pointer to the <code>of_device</code> that is the parent of the device we want?</p></li>
  <li><p>How can i get a pointer to an already instantiated class by using only the name?If it was possible i could iterate over the devices of that class.</p></li>
  </ol>
  
  <p>Any other advice would be very useful! Thank you all.</p>