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 ...
Get Linux Kernel Programming Part 2 - Char Device Drivers and Kernel Synchronization now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.