title: How to access driver information from within the kernel?
body: <p>I work with cpu management in big.LITTLE boards and the board on which I am developing on has some ina231 power sensors. Which I believe are handled by the ina2xx_driver (this would make sense to me). My knowledge of drivers is still in development so I am unsure about how I should get the information I need to my CPU module out of the driver/devices, in a way that wont make the Linux gods angry.</p>
  
  <p>The board has 4 sensors which I believe are then stored in the <code>struct i2c_driver</code> in the linked list <code>struct list_head clients</code>. If I have understood this correctly, then my initial idea was to export a pointer to the driver</p>
  
  <pre><code>   static struct i2c_driver ina2xx_driver = { 
         .driver = { 
             .name   = "ina2xx",
         },  
         .probe      = ina2xx_probe,
         .remove     = ina2xx_remove,
         .id_table   = ina2xx_id,
     };
  
     +struct i2c_driver *ina2xx_driver_p = &amp;ina2xx_driver;
  
     +EXPORT_SYMBOL(ina2xx_driver_p);
  </code></pre>
  
  <p>to my module which could then step through the linked list of i2c clients allowing me to access individual device information by doing something like this</p>
  
  <pre><code>struct i2c_client *tmp
  struct list_head *pos;
  struct list_head *clients_head = &amp;ina2xx_driver_p-&gt;clients; 
  
  list_for_each(pos, clients_head){
      tmp = list_entry(pos, struct i2c_client, detected)
      struct ina2xx_data *data = ina2xx_update_device(tmp.dev);
      ina2xx_get_value(data, $(attribute));
  }
  </code></pre>
  
  <p>I haven't actually tried this, it's just how I imagine one solution being after reading the header files. Given my lack of knowledge on the recommended practice I thought it would be best to ask before wasting a day or two trying to implement something that is destined to fail.</p>
  
  <p>Is there a more standardized way that is used in the kernel to get device driver or device pointers to access information or way to get device information without reading it from files?</p>
  
  <p>I hope my question makes sense and thanks.</p>