<div dir="ltr"><div><div>Hi all,<br><br></div>I'm dealing with a SPI driver and I have a doubt. I need to read and write data to spi (registers and values) inside interrupt handler. I want to know if this pattern is safe or if I'll face problems with it.<br><br></div>This code is being added to gpio-mcp23s08.c driver to handle IRQ and save INTCAP at interruption time. INTCAP register keeps the input port status at interruption time. I want to capture this as fast as possible and put it at a circular queue. I write this code inspired by spi_sync function, but using spinlocks so it doesn't sleeps. But, these spin_(un)lock calls seems a bad ideia to me. Any better idea or guidelines?<br><div><br>Here is the code.<br><a href="https://gist.github.com/gkos/4cce494e90518077084a#file-gpio-mcp23s08-c-L440">https://gist.github.com/gkos/4cce494e90518077084a#file-gpio-mcp23s08-c-L440</a><br><br></div><div>The functions are mcp23s17_read_irqsafe and mcp23s17_read_irqsafe_complete<br><br></div><div>PS: The code is a little messed up (because I've been trying to optimize this INTCAP capturing by many means)<br></div><div><br></div><div>Cheers<br></div><div>- dhs<br clear="all"></div><div><div><div><br>-- <br><div class="gmail_signature"><div style="text-align:right"><i>"Do or do not. There is no try"</i><br><i> </i><i><b>Yoda Master</b></i><br></div></div>
</div></div></div></div>