Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • so that's the callback called when some other process writes to the /dev/spi... file? Just for my understanding: The mutex is really being locked by the spi driver, not by the writing process? Does is make any difference whether the writing processes open and close the file or just keep it opened the whole time and write to it periodically? Commented Apr 7, 2021 at 10:40
  • The writing process invokes the write() system call on an open file descriptor associated with the character device. That leads to the execution of the above function in the kernel to handle that operation. @DanielD. Commented Apr 7, 2021 at 15:24
  • With SPI, the writes aren't as much streaming bytes (as with a "regular" serial port or a TCP socket), but sending full messages (as with an UDP socket). The driver controls the chip select / chip enable lines too, and deactivates them between all read() and write() calls (kernel.org/doc/html/latest/spi/spidev.html). SPI devices can well depend on the chip enable to identify the start and end of a transfer. (Worse, they may require both writes and reads within the same transfer.) Commented Apr 7, 2021 at 20:53
  • Thanks to both of you for taking your time and looking up the code, really helped me to understand things :) Commented Apr 8, 2021 at 10:50
  • what if the user process gets signaled (eg.SIGKILL) while in the kernel context? does the lock stop? or does the process waits until the syscall returns? Commented Mar 30, 2022 at 13:20