public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Danilo Krummrich <dakr@kernel.org>
Cc: "Lyude Paul" <lyude@redhat.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Maíra Canal" <mairacanal@riseup.net>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
	"Zijun Hu" <quic_zijuhu@quicinc.com>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Robin Murphy" <robin.murphy@arm.com>,
	"Alexander Lobakin" <aleksander.lobakin@intel.com>,
	"Lukas Wunner" <lukas@wunner.de>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Simona Vetter" <simona.vetter@ffwll.ch>
Subject: Re: [RFC] driver core: add a virtual bus for use when a simple device/bus is needed
Date: Tue, 4 Feb 2025 07:05:29 +0100	[thread overview]
Message-ID: <2025020427-urgency-preplan-baaa@gregkh> (raw)
In-Reply-To: <Z6ExZOzIgAHlX_MP@pollux>

On Mon, Feb 03, 2025 at 10:13:08PM +0100, Danilo Krummrich wrote:
> On Mon, Feb 03, 2025 at 12:25:23PM +0100, Greg Kroah-Hartman wrote:
> > On Mon, Feb 03, 2025 at 12:01:04PM +0100, Danilo Krummrich wrote:
> > > On Mon, Feb 03, 2025 at 10:39:58AM +0100, Greg Kroah-Hartman wrote:
> > > > From 4c7aa0f9f0f7d25c962b70a11bad48d418b9490a Mon Sep 17 00:00:00 2001
> > > > From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > > Date: Fri, 31 Jan 2025 15:01:32 +0100
> > > > Subject: [PATCH] driver core: add a virtual bus for use when a simple
> > > >  device/bus is needed
> > > > 
> > > > Many drivers abuse the platform driver/bus system as it provides a
> > > > simple way to create and bind a device to a driver-specific set of
> > > > probe/release functions.  Instead of doing that, and wasting all of the
> > > > memory associated with a platform device, here is a "virtual" bus that
> > > > can be used instead.
> > > > 
> > > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > 
> > > I think it turned out pretty nice combining the driver and device creation for
> > > convenience.
> > > 
> > > But I think we may still need the option to create multiple devices for the same
> > > driver, as mentioned by Sima.
> > 
> > That will work just fine, the api will allow that, just give each device
> > a unique name and you are good to go.
> > 
> > > @Sima: I wonder if the number of devices could just be an argument?
> > 
> > Then the virtual bus logic will have to create some sort of number/name
> > system and I don't want to do that.  It's a "first caller gets the name"
> > type thing here.  You can easily in a driver do this:
> > 
> > 	my_dev_1 = virtual_device_create(&my_virt_ops, "my_dev_1");
> > 	my_dev_2 = virtual_device_create(&my_virt_ops, "my_dev_2");
> > 	my_dev_3 = virtual_device_create(&my_virt_ops, "my_dev_3");
> > 	...
> > 
> > You share the same callbacks, and that's all you really care about.  If
> > you want to hang sysfs files off of these things, I can make them take a
> > device_groups pointer as well, but let's keep it simple first.
> 
> Sure, that works perfectly. Just thought, we might not want to also create a new
> struct driver for each device.

Oooh, good catch, I can get rid of that now and just use a single
internal driver structure.  The "driver vs. device" shouldn't really
matter anymore as that's not the goal here.

I'll keep my v1 version of the virtual bus code here and rename it to
something else (simple?) as we do want tht for other platform devices
that need/want to have a real driver, but for this api for now, that's
not needed.

thanks,

greg k-h

  reply	other threads:[~2025-02-04  6:05 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-22 23:49 [PATCH 0/2] rust/kernel: Add bindings for manually creating devices Lyude Paul
2025-01-22 23:49 ` [PATCH 1/2] rust/kernel: Add platform::Device::from_raw() Lyude Paul
2025-01-28 14:35   ` Alice Ryhl
2025-01-22 23:49 ` [PATCH 2/2] rust/kernel: Add platform::ModuleDevice Lyude Paul
2025-01-23  6:23   ` Greg Kroah-Hartman
2025-01-23 10:21     ` Danilo Krummrich
2025-01-23 14:17       ` Greg Kroah-Hartman
2025-01-24 10:52         ` Danilo Krummrich
2025-01-30 21:28           ` [PATCH] WIP: drivers/base: Add virtual_device_create() Lyude Paul
2025-01-30 21:58             ` Lyude Paul
2025-02-01  8:32               ` Greg Kroah-Hartman
2025-01-31  3:34             ` kernel test robot
2025-01-31  8:00             ` Greg Kroah-Hartman
2025-01-31 16:40               ` Greg Kroah-Hartman
2025-01-31 18:43                 ` Danilo Krummrich
2025-02-01  8:00                   ` Greg Kroah-Hartman
2025-02-03  9:39                     ` [RFC] driver core: add a virtual bus for use when a simple device/bus is needed Greg Kroah-Hartman
2025-02-03 10:02                       ` Greg Kroah-Hartman
2025-02-03 11:01                       ` Danilo Krummrich
2025-02-03 11:25                         ` Greg Kroah-Hartman
2025-02-03 14:33                           ` Greg Kroah-Hartman
2025-02-03 15:32                             ` Simona Vetter
2025-02-03 15:38                               ` Greg Kroah-Hartman
2025-02-03 22:45                             ` Lyude Paul
2025-02-03 21:13                           ` Danilo Krummrich
2025-02-04  6:05                             ` Greg Kroah-Hartman [this message]
2025-02-03  9:45                     ` [PATCH] WIP: drivers/base: Add virtual_device_create() Simona Vetter
2025-02-03  9:51                       ` Greg Kroah-Hartman
2025-01-31 16:42               ` Simona Vetter
2025-01-31 10:43             ` Andy Shevchenko
2025-01-24  0:33     ` [PATCH 2/2] rust/kernel: Add platform::ModuleDevice Lyude Paul
2025-01-24 11:02       ` Danilo Krummrich
2025-01-31 16:41         ` Simona Vetter
2025-01-24 21:19       ` Lyude Paul

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=2025020427-urgency-preplan-baaa@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=dakr@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=lyude@redhat.com \
    --cc=mairacanal@riseup.net \
    --cc=quic_zijuhu@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona.vetter@ffwll.ch \
    /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