Consider this scenario: you've successfully developed a device driver for, say, a pressure sensor device (perhaps by using the kernel's I2C APIs to fetch the pressure from the chip via the I2C protocol). So, you have the current pressure value in a variable within the driver, which of course implies that it's within kernel memory space. The issue at hand is, how exactly do you now have a user space application retrieve this value? Well, as we learned in the previous chapter, you can always include a .read method in the driver's fops structure. When the user space app issues a read(2) system call, control will be diverted (via the virtual file system (VFS)) to your driver's read method. In there, you perform copy_to_user() (or equivalent), resulting in the user mode app receiving the value. However, but...




















































