public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: [PATCH 00/21] driver core: bus: remove private "backpointer" from struct bus_type
Date: Wed,  8 Feb 2023 12:13:09 +0100	[thread overview]
Message-ID: <20230208111330.439504-1-gregkh@linuxfoundation.org> (raw)

In the quest to make all struct bus_type constant in the kernel,
allowing them to move into read-only memory, this patch series goes
through the steps in getting rid of the "private" pointer in struct
bus_type.  It does so primarily by relying on the already-present list
of subsystems in the driver core and looking up the struct bus_type from
that list when needed, or looking up the private structure from the bus
pointer, depending on what is needed.

Overall, more lines of code are added, but we now have the additional
safely that the internal subsystem private type is properly reference
counted.  We "got away" with not incrementing reference counts because
we relied on the caller of functions to have a valid reference when
calling into the core.  That's not really the proper way to handle
reference counts, so as part of the conversion, reference counts are now
correctly handled.

There are still some remaining steps to be able to have bus_type be
constant everywhere in the kernel, but this series is a great first step
and is the "hard part" of the work.  The rest involves changing the
callback sysfs file functions and handling the dev_root pointer
properly.  Those changes will be forthcoming after these as they involve
lots more minor driver changes all over the kernel.

This has been build-tested by the 0-day bot for a while, and is being
used by me right now to send this series out, so it "works for me!"

This series is based against my current driver-core-next branch that is
in linux-next.

Greg Kroah-Hartman (21):
  driver core: add local subsys_get and subsys_put functions
  driver core: bus: implement bus_get/put() without the private pointer
  driver core: bus: constantify the bus_find_* functions
  driver core: bus: convert bus_create/remove_file to be constant
  driver core: bus: sysfs function cleanups
  driver core: bus: bus_add/probe/remove_device() cleanups
  driver core: bus: bus_register/unregister() cleanups
  driver core: bus: subsys_interface_register/unregister() cleanups
  driver core: bus: bus_get_kset() cleanup
  driver core: bus: bus_register/unregister_notifier() cleanups
  driver core: bus: bus_add/remove_driver() cleanups
  driver core: bus: bus iterator cleanups
  driver core: bus: clean up bus_sort_breadthfirst()
  driver core: move driver_find() to bus.c
  driver core: bus: clean up driver_find()
  driver core: create bus_is_registered()
  driver core: remove private pointer from struct bus_type
  driver core: bus: constify bus_register/unregister_notifier()
  driver core: bus: constify bus_get_kset()
  driver core: bus: constify some internal functions
  driver core: bus: constify bus_unregister()

 drivers/base/base.h        |  14 ++
 drivers/base/bus.c         | 491 ++++++++++++++++++++++++++-----------
 drivers/base/driver.c      |  29 +--
 include/linux/device/bus.h |  37 ++-
 4 files changed, 375 insertions(+), 196 deletions(-)

-- 
2.39.1


             reply	other threads:[~2023-02-08 11:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08 11:13 Greg Kroah-Hartman [this message]
2023-02-08 11:13 ` [PATCH 01/21] driver core: add local subsys_get and subsys_put functions Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 02/21] driver core: bus: implement bus_get/put() without the private pointer Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 03/21] driver core: bus: constantify the bus_find_* functions Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 04/21] driver core: bus: convert bus_create/remove_file to be constant Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 05/21] driver core: bus: sysfs function cleanups Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 06/21] driver core: bus: bus_add/probe/remove_device() cleanups Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 07/21] driver core: bus: bus_register/unregister() cleanups Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 08/21] driver core: bus: subsys_interface_register/unregister() cleanups Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 09/21] driver core: bus: bus_get_kset() cleanup Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 10/21] driver core: bus: bus_register/unregister_notifier() cleanups Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 11/21] driver core: bus: bus_add/remove_driver() cleanups Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 12/21] driver core: bus: bus iterator cleanups Greg Kroah-Hartman
2023-02-21 12:54   ` Geert Uytterhoeven
2023-02-08 11:13 ` [PATCH 13/21] driver core: bus: clean up bus_sort_breadthfirst() Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 14/21] driver core: move driver_find() to bus.c Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 15/21] driver core: bus: clean up driver_find() Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 16/21] driver core: create bus_is_registered() Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 17/21] driver core: remove private pointer from struct bus_type Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 18/21] driver core: bus: constify bus_register/unregister_notifier() Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 19/21] driver core: bus: constify bus_get_kset() Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 20/21] driver core: bus: constify some internal functions Greg Kroah-Hartman
2023-02-08 11:13 ` [PATCH 21/21] driver core: bus: constify bus_unregister() Greg Kroah-Hartman

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=20230208111330.439504-1-gregkh@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox