From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Wedson Almeida Filho <wedsonaf@gmail.com>
Cc: "Asahi Lina" <lina@asahilina.net>,
"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>,
"Will Deacon" <will@kernel.org>,
"Robin Murphy" <robin.murphy@arm.com>,
"Joerg Roedel" <joro@8bytes.org>,
"Hector Martin" <marcan@marcan.st>,
"Sven Peter" <sven@svenpeter.dev>,
"Arnd Bergmann" <arnd@arndb.de>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Alyssa Rosenzweig" <alyssa@rosenzweig.io>,
"Neal Gompa" <neal@gompa.dev>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
asahi@lists.linux.dev
Subject: Re: [PATCH 5/5] rust: device: Add a stub abstraction for devices
Date: Thu, 9 Mar 2023 18:11:18 +0100 [thread overview]
Message-ID: <ZAoTNlF+bHyyGs7x@kroah.com> (raw)
In-Reply-To: <CANeycqrtjKMfpae_DUp-VrDZugJVO7mcbBvUBB+zAc=E6aU4tw@mail.gmail.com>
On Thu, Mar 09, 2023 at 01:46:39PM -0300, Wedson Almeida Filho wrote:
> On Thu, 9 Mar 2023 at 08:24, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> > > > > + // owns a reference. This is satisfied by the call to `get_device` above.
> > > > > + Self { ptr }
> > > > > + }
> > > > > +
> > > > > + /// Creates a new device instance from an existing [`RawDevice`] instance.
> > > > > + pub fn from_dev(dev: &dyn RawDevice) -> Self {
> > > >
> > > > I am a rust newbie, but I don't understand this "RawDevice" here at all.
> > >
> > > Different buses will have their own Rust "Device" type, for example,
> > > pci::Device, amba::Device, platform::Device that wrap their C
> > > counterparts pci_dev, amba_device, platform_device.
> > >
> > > "RawDevice" is a trait for functionality that is common to all
> > > devices. It exposes the "struct device" of each bus/subsystem so that
> > > functions that work on any "struct device", for example, `clk_get`,
> > > `pr_info`. will automatically work on all subsystems.
> >
> > Why is this being called "Raw" then? Why not just "Device" to follow
> > along with the naming scheme that the kernel already uses?
>
> Because it gives us access to underlying raw `struct device` pointer,
> in Rust raw pointers are those unsafe `*mut T` or `*const T`. I'm not
> married to the name though, we should probably look for a better one
> if this one is confusing.
>
> Just "Device" is already taken. It's a ref-counted `struct device` (it
> calls get_device/put_device in the right places automatically,
> guarantees no dandling pointers); it is meant to be used by code that
> needs to hold on to devices when they don't care about the bus. (It in
> fact implements `RawDevice`.)
I don't understand, why do you need both of these? Why can't one just
do? Why would you need one without the other? I would think that
"Device" and "RawDevice" here would be the same thing, that is a way to
refer to a "larger" underlying struct device memory chunk in a way that
can be passed around without knowing, or caring, what the "real" device
type is.
> How about `IsDevice`?
That sounds like a question, and would return a boolean, not a structure :)
> Then, for example, the platform bus would implement `IsDevice` for
> `plaform::Device`.
I don't really understand that, sorry.
thanks,
greg k-h
next prev parent reply other threads:[~2023-03-09 17:11 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-24 10:53 [PATCH 0/5] rust: Add io_pgtable and RTKit abstractions Asahi Lina
2023-02-24 10:53 ` [PATCH 1/5] rust: Add a Sealed trait Asahi Lina
2023-02-24 10:53 ` [PATCH 2/5] rust: device: Add a minimal RawDevice trait Asahi Lina
2023-02-24 11:23 ` Greg Kroah-Hartman
2023-02-24 13:15 ` Asahi Lina
2023-02-24 14:11 ` Greg Kroah-Hartman
2023-02-24 14:19 ` Greg Kroah-Hartman
2023-02-24 14:44 ` Asahi Lina
2023-02-24 15:25 ` Greg Kroah-Hartman
2023-02-24 15:45 ` Asahi Lina
2023-02-25 17:07 ` alyssa
2023-02-24 14:32 ` Robin Murphy
2023-02-24 14:48 ` Asahi Lina
2023-02-24 15:14 ` Robin Murphy
2023-02-24 16:23 ` Asahi Lina
2023-02-24 19:22 ` Miguel Ojeda
2023-03-05 6:52 ` Wedson Almeida Filho
2023-02-24 15:32 ` Greg Kroah-Hartman
2023-02-24 18:52 ` Robin Murphy
2023-02-25 7:00 ` Greg Kroah-Hartman
2023-02-24 14:43 ` Asahi Lina
2023-02-24 15:24 ` Greg Kroah-Hartman
2023-02-24 15:42 ` Asahi Lina
2023-02-24 10:53 ` [PATCH 3/5] rust: io_pgtable: Add io_pgtable abstraction Asahi Lina
2023-02-24 10:53 ` [PATCH 4/5] rust: soc: apple: rtkit: Add Apple RTKit abstraction Asahi Lina
2023-02-24 10:53 ` [PATCH 5/5] rust: device: Add a stub abstraction for devices Asahi Lina
2023-02-24 11:19 ` Greg Kroah-Hartman
2023-02-24 15:10 ` Asahi Lina
2023-02-24 15:34 ` Greg Kroah-Hartman
2023-02-24 15:51 ` Asahi Lina
2023-02-24 16:31 ` Greg Kroah-Hartman
2023-02-24 16:53 ` Asahi Lina
2023-03-05 6:39 ` Wedson Almeida Filho
2023-03-09 11:24 ` Greg Kroah-Hartman
2023-03-09 16:46 ` Wedson Almeida Filho
2023-03-09 17:11 ` Greg Kroah-Hartman [this message]
2023-03-09 19:06 ` Wedson Almeida Filho
2023-03-13 17:01 ` Gary Guo
2023-03-09 19:43 ` Miguel Ojeda
2023-03-13 17:52 ` Gary Guo
2023-03-13 18:05 ` Boqun Feng
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=ZAoTNlF+bHyyGs7x@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=alex.gaynor@gmail.com \
--cc=alyssa@rosenzweig.io \
--cc=arnd@arndb.de \
--cc=asahi@lists.linux.dev \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=joro@8bytes.org \
--cc=lina@asahilina.net \
--cc=linux-kernel@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=neal@gompa.dev \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=robin.murphy@arm.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=sven@svenpeter.dev \
--cc=wedsonaf@gmail.com \
--cc=will@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.