From: Joerg Roedel <joro@8bytes.org>
To: iommu@lists.linux-foundation.org
Cc: Robin Murphy <robin.murphy@arm.com>,
linux-kernel@vger.kernel.org, Joerg Roedel <jroedel@suse.de>
Subject: [PATCH 1/9] iommu: Introduce wrappers around dev->iommu_fwspec
Date: Tue, 4 Dec 2018 17:29:54 +0100 [thread overview]
Message-ID: <20181204163002.15800-2-joro@8bytes.org> (raw)
In-Reply-To: <20181204163002.15800-1-joro@8bytes.org>
From: Joerg Roedel <jroedel@suse.de>
These wrappers will be used to easily change the location of
the field later when all users are converted.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
drivers/iommu/iommu.c | 14 +++++++-------
include/linux/iommu.h | 11 +++++++++++
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index edbdf5d6962c..4cfd407b972c 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1976,7 +1976,7 @@ const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode)
int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode,
const struct iommu_ops *ops)
{
- struct iommu_fwspec *fwspec = dev->iommu_fwspec;
+ struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
if (fwspec)
return ops == fwspec->ops ? 0 : -EINVAL;
@@ -1988,26 +1988,26 @@ int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode,
of_node_get(to_of_node(iommu_fwnode));
fwspec->iommu_fwnode = iommu_fwnode;
fwspec->ops = ops;
- dev->iommu_fwspec = fwspec;
+ dev_iommu_fwspec_set(dev, fwspec);
return 0;
}
EXPORT_SYMBOL_GPL(iommu_fwspec_init);
void iommu_fwspec_free(struct device *dev)
{
- struct iommu_fwspec *fwspec = dev->iommu_fwspec;
+ struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
if (fwspec) {
fwnode_handle_put(fwspec->iommu_fwnode);
kfree(fwspec);
- dev->iommu_fwspec = NULL;
+ dev_iommu_fwspec_set(dev, NULL);
}
}
EXPORT_SYMBOL_GPL(iommu_fwspec_free);
int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids)
{
- struct iommu_fwspec *fwspec = dev->iommu_fwspec;
+ struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
size_t size;
int i;
@@ -2016,11 +2016,11 @@ int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids)
size = offsetof(struct iommu_fwspec, ids[fwspec->num_ids + num_ids]);
if (size > sizeof(*fwspec)) {
- fwspec = krealloc(dev->iommu_fwspec, size, GFP_KERNEL);
+ fwspec = krealloc(fwspec, size, GFP_KERNEL);
if (!fwspec)
return -ENOMEM;
- dev->iommu_fwspec = fwspec;
+ dev_iommu_fwspec_set(dev, fwspec);
}
for (i = 0; i < num_ids; i++)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index a1d28f42cb77..f93fdcf7d130 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -398,6 +398,17 @@ void iommu_fwspec_free(struct device *dev);
int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids);
const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode);
+static inline struct iommu_fwspec *dev_iommu_fwspec_get(struct device *dev)
+{
+ return dev->iommu_fwspec;
+}
+
+static inline void dev_iommu_fwspec_set(struct device *dev,
+ struct iommu_fwspec *fwspec)
+{
+ dev->iommu_fwspec = fwspec;
+}
+
#else /* CONFIG_IOMMU_API */
struct iommu_ops {};
--
2.17.1
next prev parent reply other threads:[~2018-12-04 16:29 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-04 16:29 [PATCH 0/9] Access dev->iommu_fwspec through functions Joerg Roedel
2018-12-04 16:29 ` Joerg Roedel
2018-12-04 16:29 ` Joerg Roedel [this message]
[not found] ` <20181204163002.15800-1-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2018-12-04 16:29 ` [PATCH 2/9] ACPI/IORT: Use helper functions to access dev->iommu_fwspec Joerg Roedel
2018-12-04 16:29 ` Joerg Roedel
2018-12-05 17:50 ` Robin Murphy
[not found] ` <ecfaa990-9257-0592-ee4d-ca3f8537783d-5wv7dgnIgG8@public.gmane.org>
2018-12-06 13:53 ` Joerg Roedel
2018-12-06 13:53 ` Joerg Roedel
2018-12-04 16:29 ` [PATCH 4/9] iommu/dma: " Joerg Roedel
2018-12-04 16:29 ` Joerg Roedel
2018-12-04 16:29 ` [PATCH 3/9] iommu/arm-smmu: " Joerg Roedel
[not found] ` <20181204163002.15800-4-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2018-12-06 13:11 ` Will Deacon
2018-12-06 13:11 ` Will Deacon
2018-12-04 16:29 ` [PATCH 5/9] iommu/ipmmu-vmsa: " Joerg Roedel
2018-12-04 16:29 ` [PATCH 6/9] iommu/mediatek: " Joerg Roedel
2018-12-04 16:30 ` [PATCH 7/9] iommu/of: " Joerg Roedel
2018-12-05 17:41 ` Robin Murphy
2018-12-06 14:16 ` Joerg Roedel
2018-12-04 16:30 ` [PATCH 8/9] iommu/qcom: " Joerg Roedel
2018-12-04 16:30 ` [PATCH 9/9] iommu/tegra: " Joerg Roedel
-- strict thread matches above, loose matches on Subject: below --
2018-12-11 12:19 [PATCH 0/9 v2] Access dev->iommu_fwspec through functions Joerg Roedel
2018-12-11 12:19 ` [PATCH 1/9] iommu: Introduce wrappers around dev->iommu_fwspec Joerg Roedel
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=20181204163002.15800-2-joro@8bytes.org \
--to=joro@8bytes.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jroedel@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.