@@ -1545,18 +1545,28 @@ static int arm_smmu_domain_set_attr(struct iommu_domain *domain,
return ret;
}
-static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args)
+static u32 arm_smmu_of_parse(struct device_node *np, const u32 *args,
+ unsigned int count)
{
- u32 mask, fwid = 0;
+ u32 fwid = 0, mask;
- if (args->args_count > 0)
- fwid |= FIELD_PREP(SMR_ID, args->args[0]);
+ if (count > 0)
+ fwid |= FIELD_PREP(SMR_ID, args[0]);
- if (args->args_count > 1)
- fwid |= FIELD_PREP(SMR_MASK, args->args[1]);
- else if (!of_property_read_u32(args->np, "stream-match-mask", &mask))
+ if (count > 1)
+ fwid |= FIELD_PREP(SMR_MASK, args[1]);
+ else if (!of_property_read_u32(np, "stream-match-mask", &mask))
fwid |= FIELD_PREP(SMR_MASK, mask);
+ return fwid;
+}
+
+static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args)
+{
+ u32 fwid;
+
+ fwid = arm_smmu_of_parse(args->np, args->args, args->args_count);
+
return iommu_fwspec_add_ids(dev, &fwid, 1);
}