Linux Device Drivers, 3rd Edition by Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman This errata page lists errors outstanding in the most recent printing. If you have technical questions or error reports, you can send them to booktech@oreilly.com. Please specify the printing date of your copy. This page was updated March 25, 2008. Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification Confirmed errors: {sample code} File examples/misc-modules/jit.c, function jit_fn(), 4th line from bottom; len = sprintf(buf, "%9li %9li\n", j0, j1); should be: len = sprintf(buf, "%10lu %10lu\n", (u32)j0, (u32)j1); {37} second paragraph; The parameter "num" in module_param_array(name,type,num,perm) is actually a "pointer to a integer variable". 2.6.11 change the name of the parameter to nump to avoid the confusion. (41) Two first lines; Add the MODULE_LICENSE macro to the MODULE_XXX list. (41) 1st definition, last sentence; "The second form exports without using versioning information, and the third limits the export to GPL-licensed modules." should read: "The second form limits use of the exported symbol to GPL-licensed modules." (41) middle; The following entries already appear earlier in the same list on p.39 (Quick Ref. for Ch. 2): module_init(init_function); module_exit(cleanup_function); (54) 2nd Definition (f_flags); In parentheses the sentence says 'we discuss nonblocking I/O in the section "Blocking and Nonblocking Operations" in Chapter 1'. The chapter number referenced should be 6, as the section is on page 151. (64) 1st normal paragraph; ...in the section "Using the ioctl Argument" in Chapter 1... should read: ...in the section "Using the ioctl Argument" in Chapter 6... {67} code listing for scull_read(), 3rd line of body; The assignments to 'quantum' and 'qset' should be protected by a semaphore, to avoid the following (admittedly unlikely) race condition: - The device is opened for reading by one process. - Somebody changes the quantum value with ioctl(). - A read begins on the device, reading its quantum value, but the semaphore is not yet taken. - A second process opens the device O_WRONLY, causing it to be reinitialized, thus changing the device's quantum value - That process writes to the scull device - The first read resumes (90) Last paragraph; ioctl, which we show you how to use in Chapter 1, is ... should read: ioctl, which we show you how to use in Chapter 6, is ... [194] 2nd paragraph; Text states that the return value of wait_event_timeout and wait_event_interruptible timeout is never negative. This is correct for wait_event_timeout only. In fact, the interruptible version will return -ERESTARTSYS. (197) 4th paragraph; ... in the section "Spinlocks and Atomic Context" in Chapter 1, ... should read: ... in the section "Spinlocks and Atomic Context" in Chapter 5, ... (198) 5th paragraph; ...(discussed in the section "Atomic Variables" in Chapter 1)... should read: ...(discussed in the section "Atomic Variables" in Chapter 5)... (215) paragraph under _GFP_COLD; "Chapter 1" should read: "Chapter 15" (216) 3rd paragraph; "Chapter 1" should read: "Chapter 15" (230) paragraph under Obtaining Large Buffers; "Chapter 1" should read: "Chapter 15" (250) First line on page; "vmalloc and Friends" in Chapter 1. should read: "vmalloc and Friends" in Chapter 8. [276] last paragraph example; There is a synchronization mistake in example shown after: void short_do_tasklet (unsigned long unused) { int savecount = short_wq_count, written; This is not safe to clean the variable in this manner If at this time hw interrupt will occur, we will lose one(or maybe more) tick for We should use the to prevent such a problem short_wq_count = 0; /* we have already removed from the queue */ Author response: You are correct - there is a very narrow window in which we can race with the interrupt handler. As you suggest, it could be fixed with a spinlock, though, perhaps, a seqlock would be a more suitable tool for this situation. {281} 2nd paragraph; "IRQ 5 is used for the serial ATA and IEEE 1394 controllers;" should be "IRQ 5 is used for the serial ATA and USB 2.0 controllers;" [293] 2nd last paragraph; le16_to_cpus does not do "signed" conversion but "in situ" conversion. See kernel header include/linux/byteorder/generic.h. [308] Figure 12-2, top row of registers; The Class Code register should be shaded, to indicate that it is a required register. (388) Third paragraph in "The class_simple interface"; "Chapter 1" should read: "Chapter 11" [388] "The class_simple Interface", entire section; The class_simple interface is no longer present in kernels from 2.6.13 on. All references in the book to this interface and its functions are obsolete now, and should be removed. (416,418) Bottom (by page number); The Chapter information at bottom of page is incorrect. Chapter 1: Memory Mapping and DMA should be Chapter 15: Memory Mapping and DMA [469] 2nd & 3rd code fragments; in second fragment it says -- struct sbull_dev { ... int size; /Device size in sectors */ ... in the third frgament, this is being initialized as bytes??!! dev->size = nsectors * hardsect_size; which is it? AUTHOR'S REPLY: Yes, the comment is wrong; somewhere along the line, that field became the size in bytes. So, among other things, that means that the "int" type may not be the best choice - though it's unlikely to overflow for the sizes normally used with sample RAM disks. {548} Last paragraph, 3rd line; "It it used to register" should be: "It is used to register" [556] 3rd paragraph of the section "Flow of Data"; This paragraph says that I cannot call copy_from_user, kmalloc, and *printk* in an interrupt context. But on page 79, the first paragraph says I can call printk from anywhere, including interrupt handlers. I think page 79 is true, and the tiny_write() sample code on page 556 does call printk without checking context. AUTHOR'S COMMENTS: You are right, printk() is designed to be callable from anywhere - though it might lose output if called at the wrong time from interrupt context. Sorry for the confusion. (590-592) function listing in index; One of the very useful things in this book is the function listing in the index. However (you knew there would be one), the value of this list is lessened because some of the functions are alphabetized under their return value rather than their name, while most are alphabetized by their name. Examples include: "const char *dev_name" under "const" rather than "dev_name" "int seq_escape" under "int" rather than "seq_escape" "void tasklet_disable" under "void" rather than "tasklet_disable" There are mis-alphabetized functions listed under "const", "int", "unsigned", and "void". {604} index, middle of 2nd column; The following entries are missing: "pci_module_init, 325" "pci_register_driver, 312-313, 325" {613} index, top of page; The following entry is missing: "udev, 403-405 (back cover) 3rd paragraph; ".. been competely updated for Version 2.6.10 .." should read: .. been completely updated for Version 2.6.10 .."