[Haskell-cafe] Genuine Need For Persistent Global State?

Alan Carter alangcarter at gmail.com
Sat Oct 17 13:54:42 EDT 2009

On Fri, Oct 16, 2009 at 9:13 PM, Bryan O'Sullivan <bos at serpentine.com>wrote:

> 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?
Thanks Bryan - your thought on this is pure and true :-)

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.

My driver can now accumulate data as I wanted, and I don't feel like I've


... the PA system was moaning unctuously, like a lady hippopotamus reading
A. E. Housman ..."
 -- James Blish, "They Shall Have Stars"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091017/d1990812/attachment.html

More information about the Haskell-Cafe mailing list