diff mbox

[1/2] iommu/arm-smmu: Replace list walk with platform driver data

Message ID 1393601830-4677-2-git-send-email-laurent.pinchart+renesas@ideasonboard.com (mailing list archive)
State New, archived
Headers show

Commit Message

Laurent Pinchart Feb. 28, 2014, 3:37 p.m. UTC
Instead of walking the list of registered SMMU devices at remove time to
locate the device being removed, set platform driver data at probe time
to point to the SMMU and retrieve the pointer at remove time.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/iommu/arm-smmu.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Comments

Will Deacon Feb. 28, 2014, 4:38 p.m. UTC | #1
Hi Laurent,

On Fri, Feb 28, 2014 at 03:37:09PM +0000, Laurent Pinchart wrote:
> Instead of walking the list of registered SMMU devices at remove time to
> locate the device being removed, set platform driver data at probe time
> to point to the SMMU and retrieve the pointer at remove time.

What does this gain us other than a slight code shrinkage? If we could get
rid of the arm_smmu_devices list, then I'd be more excited by this change!

Will
Laurent Pinchart March 2, 2014, 5:59 p.m. UTC | #2
Hi Will,

On Friday 28 February 2014 16:38:37 Will Deacon wrote:
> Hi Laurent,
> 
> On Fri, Feb 28, 2014 at 03:37:09PM +0000, Laurent Pinchart wrote:
> > Instead of walking the list of registered SMMU devices at remove time to
> > locate the device being removed, set platform driver data at probe time
> > to point to the SMMU and retrieve the pointer at remove time.
> 
> What does this gain us other than a slight code shrinkage?

Just a slight code shrinkage. That's better than nothing, isn't it ? :-)

> If we could get rid of the arm_smmu_devices list, then I'd be more excited
> by this change!

Associating devices with IOMMUs is something that should be performed by the 
IOMMU core. I might give this a try, but I'll be busy with other tasks for the 
next couple of weeks.
diff mbox

Patch

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 1d9ab39..c33a310 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1912,6 +1912,8 @@  static int arm_smmu_device_dt_probe(struct platform_device *pdev)
 	list_add(&smmu->list, &arm_smmu_devices);
 	spin_unlock(&arm_smmu_devices_lock);
 
+	platform_set_drvdata(pdev, smmu);
+
 	arm_smmu_device_reset(smmu);
 	return 0;
 
@@ -1937,22 +1939,13 @@  static int arm_smmu_device_remove(struct platform_device *pdev)
 {
 	int i;
 	struct device *dev = &pdev->dev;
-	struct arm_smmu_device *curr, *smmu = NULL;
+	struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
 	struct rb_node *node;
 
 	spin_lock(&arm_smmu_devices_lock);
-	list_for_each_entry(curr, &arm_smmu_devices, list) {
-		if (curr->dev == dev) {
-			smmu = curr;
-			list_del(&smmu->list);
-			break;
-		}
-	}
+	list_del(&smmu->list);
 	spin_unlock(&arm_smmu_devices_lock);
 
-	if (!smmu)
-		return -ENODEV;
-
 	if (smmu->parent_of_node)
 		of_node_put(smmu->parent_of_node);