title: Using container_of with a pre-initialized struct
body: <p>Sorry that the title is a bit vague. Here is what I want to do.</p>
  <p>First lets say there is the following struct.</p>
  <pre><code>struct info {
    struct device *dev
    int a;
    int b;
  }
  </code></pre>
  <p>I allocate memory for this struct and assign values as the following.</p>
  <pre><code>struct info *i0;
  i0 = kzalloc(sizeof(*i), GFP_KERNEL);
  i0-&gt;dev = dev0; //dev is pre-initialized
  i0-&gt;a = 0;
  i0-&gt;b = 1;
  </code></pre>
  <p>I am unsure if I can use <code>container_of</code> with pre-initialized <code>dev0</code> that I used to assign to <code>i0-&gt;dev</code>. Something like below.</p>
  <pre><code>struct info * i1 = container_of(dev0, struct info, dev);
  do_something(i1-&gt;a, i1-&gt;b);
  </code></pre>
  <p>Doing so gives the following error in the line of <code>container_of</code>.</p>
  <pre><code>error: undefined symbol: __compiletime_assert_###
  </code></pre>
  <p>Can someone help me understand the error and guide me on correct use of <code>container_of</code>? What would be a good workaround?
  Thank you very much.</p>