Commit 4f2a4aec authored by Johan Hovold's avatar Johan Hovold Committed by Joerg Roedel
Browse files

iommu/mediatek: simplify dt parsing error handling



As previously documented by commit 26593928 ("iommu/mediatek: Add
error path for loop of mm_dts_parse"), the id mapping may not be linear
so the whole larb array needs to be iterated on devicetree parsing
errors.

Simplify the loop by iterating from index zero while dropping the
redundant NULL check for consistency with later cleanups.

Also add back the comment which was removed by commit 462e768b
("iommu/mediatek: Fix forever loop in error handling") to prevent anyone
from trying to optimise the loop by iterating backwards from 'i'.

Cc: Yong Wu <yong.wu@mediatek.com>
Acked-by: default avatarRobin Murphy <robin.murphy@arm.com>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Reviewed-by: default avatarYong Wu <yong.wu@mediatek.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: default avatarJoerg Roedel <joerg.roedel@amd.com>
parent de83d461
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -1239,11 +1239,10 @@ static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **m
	return 0;

err_larbdev_put:
	for (i = MTK_LARB_NR_MAX - 1; i >= 0; i--) {
		if (!data->larb_imu[i].dev)
			continue;
	/* id mapping may not be linear, loop the whole array */
	for (i = 0; i < MTK_LARB_NR_MAX; i++)
		put_device(data->larb_imu[i].dev);
	}

	return ret;
}