CV-Bowen opened a new pull request, #21817:
URL: https://github.com/apache/nuttx/pull/21817

   ## Summary
   
   `struct spi_ops_s.exchange` returns void, so an SPI lower half cannot
   report a timeout, a DMA error or an unmappable buffer to the caller.
   The VirtIO SPI frontend (a follow-up PR) needs to, and it uses the
   auto/inverted CS features added here.
   
   - arch, drivers/spi: fix nxstyle errors in the SPI drivers
     - The files touched below fail the current whole-file nxstyle check
       (mostly the switch/case indentation required since the 2026-07
       nxstyle update). Whitespace and brace changes only: `git diff -w`
       shows just seven empty `while` bodies changed from `;` to `{ }`,
       two re-wrapped comments and one `{` moved to its own line.
   - include/nuttx/spi: pass the SPI_SEND() word through as uint32_t
     - `SPI_SEND()` cast the word to `uint16_t` although `send()` takes
       a `uint32_t`, so wider words were truncated.
   - include/nuttx/spi: add auto CS and inverted CS hardware features
     - `HWFEAT_AUTO_CS_CONTROL` and `HWFEAT_INVERT_CS_LEVEL` take bits 4
       and 5; `HWFEAT_LSBFIRST` and `HWFEAT_TRIGGER` move to bits 6 and 7.
   - drivers/spi: return int from the exchange method
     - `exchange()` and `SPI_EXCHANGE()` return int; every lower half
       returns `OK`, or the result of the transfer helper it calls.
   - arch: return int from the remaining SPI exchange methods
     - The same for the lower halves not covered by the previous commit
       (am67, ameba, gd32w51x, gd32vw55x, nrf54l, rm57, rp23xx,
       rp23xx-rv, stm32h5, bcm2711, sim Linux SPI and its host-side
       `spi_ops_s` copy).
   - drivers/spi: let exchangeseqs decline a request with -ENOTSUP
     - `spi_transfer()` and `spi_transferseqs()` fall back to their
       generic loops when `exchangeseqs()` returns `-ENOTSUP`, so a lower
       half can implement it for only some requests.
   
   ## Impact
   
   - API: `spi_ops_s.exchange` now returns int. Out-of-tree SPI lower
     halves must change the return type and return `OK` (or an error).
     Existing callers that ignore the value are unaffected.
   - `HWFEAT_LSBFIRST` / `HWFEAT_TRIGGER` change value; in-tree users
     all go through the macros.
   - `exchangeseqs()` returning `-ENOTSUP` now means "not handled"
     instead of failing the transfer.
   - No Kconfig change, no behaviour change for existing drivers.
   
   ## Testing
   
   Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU 
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
   
   Build, one config per SPI lower half that this host has a toolchain
   for, with `CONFIG_SPI`, `CONFIG_SPI_EXCHANGE` and the chip's SPI
   instance enabled (0 new warnings):
   
   sim:nsh (+`SPI_DRIVER`, and +`SIM_SPI` for the Linux SPI bridge),
   gd-xd-w515-eval:nsh (gd32w51x), nucleo-f091rc:nsh (stm32 m0),
   nucleo-f446re:nsh (stm32 m3m4), nucleo-f722ze:nsh (stm32f7),
   nucleo-h723zg:oa_tc6 (stm32h7), nucleo-h563zi:nsh (stm32h5),
   nucleo-l432kc:nsh (stm32l4), b-u585i-iot02a:nsh (stm32u5),
   imxrt1170-evk:netnsh, spresense:audio (cxd56xx), thingy53:rgbled_cpuapp
   (nrf53), nrf54l15-tag:sensors, freedom-kl25z:nsh,
   pimoroni-pico-2-plus:audiopack and raspberrypi-pico-2-rv:nsh (rp23xx;
   compiled and linked, only the post-build picotool step is missing
   here).
   
   Configs that also fail on master in the same way (board.h without SPI
   pins, missing board functions) were compared against master rather
   than counted: devebox-stm32h743, nucleo-l552ze, flipperzero,
   nucleo-wl55jc, freedom-k28f, sabre-6quad, verdin-mx8mp, arduino-due,
   raspberrypi-4b, t3-gem-o1, rm57l843-launchxl2, lpc4337-ws. No
   toolchain here for xtensa, mips, renesas, z16, z80; those files only
   change the return type and add `return OK`.
   
   No regression in rpmsg: sim:rpserver/rpproxy and 
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping, 
rpmsgfs; 15/15). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC 
disabled, which current master needs for nxinit to start nsh there; unrelated 
to this change.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to