From: Thierry Reding <thierry.reding@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: linux-tegra@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org,
Russell King <rmk+kernel@arm.linux.org.uk>
Subject: [RFC 1/5] drivers/base: Allow multiple masters per device
Date: Tue, 22 Apr 2014 17:09:29 +0200 [thread overview]
Message-ID: <1398179373-29966-2-git-send-email-thierry.reding@gmail.com> (raw)
In-Reply-To: <1398179373-29966-1-git-send-email-thierry.reding@gmail.com>
From: Thierry Reding <treding@nvidia.com>
Currently the component/master framework allows only a single master to
be registered against a struct device. A master is uniquely identified
by the device and the master operations table, but the current API does
not pass enough information along to allow a master to be uniquely
identified when calling component_unbind_all().
To make it possible to register multiple masters on one device, instead
of passing around the device associated with a master, pass around the
master directly. That way it can always be uniquely identified.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/base/component.c | 18 +++++++-----------
include/linux/component.h | 17 ++++++++---------
2 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/drivers/base/component.c b/drivers/base/component.c
index c4778995cd72..14fe81bf5ed2 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -120,7 +120,7 @@ static int try_to_bring_up_master(struct master *master,
* Search the list of components, looking for components that
* belong to this master, and attach them to the master.
*/
- if (master->ops->add_components(master->dev, master)) {
+ if (master->ops->add_components(master, master->dev)) {
/* Failed to find all components */
master_remove_components(master);
ret = 0;
@@ -139,7 +139,7 @@ static int try_to_bring_up_master(struct master *master,
}
/* Found all components */
- ret = master->ops->bind(master->dev);
+ ret = master->ops->bind(master, master->dev);
if (ret < 0) {
devres_release_group(master->dev, NULL);
dev_info(master->dev, "master bind failed: %d\n", ret);
@@ -172,7 +172,7 @@ static int try_to_bring_up_masters(struct component *component)
static void take_down_master(struct master *master)
{
if (master->bound) {
- master->ops->unbind(master->dev);
+ master->ops->unbind(master, master->dev);
devres_release_group(master->dev, NULL);
master->bound = false;
}
@@ -233,21 +233,19 @@ static void component_unbind(struct component *component,
{
WARN_ON(!component->bound);
- component->ops->unbind(component->dev, master->dev, data);
+ component->ops->unbind(component->dev, master, data);
component->bound = false;
/* Release all resources claimed in the binding of this component */
devres_release_group(component->dev, component);
}
-void component_unbind_all(struct device *master_dev, void *data)
+void component_unbind_all(struct master *master, void *data)
{
- struct master *master;
struct component *c;
WARN_ON(!mutex_is_locked(&component_mutex));
- master = __master_find(master_dev, NULL);
if (!master)
return;
@@ -282,7 +280,7 @@ static int component_bind(struct component *component, struct master *master,
dev_dbg(master->dev, "binding %s (ops %ps)\n",
dev_name(component->dev), component->ops);
- ret = component->ops->bind(component->dev, master->dev, data);
+ ret = component->ops->bind(component->dev, master, data);
if (!ret) {
component->bound = true;
@@ -308,15 +306,13 @@ static int component_bind(struct component *component, struct master *master,
return ret;
}
-int component_bind_all(struct device *master_dev, void *data)
+int component_bind_all(struct master *master, void *data)
{
- struct master *master;
struct component *c;
int ret = 0;
WARN_ON(!mutex_is_locked(&component_mutex));
- master = __master_find(master_dev, NULL);
if (!master)
return -EINVAL;
diff --git a/include/linux/component.h b/include/linux/component.h
index 68870182ca1e..89fe8bb35053 100644
--- a/include/linux/component.h
+++ b/include/linux/component.h
@@ -2,24 +2,23 @@
#define COMPONENT_H
struct device;
+struct master;
struct component_ops {
- int (*bind)(struct device *, struct device *, void *);
- void (*unbind)(struct device *, struct device *, void *);
+ int (*bind)(struct device *, struct master *, void *);
+ void (*unbind)(struct device *, struct master *, void *);
};
int component_add(struct device *, const struct component_ops *);
void component_del(struct device *, const struct component_ops *);
-int component_bind_all(struct device *, void *);
-void component_unbind_all(struct device *, void *);
-
-struct master;
+int component_bind_all(struct master *, void *);
+void component_unbind_all(struct master *, void *);
struct component_master_ops {
- int (*add_components)(struct device *, struct master *);
- int (*bind)(struct device *);
- void (*unbind)(struct device *);
+ int (*add_components)(struct master *, struct device *);
+ int (*bind)(struct master *, struct device *);
+ void (*unbind)(struct master *, struct device *);
};
int component_master_add(struct device *, const struct component_master_ops *);
--
1.9.2
next prev parent reply other threads:[~2014-04-22 15:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-22 15:09 [RFC 0/5] drm/tegra: Convert to master/component framework Thierry Reding
2014-04-22 15:09 ` Thierry Reding [this message]
2014-04-22 15:09 ` [RFC 2/5] drivers/base: Allow driver-data to be attached to a master Thierry Reding
2014-04-22 15:09 ` [RFC 3/5] drivers/base: Add interface framework Thierry Reding
2014-04-22 15:09 ` [RFC 4/5] drm: Introduce drm_set_unique() Thierry Reding
[not found] ` <1398179373-29966-5-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-04-22 15:48 ` Daniel Vetter
2014-04-23 7:17 ` Thierry Reding
2014-04-23 8:40 ` Daniel Vetter
2014-04-23 10:48 ` David Herrmann
2014-04-23 13:37 ` Thierry Reding
2014-04-22 15:09 ` [RFC 5/5] drm/tegra: Convert to master/component framework Thierry Reding
[not found] ` <1398179373-29966-1-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-04-30 22:01 ` [RFC 0/5] " Thierry Reding
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=1398179373-29966-2-git-send-email-thierry.reding@gmail.com \
--to=thierry.reding@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=rmk+kernel@arm.linux.org.uk \
/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