CV-Bowen opened a new pull request, #21816:
URL: https://github.com/apache/nuttx/pull/21816
## Summary
`struct i2c_ops_s` has no way for a lower half to report bus state or
to complete a transfer asynchronously. The VirtIO I2C frontend (a
follow-up PR) implements `status()` and `cancel()`.
- include/nuttx/i2c: add an optional status op and a transfer callback
- `status()` op and `I2C_STATUS()`, which returns
`I2C_STATUS_PRESENT` when the op is NULL
- `callback`/`arg` in `struct i2c_msg_s` for asynchronous
completion
- include/nuttx/i2c: add a cancel op for asynchronous transfers
- `cancel()` op and `I2C_CANCEL()`, plus a `cookie` in
`struct i2c_msg_s` that a lower half fills when it accepts an
asynchronous transfer; a NULL cookie cancels everything pending
## Impact
- Header only, no Kconfig change, no in-tree driver changes.
- Both ops are appended after `shutdown`, so the in-tree lower halves
that initialise `struct i2c_ops_s` positionally (i2c_bitbang,
tca9548a, pca9540bdp, ds28e17, ez80, z8) leave them NULL. The new
`struct i2c_msg_s` members are also appended, so positional
`i2c_msg_s` initialisers zero them and transfers stay synchronous.
- Callers must check `ops->cancel` before `I2C_CANCEL()`;
`I2C_STATUS()` already handles a NULL `status`.
## 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, 0 new warnings:
- sim:nsh with `CONFIG_I2C`, `CONFIG_I2C_DRIVER`,
`CONFIG_I2C_BITBANG`, `CONFIG_I2CMULTIPLEXER_TCA9548A`,
`CONFIG_I2CMULTIPLEXER_PCA9540BDP`, `CONFIG_1WIRE_DS28E17`, which
builds the positional `i2c_ops_s` initialisers. ds28e17.c warns about
an implicit `up_udelay()` declaration on master as well; this PR does
not touch it.
- qemu-armv8a:netnsh with `CONFIG_I2C`, `CONFIG_I2C_DRIVER`,
`CONFIG_I2C_BITBANG`.
No runtime test: nothing in this PR calls the new ops. The VirtIO I2C
frontend PR exercises them.
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]