<div class="gmail_quote">On Fri, Oct 16, 2009 at 9:13 PM, Bryan O'Sullivan <span dir="ltr"><<a href="mailto:bos@serpentine.com">bos@serpentine.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div class="im">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></blockquote><div><br></div><div>Thanks Bryan - your thought on this is pure and true :-)</div><div><br></div><div>Although I'm just making a toy driver, I wanted to exercise the bits a real one would need, and wrongly thought persistent state would matter. You're quite right though - generally, things that matter should go in the per device store, which can easily be kmalloc()ed/kfree()ed on open/close, picked up and passed into Haskell as a Ptr on write/read (so avoiding even the need to understand the C struct in Haskell), then peeked and poked.</div>
<div><br></div><div>My driver can now accumulate data as I wanted, and I don't feel like I've cheated.</div><div><br></div><div>Alan</div><div><br></div></div>-- <br>... the PA system was moaning unctuously, like a lady hippopotamus reading A. E. Housman ..."<br>
-- James Blish, "They Shall Have Stars"<br>