Skip to content

Rename lw_set_slave to lw_set_target and retire master/slave terminology #7

Closed

Description

@CameronBrooks11

Companion to feastorg/CRUMBS#31, which does the same cleanup one layer up.
Filing here because CRUMBS cannot finish its own rename while the function it
calls is still named lw_set_slave.

NXP retired master/slave from the I²C specification in 2021 (UM10204 Rev 7).
The replacement pair is controller/target.

Counts

41 occurrences of master or slave across *.c, *.h and *.md, excluding
docs/archive/. Exactly one of them is an exported symbol:

int lw_set_slave(lw_i2c_bus *bus, uint8_t addr);

Everything else is comments, documentation and prose.

The one API change

lw_set_slave → lw_set_target. It selects a target address via the
I2C_SLAVE ioctl, so target is both the standard's word and the accurate one.

Suggest keeping lw_set_slave as a deprecated inline alias rather than a hard
break. It has nine call sites in feastorg/CRUMBS
(src/hal/linux/crumbs_i2c_linux.c, seven; src/crumbs_linux.h, two in
comments) plus internal uses here in src/Wire.cpp, tests/, examples/ and
docs/. An alias lets the two repos move independently instead of needing a
synchronised release.

The I2C_SLAVE ioctl constant itself comes from the Linux kernel headers and
obviously stays as-is.

The Arduino-compatibility nuance

include/Wire.h is deliberately an Arduino Wire look-alike, so some of its
wording mirrors Arduino's API rather than describing this library:

  • Wire.h:73 — "Arduino-style overloads for slave mode compatibility"
  • Wire.h:74, Wire.h:78 — Linux userspace cannot do target mode

Arduino renamed too — their style guide moved to controller/peripheral — so
these can be reworded without breaking the compatibility framing. Worth a
deliberate decision rather than a blanket sweep, since the point of these
comments is to describe someone else's API.

Probably leave alone

Anything naming the kernel's i2c-slave interface or the I2C_SLAVE ioctl by
its upstream name. Renaming those makes the code harder to search against kernel
documentation.

Why now

A relicensing release is planned for CRUMBS, and a paper is being written that
fixes its terminology deliberately: device for anything on the wire,
peripheral for a device speaking CRUMBS, controller/target for the I²C
roles, and no master/slave anywhere. The library and the paper should agree,
and a reviewer is likely to read both.

Activity

  1. CameronBrooks11 commented on Sep 12, 2026

    @CameronBrooks11
    MemberAuthor

    Correction to the "Why now" section above.

    That paragraph describes the companion paper as using device for anything on
    the wire and peripheral for a device that speaks CRUMBS. The paper has since
    dropped that split, because it overloads a standard term: peripheral already
    means whatever answers the controller, regardless of the protocol it speaks.
    Defining it as "speaks CRUMBS" invented a hierarchy the field does not use.

    The paper now uses standard I²C vocabulary:

    • controller starts every exchange; peripheral answers it
    • CRUMBS peripheral where it matters that the peripheral implements CRUMBS
    • mixed bus for a bus carrying both
    • controller/target where the I²C bus role specifically is meant
    • no master or slave

    Nothing in the grouped file lists changes. controller is the same word in both
    vocabularies, so every recommendation in sections 1 to 4 stands as written. Only
    the justification paragraph was wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions