* [PATCH i2c-tools 0/2] Add support for message modifier flags
@ 2025-11-28 10:40 Benoît Monin
2025-11-28 10:40 ` [PATCH i2c-tools 1/2] i2cdetect: Display mangling and nostart support Benoît Monin
2025-11-28 10:40 ` [PATCH i2c-tools 2/2] i2ctransfer: Add optional message modifier flags Benoît Monin
0 siblings, 2 replies; 3+ messages in thread
From: Benoît Monin @ 2025-11-28 10:40 UTC (permalink / raw)
To: linux-i2c; +Cc: Jean Delvare, Thomas Petazzoni, Benoît Monin
I2C messages can be modified with a set of flags covered by the protocol
mangling and the skip repeated start functionalities. This series add
support for such flags to i2cdetect and i2ctransfer.
The first patch shows the support of protocol mangling and repeated
start skipping in the output of 'i2cdetect -F'.
The second patch adds the parsing of optional flags to i2ctransfer
message description. Those command-line flags then set the i2c message
flags alongside the read/write flag.
I wrote these changes to test the insertion of I2C_M_STOP flag in
multi-message transactions with i2ctransfer, but the other flags can be
useful for various test scenarios.
The patches use defines that have been present in the kernel since
v3.6 released in 2012. If compatibility with older kernel is required,
we will need to wrap some of them with #ifndef ... #endif.
Maybe a minimum kernel version can be documented in the README?
Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
---
Benoît Monin (2):
i2cdetect: Display mangling and nostart support
i2ctransfer: Add optional message modifier flags
tools/i2cdetect.c | 4 ++++
tools/i2ctransfer.c | 34 +++++++++++++++++++++++++---------
2 files changed, 29 insertions(+), 9 deletions(-)
---
base-commit: ea51da725b743da00b894dfdc4ab189f5a51e90e
change-id: 20251127-msg-flags-3d2b2da9ae28
Best regards,
--
Benoît Monin, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH i2c-tools 1/2] i2cdetect: Display mangling and nostart support
2025-11-28 10:40 [PATCH i2c-tools 0/2] Add support for message modifier flags Benoît Monin
@ 2025-11-28 10:40 ` Benoît Monin
2025-11-28 10:40 ` [PATCH i2c-tools 2/2] i2ctransfer: Add optional message modifier flags Benoît Monin
1 sibling, 0 replies; 3+ messages in thread
From: Benoît Monin @ 2025-11-28 10:40 UTC (permalink / raw)
To: linux-i2c; +Cc: Jean Delvare, Thomas Petazzoni, Benoît Monin
Show the support of protocol mangling and repeated start elision in the
list of fonctionnalities displayed with '-F'.
Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
---
tools/i2cdetect.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/i2cdetect.c b/tools/i2cdetect.c
index bb2f146..70b585d 100644
--- a/tools/i2cdetect.c
+++ b/tools/i2cdetect.c
@@ -165,6 +165,10 @@ static const struct func all_func[] = {
{ .value = I2C_FUNC_SLAVE,
.name = "Target mode" },
#endif
+ { .value = I2C_FUNC_PROTOCOL_MANGLING,
+ .name = "Protocol mangling" },
+ { .value = I2C_FUNC_NOSTART,
+ .name = "Skip repeated start" },
{ .value = 0, .name = "" }
};
--
2.52.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH i2c-tools 2/2] i2ctransfer: Add optional message modifier flags
2025-11-28 10:40 [PATCH i2c-tools 0/2] Add support for message modifier flags Benoît Monin
2025-11-28 10:40 ` [PATCH i2c-tools 1/2] i2cdetect: Display mangling and nostart support Benoît Monin
@ 2025-11-28 10:40 ` Benoît Monin
1 sibling, 0 replies; 3+ messages in thread
From: Benoît Monin @ 2025-11-28 10:40 UTC (permalink / raw)
To: linux-i2c; +Cc: Jean Delvare, Thomas Petazzoni, Benoît Monin
Allow setting protocol mangling and repeated start elision flags of an i2c
message with a set of optional command-line flags. These optional flags
are parsed at the beginning of the DESC field up to a read or write flag.
For example, to read one byte from address 0x50 followed by a stop, then
write two bytes at 0x54 on bus 0, one would call i2ctransfer as follow:
i2ctransfer 0 pr1@0x50 w2@0x54 0x10 0x20
Since the new flags are optional, this patch preserves the compatibility
of the i2ctransfer syntax.
Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
---
tools/i2ctransfer.c | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c
index 4db98e3..921ffaa 100644
--- a/tools/i2ctransfer.c
+++ b/tools/i2ctransfer.c
@@ -52,9 +52,16 @@ static void help(void)
" -V version info\n"
" -y yes to all confirmations\n"
" I2CBUS is an integer or an I2C bus name\n"
- " DESC describes the transfer in the form: {r|w}LENGTH[@address]\n"
- " 1) read/write-flag 2) LENGTH (range 0-65535, or '?')\n"
- " 3) I2C address (use last one if omitted)\n"
+ " DESC describes the transfer in the form: [inpst]{r|w}LENGTH[@address]\n"
+ " 1) optional message modifier flags\n"
+ " i: ignore NACK from client\n"
+ " n: no master ACK/NACK bit in a read message\n"
+ " p: emit a STOP after the message\n"
+ " s: skip repeated start\n"
+ " t: toggle read/write bit\n"
+ " 2) mandatory read/write flag\n"
+ " 3) LENGTH (range 0-65535, or '?')\n"
+ " 4) I2C address (use last one if omitted)\n"
" DATA are LENGTH bytes for a write message. They can be shortened by a suffix:\n"
" = (keep value constant until LENGTH)\n"
" + (increase value by 1 until LENGTH)\n"
@@ -202,12 +209,21 @@ int main(int argc, char *argv[])
case PARSE_GET_DESC:
flags = 0;
- switch (*arg_ptr++) {
- case 'r': flags |= I2C_M_RD; break;
- case 'w': break;
- default:
- fprintf(stderr, "Error: Invalid direction\n");
- goto err_out_with_arg;
+ for (int done = 0; !done; ) {
+ switch (*arg_ptr++) {
+ /* optional flags */
+ case 'i': flags |= I2C_M_IGNORE_NAK; break;
+ case 'n': flags |= I2C_M_NO_RD_ACK; break;
+ case 'p': flags |= I2C_M_STOP; break;
+ case 's': flags |= I2C_M_NOSTART; break;
+ case 't': flags |= I2C_M_REV_DIR_ADDR; break;
+ /* mandatory flags */
+ case 'r': flags |= I2C_M_RD; done = 1; break;
+ case 'w': done = 1; break;
+ default:
+ fprintf(stderr, "Error: Invalid flag\n");
+ goto err_out_with_arg;
+ }
}
if (*arg_ptr == '?') {
--
2.52.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-28 10:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-28 10:40 [PATCH i2c-tools 0/2] Add support for message modifier flags Benoît Monin
2025-11-28 10:40 ` [PATCH i2c-tools 1/2] i2cdetect: Display mangling and nostart support Benoît Monin
2025-11-28 10:40 ` [PATCH i2c-tools 2/2] i2ctransfer: Add optional message modifier flags Benoît Monin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).