Skip to content

Migrate drivers away from legacy I2C helpers - #936

Open
davecheney wants to merge 2 commits into
tinygo-org:devfrom
davecheney:davecheney-inline-legacy-i2c-helpers
Open

davecheney wants to merge 2 commits into
tinygo-org:devfrom
davecheney:davecheney-inline-legacy-i2c-helpers

Conversation

@davecheney

Copy link
Copy Markdown
Contributor

The legacy I2C register helpers are no longer needed. Deprecate them and let tinygo fix migrate callers to direct bus transactions.

This is an example of tinygo fix.

  • Commit 90a36d2 adds the deprecation warnings and //go:fix inline annotations.
  • Commit 942b9ec is the result of running tinygo fix -inline -inline.allow_binding_decl=true -target waveshare-rp2040-pizero -tests=true on 33 caller packages.

This is a partial migration. The inline analyzer left calls it could not safely inline, and existing package errors prevented a full ./... run.

Keep the generated migration separate from the annotations so its effect can be reviewed on its own.
@soypat

soypat commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

So this is a net improvement, who likes having legacy. I will note that the improvement is net looks- I think we still are allocating just like we did with legacy package, just that now it no longer says legacy (still copies legacy behaviour)... which feels like sweeping part of the baggage under the rug...

@soypat

soypat commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Ideally some of these drivers follow the regmap pattern and could easily be rewritten with the idiom

@davecheney

Copy link
Copy Markdown
Contributor Author

Yes, I should add that this PR was mostly to show it off in the monthly call. I just looked for the lowest hanging fruit in the drivers repo to make the point.

Probably doing source rewriting en mass would start by planning a better rewrite target than I did by shotgunning those two i2c functions.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants