@@ -308,25 +308,39 @@ static int shmobile_iommu_attach_all_devices(void)
ret = PTR_ERR(iommu_mapping);
goto err;
}
- for (dev = ipmmu_devices; dev; dev = dev->archdata.iommu) {
+ for (dev = ipmmu_devices; dev; ) {
+ struct shmobile_iommu_arch_data *data = dev->archdata.iommu;
+
if (arm_iommu_attach_device(dev, iommu_mapping))
pr_err("arm_iommu_attach_device failed\n");
+
+ dev = data->next;
}
err:
spin_unlock(&lock_add);
return 0;
}
-void ipmmu_add_device(struct device *dev)
+int ipmmu_add_device(struct device *dev)
{
+ struct shmobile_iommu_arch_data *data;
+
+ data = kzalloc(sizeof(*data), GFP_KERNEL);
+ if (data == NULL)
+ return -ENOMEM;
+
+ dev->archdata.iommu = data;
+
spin_lock(&lock_add);
- dev->archdata.iommu = ipmmu_devices;
+ data->next = ipmmu_devices;
ipmmu_devices = dev;
if (!IS_ERR_OR_NULL(iommu_mapping)) {
if (arm_iommu_attach_device(dev, iommu_mapping))
pr_err("arm_iommu_attach_device failed\n");
}
spin_unlock(&lock_add);
+
+ return 0;
}
int ipmmu_iommu_init(struct shmobile_ipmmu *ipmmu)
@@ -1,10 +1,16 @@
#ifndef __SH_IOMMU_H__
#define __SH_IOMMU_H__
+struct device;
+
+struct shmobile_iommu_arch_data {
+ struct device *next;
+};
+
#ifdef CONFIG_SHMOBILE_IPMMU_TLB
-void ipmmu_add_device(struct device *dev);
+int ipmmu_add_device(struct device *dev);
#else
-static inline void ipmmu_add_device(struct device *dev)
+static inline int ipmmu_add_device(struct device *dev)
{
}
#endif
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> --- drivers/iommu/shmobile-iommu.c | 20 +++++++++++++++++--- include/linux/sh_iommu.h | 10 ++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-)