BMI160 SPI op queue race condition fix

The async SPI queue index is reset after a SPI command is sent to
SPI driver. However, if the SPI transaction is very short and there
is other interrupts going on, the SPI driver can finish and invoke
SPI transaction callback before the reset happen. If the callback
tries to send another SPI command, the new command will be appended
after previous one and cause problem.

This CL fix this issue by saving a copy of the index before calling
SPI driver and thus avoid the problem.

cherry-pick from fb5ffc3b774fc87b3dcf70261188393eef81423a

bug: b/29625330
Change-Id: I509ab9449b6718e2277f6ae5ab29112cbf0a3496
1 file changed