title: Adaptation from old init_timer to new timer_setup
body: <p>I have been trying to port a driver from 2.6 to 4.X without support from the original board manufacturer (and very limited Linux experience).</p>
  <p>The original driver uses <code>init_timer()</code> and passes in a pointer to the <code>timer_list</code> structure. That <code>timer_list</code> structure's <code>data</code> element was set to a pointer to another memory structure and the <code>function</code> element set to the callback.  Inside the callback function the <code>data</code> element was used to access other bits of stuff.</p>
  <p>The current timer <code>init</code>-method uses:</p>
  <pre><code>timer_setup( timer_list *, callback, (unsigned int) flags);
  </code></pre>
  <p>and the <code>timer_list</code> structure was changed to eliminate the <code>data</code> field.</p>
  <p>I'm not sure what is the best/proper way to inform the callback function of the equivalent <code>data</code> element.  Can anyone provide some guidance?</p>
  <p>Here is a snippet of the old driver:</p>
  <pre><code>myDevice * dev;
  
  dev-&gt;getIntrTimer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);    
  init_timer(dev-&gt;getIntrTimer);
  
  dev-&gt;getIntrTimer-&gt;data = (unsigned long) dev;
  dev-&gt;getIntrTimer-&gt;function = GetIntrTimerCallback;
  </code></pre>
  <p>The callback function starts off like this:</p>
  <pre><code>void GetIntrTimerCallback(unsigned long devAddr)
  {
      myDevice *dev = (myDevice *) devAddr;
      dev-&gt;blahBlah++; // etc.
  </code></pre>
  <p>So the old code gets passed the pointer to <code>myDevice</code> so inside the callback that structure can be accessed.</p>
  <p>But with the new timer method only has available an int that is 4 bytes but a pointer is 8 (or whatever).</p>
  <p>What I'd like to do is this:</p>
  <pre><code>dev-&gt;getIntrTimer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
  timer_setup(dev-&gt;getIntrTimer, GetIntrTimerCallback, dev);
  </code></pre>
  <p>but of course that generates compile errors because <code>dev</code> is a pointer to type <code>myDevice</code>, which does not fit in an int.</p>