<div class="gmail_quote">On Fri, Oct 16, 2009 at 11:59 AM, Alan Carter <span dir="ltr"><<a href="mailto:alangcarter@gmail.com">alangcarter@gmail.com</a>></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't on the bottom of a call graph coming from a Haskell main. A driver really needs to know where it's at. So I seem to need some kind of global, persistent state, and Control.Monad.State seems to be out because I can't pass a State around my call graph.</div>
</blockquote><div><br></div><div>You don't need anything special for this. A Linux kernel "struct device" has a "void *driver_data" 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>