Live data from Hacker News

Writing device drivers in Linux: A brief tutorial (2006)

freesoftwaremagazine.com

31–36 of 36 posts

Re: Writing device drivers in Linux: A brief tutorial (2006)

#31

Earlier quoted context omitted.

While not straightforward or easy (for an average chap), it's quite possible, and very useful. Although I wouldn't call it most people's programming language of choice, knowing, and being able to grapple with how C pushes memory management to user-code will definitely change the way you think about programming. TLDR : Pick up any of the hundreds of books on it and start learning! If you're having trouble motivating y…

K&R was the first and only book about C that actually worked for me. Everything else was verbose, confusing, and left me with no more than the ability to do basic character apps. I read dozens of the "hundreds of books on it", and they all left me incompetent at C. K&R allowed me to become useful in the C language, including hacking on kernel modules. I'm sure there are other good books on C. But, I never found one.…

I'd go even further: I would say that K&R is the best written book in all of computer science.

It is so brief, yet it covers everything about C, introduces you to programming and to UNIX, and teaches you style. It's written by no less than the guy who coined the term "UNIX" (the K in K&R) and the inventor of C (the R). The original K&R--not including the reference manual at the end--was only 177 pages. The updated ANSI C version, 189 pages.

The opposite is any book about Java. The usual university-level Java books are a sickening 1000+ pages.

I've often wondered how anyone who's trying to learn something new can prefer a thick book over a thin one. I deliberately look for thin books -- but most people must fall for the thick==better notion.

Re: Writing device drivers in Linux: A brief tutorial (2006)

#33
post #4

Article is from 2006.

It doesn't make it any less relevant, people post Wikipedia pages, irrelevant news stories meant to make you "awww" on here, etc, at least this not only provides technical insight but is also relevant to the normal content on HN.

Yes, but they publication year should be indicated in the title if it's an older article. When I posted my comment it was not.

Re: Writing device drivers in Linux: A brief tutorial (2006)

#34
post #6

Does anyone have any suggestions for books/learning materials related to the pre requisites mentioned in the article, specifically Microprocessor programming? I've tried to find some in the past but having no prior EE experience I find even some of the basics challenging. I have experience with C, but don't really know where to start with the lower level stuff. I'm thinking I should start with a simple book like Elec…

If you get the basics of assembly programming, and read any periferal's datasheet (get a simple one), you'll notice that there is protocol for accessing the periferal. If you can understand that protocol and know how you can write C code that conforms to it, you know "microprocessor programming".

If not, well, you may need to learn assembly, C, or something else entirely (but probably not EE), and the experiment will help you discover what exactly you need.

Re: Writing device drivers in Linux: A brief tutorial (2006)

#36
I haven't bothered to check the docs, but isn't that a race condition in memory_init, registering the device before allocating the buffer?

Or are drivers loaded while holding a global lock? Even though driver (un)loading probably is fairly rare, that seems a bit heavy to me.

Worse, the 'goto fail' path, if it is ever hit, seems to leak a register_chrdev call.

Post reply on HN