From: Fabien Parent <parent.f@gmail.com>
To: "Rob Herring" <robh@kernel.org>,
"Saravana Kannan" <saravanak@google.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
"Mark Brown" <broonie@kernel.org>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Bjorn Andersson" <andersson@kernel.org>,
"Konrad Dybcio" <konradybcio@kernel.org>,
"Fabien Parent" <parent.f@gmail.com>
Cc: devicetree@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-arm-msm@vger.kernel.org, vinod.koul@linaro.org,
Fabien Parent <fabien.parent@linaro.org>,
Fiona Behrens <me@kloenk.dev>
Subject: [PATCH 0/9] Regulator driver with I2C/Regmap Rust abstractions
Date: Wed, 18 Dec 2024 15:36:30 -0800 [thread overview]
Message-ID: <20241218-ncv6336-v1-0-b8d973747f7a@gmail.com> (raw)
This patch series adds a new regulator driver used by APQ8039 T2,
as well as all the Rust abstractions needed to write that driver.
This series is adding three abstractions:
* I2C: I do not expect this one to be too controversial since it is
closely following what is done for the platform abstraction.
* Regmap: This might be the abstraction that will trigger most of the
conversations since I took some liberties, and used what Rust has to
offer in order provide something that seems to me user-friendly while
also providing type-safety to ensure correct usage of the APIs.
A problem I faced is that 'struct regmap' is not reference counted,
and pointer to it are being held in several places. In C it is
mostly expected to use devm_ API during allocation and forget about
the pointer lifetime, but this does not seem idiomatic to rust since
one would expect that the `Regmap` structure to be deinited and
deallocated when dropped. I was hesitating between adding a refcount
to the C API, or maintain some form of refcount by wrapping the
structure into a Arc, and making sure that each abstraction for C code
that hold a pointer to a regmap would keep a Arc<Regmap> instance.
I chose to do the later for simplicity.
* Regulator driver: This one contains the bare minimum to write the
ncv6336 drivers. I also have an abstraction for the consumer part, but
it will come later in another patch series for another driver.
Dependencies:
[1] Entire series depends on the patch series from Danilo adding Device
and OF Rust abstractions: 2024121550-palpitate-exhume-348c@gregkh
[2] "rust: add abstraction for regmap" depends on genmask:
CAH5fLgjOKQdKViAGArMjvXjVmYpbo_sA8xoQGwu+DCW1FDFRXA@mail.gmail.com
[3] "rust: regulator: add support for regmap" depends on the Sealed trait:
20230224-rust-iopt-rtkit-v1-1-49ced3391295@asahilina.net
A while ago when Rust support was close to getting merged in the kernel
I decided to learn Rust to see what the fuss was about and see if I
could help contribute to it. Since then I've been working on a few drivers
during my free time, but my code was depending on too much out-of-tree
code. With the patch series [1] getting close to being merged, it was
finally time to send my code to the mailing list, so here it is.
Happy reviewing!
Fabien
Signed-off-by: Fabien Parent <fabien.parent@linaro.org>
---
Fabien Parent (8):
rust: add abstraction for regmap
rust: error: add declaration for ENOTRECOVERABLE error
rust: regulator: add abstraction for Regulator's modes
rust: regulator: add Regulator Driver abstraction
rust: regulator: add support for regmap
dt-bindings: regulator: add binding for ncv6336 regulator
regulator: add driver for ncv6336 regulator
arm64: dts: qcom: apq8039-t2: add node for ncv6336 regulator
Fiona Behrens (1):
rust: i2c: add basic I2C client abstraction
.../bindings/regulator/onnn,ncv6336.yaml | 54 +
MAINTAINERS | 4 +
arch/arm64/boot/dts/qcom/apq8039-t2.dts | 23 +
drivers/regulator/Kconfig | 7 +
drivers/regulator/Makefile | 1 +
drivers/regulator/ncv6336_regulator.rs | 241 +++++
rust/bindings/bindings_helper.h | 4 +
rust/helpers/helpers.c | 2 +
rust/helpers/i2c.c | 13 +
rust/helpers/regmap.c | 48 +
rust/kernel/error.rs | 1 +
rust/kernel/i2c.rs | 288 ++++++
rust/kernel/lib.rs | 6 +
rust/kernel/regmap.rs | 1043 ++++++++++++++++++++
rust/kernel/regulator.rs | 44 +
rust/kernel/regulator/driver.rs | 991 +++++++++++++++++++
16 files changed, 2770 insertions(+)
---
base-commit: 26033691d5821bb493dd3426140939d0a79cd480
change-id: 20241025-ncv6336-12324a94c693
prerequisite-message-id: <2024121550-palpitate-exhume-348c@gregkh>
prerequisite-patch-id: b798fb7308e85f8cd237e3de0c33f3079eec29b8
prerequisite-patch-id: ac93ef5057cbb09cf886223c4f10e53eeec1d234
prerequisite-patch-id: ea80287941ef43f59fa75a28e6798ff10c8e90c1
prerequisite-patch-id: 482d8f7c10b0b79fb5d06e3718fd6da0fdd0dfa2
prerequisite-patch-id: cd9756c9586f394e5b39198497979aa1384ad2b8
prerequisite-patch-id: 313083700e67eab809a6b673d1fd835a6bd18625
prerequisite-patch-id: d0c7198d84ffa229221bbe06541136c97e8aae4e
prerequisite-patch-id: 0c4e157879b92f366feca2e89b5719e0a9bfa36a
prerequisite-patch-id: 515464a50ad216e2e9811043db8ca341262db288
prerequisite-patch-id: c50da45a4d7e62930f78b854f9afc636120dc255
prerequisite-patch-id: 5e32316afbfed41fe68cc096bf5a93201d0c65f9
prerequisite-patch-id: 15b08041af5e8f50619e3098b01ac0c0c0357751
prerequisite-patch-id: 3feaab560cf92641ee1af4e07cd5cb2a50aa36a5
prerequisite-patch-id: 14a272276db1704d58a2afc140da51826347a90e
prerequisite-patch-id: c79292d0686dd843cf25f5a2300445e410e99d13
prerequisite-patch-id: ea5c28331c595ad00929291b483c8848f3ff84cf
prerequisite-patch-id: 69858ba82eb5852a4e7e36d084d2917ba4e8a6cd
prerequisite-patch-id: 3f1b33691d5ad742f689a90d41bfd37244ff4133
Best regards,
--
Fabien Parent <parent.f@gmail.com>
next reply other threads:[~2024-12-18 23:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-18 23:36 Fabien Parent [this message]
2024-12-18 23:36 ` [PATCH 1/9] rust: i2c: add basic I2C client abstraction Fabien Parent
2024-12-19 13:03 ` Rob Herring
2024-12-19 15:33 ` Fabien Parent
2024-12-18 23:36 ` [PATCH 2/9] rust: add abstraction for regmap Fabien Parent
2024-12-20 13:16 ` Mark Brown
2024-12-18 23:36 ` [PATCH 3/9] rust: error: add declaration for ENOTRECOVERABLE error Fabien Parent
2024-12-18 23:36 ` [PATCH 4/9] rust: regulator: add abstraction for Regulator's modes Fabien Parent
2024-12-18 23:36 ` [PATCH 5/9] rust: regulator: add Regulator Driver abstraction Fabien Parent
2024-12-19 10:26 ` Danilo Krummrich
2024-12-19 16:00 ` Fabien Parent
2024-12-19 18:58 ` Mark Brown
2024-12-18 23:36 ` [PATCH 6/9] rust: regulator: add support for regmap Fabien Parent
2024-12-18 23:36 ` [PATCH 7/9] dt-bindings: regulator: add binding for ncv6336 regulator Fabien Parent
2024-12-19 9:28 ` Krzysztof Kozlowski
2024-12-19 16:13 ` Fabien Parent
2024-12-21 20:20 ` Krzysztof Kozlowski
2024-12-18 23:36 ` [PATCH 8/9] regulator: add driver " Fabien Parent
2024-12-19 10:19 ` Dirk Behme
2024-12-20 14:50 ` Mark Brown
2024-12-18 23:36 ` [PATCH 9/9] arm64: dts: qcom: apq8039-t2: add node " Fabien Parent
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241218-ncv6336-v1-0-b8d973747f7a@gmail.com \
--to=parent.f@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=andersson@kernel.org \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=fabien.parent@linaro.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@kloenk.dev \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=saravanak@google.com \
--cc=tmgross@umich.edu \
--cc=vinod.koul@linaro.org \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox