<div class="gmail_quote">On Fri, Oct 16, 2009 at 11:59 AM, Alan Carter <span dir="ltr">&lt;<a href="mailto:alangcarter@gmail.com">alangcarter@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><br></div><div>Trouble is, my function is (ultimately) being called from the C kernel stuff. It isn&#39;t on the bottom of a call graph coming from a Haskell main. A driver really needs to know where it&#39;s at. So I seem to need some kind of global, persistent state, and Control.Monad.State seems to be out because I can&#39;t pass a State around my call graph.</div>
</blockquote><div><br></div><div>You don&#39;t need anything special for this. A Linux kernel &quot;struct device&quot; has a &quot;void *driver_data&quot; member which is private for your use, and intended for precisely this purpose. Global persistent state makes no more sense for kernel drivers than for most other code: how would it work if you had two mice plugged into your system?</div>
<div><br></div><div>If you want a decent reference on writing Linux driver code, seeĀ <a href="http://lwn.net/Kernel/LDD3/">http://lwn.net/Kernel/LDD3/</a></div><div><br></div><div>Your friendly kernel and Haskell hacker,</div>
<div>Bryan.</div></div>