Skip to content

Commit 8097e53

Browse files
committed
ACPI/IORT: Use helper functions to access dev->iommu_fwspec
Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct. Acked-by: Hanjun Guo <hanjun.guo@linaro.org> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent b4ef725 commit 8097e53

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/acpi/arm64/iort.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ static inline bool iort_iommu_driver_enabled(u8 type)
779779
static struct acpi_iort_node *iort_get_msi_resv_iommu(struct device *dev)
780780
{
781781
struct acpi_iort_node *iommu;
782-
struct iommu_fwspec *fwspec = dev->iommu_fwspec;
782+
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
783783

784784
iommu = iort_get_iort_node(fwspec->iommu_fwnode);
785785

@@ -794,9 +794,10 @@ static struct acpi_iort_node *iort_get_msi_resv_iommu(struct device *dev)
794794
return NULL;
795795
}
796796

797-
static inline const struct iommu_ops *iort_fwspec_iommu_ops(
798-
struct iommu_fwspec *fwspec)
797+
static inline const struct iommu_ops *iort_fwspec_iommu_ops(struct device *dev)
799798
{
799+
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
800+
800801
return (fwspec && fwspec->ops) ? fwspec->ops : NULL;
801802
}
802803

@@ -824,6 +825,7 @@ static inline int iort_add_device_replay(const struct iommu_ops *ops,
824825
*/
825826
int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head)
826827
{
828+
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
827829
struct acpi_iort_its_group *its;
828830
struct acpi_iort_node *iommu_node, *its_node = NULL;
829831
int i, resv = 0;
@@ -841,9 +843,9 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head)
841843
* a given PCI or named component may map IDs to.
842844
*/
843845

844-
for (i = 0; i < dev->iommu_fwspec->num_ids; i++) {
846+
for (i = 0; i < fwspec->num_ids; i++) {
845847
its_node = iort_node_map_id(iommu_node,
846-
dev->iommu_fwspec->ids[i],
848+
fwspec->ids[i],
847849
NULL, IORT_MSI_TYPE);
848850
if (its_node)
849851
break;
@@ -874,8 +876,7 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head)
874876
return (resv == its->its_count) ? resv : -ENODEV;
875877
}
876878
#else
877-
static inline const struct iommu_ops *iort_fwspec_iommu_ops(
878-
struct iommu_fwspec *fwspec)
879+
static inline const struct iommu_ops *iort_fwspec_iommu_ops(struct device *dev);
879880
{ return NULL; }
880881
static inline int iort_add_device_replay(const struct iommu_ops *ops,
881882
struct device *dev)
@@ -1045,7 +1046,7 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev)
10451046
* If we already translated the fwspec there
10461047
* is nothing left to do, return the iommu_ops.
10471048
*/
1048-
ops = iort_fwspec_iommu_ops(dev->iommu_fwspec);
1049+
ops = iort_fwspec_iommu_ops(dev);
10491050
if (ops)
10501051
return ops;
10511052

@@ -1084,7 +1085,7 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev)
10841085
* add_device callback for dev, replay it to get things in order.
10851086
*/
10861087
if (!err) {
1087-
ops = iort_fwspec_iommu_ops(dev->iommu_fwspec);
1088+
ops = iort_fwspec_iommu_ops(dev);
10881089
err = iort_add_device_replay(ops, dev);
10891090
}
10901091

0 commit comments

Comments
 (0)