From: Heiko Stuebner <heiko@sntech.de>
To: gregkh@linuxfoundation.org, heiko@sntech.de
Cc: rafael@kernel.org, dakr@kernel.org, hjc@rock-chips.com,
andy.yan@rock-chips.com, maarten.lankhorst@linux.intel.com,
mripard@kernel.org, tzimmermann@suse.de,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, quentin.schulz@cherry.de
Subject: [PATCH 1/2] drivers: base: component: add function to query the bound status
Date: Fri, 21 Feb 2025 00:41:40 +0100 [thread overview]
Message-ID: <20250220234141.2788785-2-heiko@sntech.de> (raw)
In-Reply-To: <20250220234141.2788785-1-heiko@sntech.de>
The component helpers already expose the bound status in debugfs, but at
times it might be necessary to also check that state in the kernel and
act differently depending on the result.
For example the shutdown handler of a drm-driver might need to stop
a whole output pipeline if the drm device is up and running, but may
run into problems if that drm-device has never been set up before,
for example because the binding deferred.
So add a little helper that returns the bound status for a componet
device.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
drivers/base/component.c | 14 ++++++++++++++
include/linux/component.h | 4 +++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/base/component.c b/drivers/base/component.c
index 741497324d78..d63e01f4851d 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -569,6 +569,20 @@ void component_master_del(struct device *parent,
}
EXPORT_SYMBOL_GPL(component_master_del);
+bool component_master_is_bound(struct device *parent,
+ const struct component_master_ops *ops)
+{
+ struct aggregate_device *adev;
+
+ guard(mutex)(&component_mutex);
+ adev = __aggregate_find(parent, ops);
+ if (!adev)
+ return 0;
+
+ return adev->bound;
+}
+EXPORT_SYMBOL_GPL(component_master_is_bound);
+
static void component_unbind(struct component *component,
struct aggregate_device *adev, void *data)
{
diff --git a/include/linux/component.h b/include/linux/component.h
index df4aa75c9e7c..9d6c66401280 100644
--- a/include/linux/component.h
+++ b/include/linux/component.h
@@ -3,7 +3,7 @@
#define COMPONENT_H
#include <linux/stddef.h>
-
+#include <linux/types.h>
struct device;
@@ -90,6 +90,8 @@ int component_compare_dev_name(struct device *dev, void *data);
void component_master_del(struct device *,
const struct component_master_ops *);
+bool component_master_is_bound(struct device *parent,
+ const struct component_master_ops *ops);
struct component_match;
--
2.47.2
next prev parent reply other threads:[~2025-02-20 23:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 23:41 [PATCH 0/2] Fix the shutdown callback of a drm component device Heiko Stuebner
2025-02-20 23:41 ` Heiko Stuebner [this message]
2025-02-21 6:14 ` [PATCH 1/2] drivers: base: component: add function to query the bound status Greg KH
2025-02-27 8:44 ` Heiko Stübner
2025-02-27 11:20 ` Greg KH
2025-02-20 23:41 ` [PATCH 2/2] drm/rockchip: Fix shutdown when no drm-device is set up Heiko Stuebner
2025-02-26 20:28 ` Nicolas Frattaroli
2025-02-27 14:02 ` [PATCH 0/2] Fix the shutdown callback of a drm component device Heiko Stuebner
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=20250220234141.2788785-2-heiko@sntech.de \
--to=heiko@sntech.de \
--cc=andy.yan@rock-chips.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=hjc@rock-chips.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=quentin.schulz@cherry.de \
--cc=rafael@kernel.org \
--cc=tzimmermann@suse.de \
/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