From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [PATCH 1/2] iommu: Always define struct iommu_ops
Date: Fri, 1 Aug 2014 14:45:12 +0200 [thread overview]
Message-ID: <1406897113-20099-1-git-send-email-thierry.reding@gmail.com> (raw)
From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
With this structure always defined, drivers can be always compiled,
irrespective of whether or not IOMMU_API is enabled. This helps to
increase compile coverage without having to build with two separate
configurations.
Unused code can still be discarded by the compiler if the IS_ENABLED()
macro is properly used in an if condition, such as shown below:
static const struct iommu_ops iommu_ops = {
...
};
static int iommu_setup(...)
{
...
bus_set_iommu(..., &iommu_ops);
...
}
...
static int iommu_probe(...)
{
...
if (IS_ENABLED(CONFIG_IOMMU_API)) {
err = iommu_setup(...);
...
}
...
}
That pattern will allow the compiler to notice that setup_iommu() is
never called if IOMMU_API is not selected, which will allow it to
discard its code and all data referenced from it.
Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
include/linux/iommu.h | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 20f9a527922a..0b5222c7ff97 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -83,8 +83,6 @@ enum iommu_attr {
DOMAIN_ATTR_MAX,
};
-#ifdef CONFIG_IOMMU_API
-
/**
* struct iommu_ops - iommu ops and capabilities
* @domain_init: init iommu domain
@@ -140,6 +138,8 @@ struct iommu_ops {
#define IOMMU_GROUP_NOTIFY_UNBIND_DRIVER 5 /* Pre Driver unbind */
#define IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER 6 /* Post Driver unbind */
+#ifdef CONFIG_IOMMU_API
+
extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops);
extern bool iommu_present(struct bus_type *bus);
extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
@@ -242,9 +242,6 @@ static inline int report_iommu_fault(struct iommu_domain *domain,
#else /* CONFIG_IOMMU_API */
-struct iommu_ops {};
-struct iommu_group {};
-
static inline bool iommu_present(struct bus_type *bus)
{
return false;
--
2.0.3
next reply other threads:[~2014-08-01 12:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-01 12:45 Thierry Reding [this message]
[not found] ` <1406897113-20099-1-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-08-01 12:45 ` [PATCH 2/2] iommu: Implement a dummy bus_set_iommu() Thierry Reding
[not found] ` <1406897113-20099-2-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-08-18 16:57 ` Joerg Roedel
2014-10-15 9:10 ` Thierry Reding
2014-10-22 14:29 ` Joerg Roedel
[not found] ` <20141022142922.GH10074-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2014-10-23 8:09 ` 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=1406897113-20099-1-git-send-email-thierry.reding@gmail.com \
--to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).