Re: [PATCH V8 06/14] rust: Add bare minimal bindings for clk framework
From: Stephen Boyd
Date: Thu Feb 06 2025 - 15:06:13 EST
Quoting Danilo Krummrich (2025-02-06 03:52:41)
> On Thu, Feb 06, 2025 at 12:49:14PM +0100, Danilo Krummrich wrote:
> > On Thu, Feb 06, 2025 at 02:58:27PM +0530, Viresh Kumar wrote:
> > > diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs
> > > new file mode 100644
> > > index 000000000000..123cdb43b115
> > > --- /dev/null
> > > +++ b/rust/kernel/clk.rs
> > > @@ -0,0 +1,48 @@
> > > +// SPDX-License-Identifier: GPL-2.0
> > > +
> > > +//! Clock abstractions.
> > > +//!
> > > +//! C header: [`include/linux/clk.h`](srctree/include/linux/clk.h)
> > > +
> > > +use crate::{
> > > + bindings,
> > > + device::Device,
> > > + error::{from_err_ptr, Result},
> > > + prelude::*,
> > > +};
> > > +
> > > +use core::ptr;
> > > +
> > > +/// A simple implementation of `struct clk` from the C code.
> > > +#[repr(transparent)]
> > > +pub struct Clk(*mut bindings::clk);
> >
> > Guess this should be Opaque<bindings::clk>.
>
> Sorry, I meant NonNull<bindings::clk>.
NULL is a valid clk. It's like "don't care" in the common clk framework
as most clk consumer operations bail out early in that case.