From: Yoshihiro Shimoda Date: Wed, 28 Nov 2018 09:23:36 +0000 (+0000) Subject: iommu/ipmmu-vmsa: Add an array of slave devices whitelist X-Git-Tag: for-linus-20190104~21^2^2~2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=807596491d33d016e420d217cf1350aef2d2b3f7;p=linux-block.git iommu/ipmmu-vmsa: Add an array of slave devices whitelist To avoid adding copy and pasted strcmp codes in the future, this patch adds an array "rcar_gen3_slave_whitelist" to check whether the device can work with the IPMMU or not. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Geert Uytterhoeven Reviewed-by: Simon Horman Signed-off-by: Joerg Roedel --- diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index 46906a763d69..331e86839a8c 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -770,8 +770,13 @@ static const struct soc_device_attribute soc_rcar_gen3_whitelist[] = { { /* sentinel */ } }; +static const char * const rcar_gen3_slave_whitelist[] = { +}; + static bool ipmmu_slave_whitelist(struct device *dev) { + unsigned int i; + /* * For R-Car Gen3 use a white list to opt-in slave devices. * For Other SoCs, this returns true anyway. @@ -783,7 +788,13 @@ static bool ipmmu_slave_whitelist(struct device *dev) if (!soc_device_match(soc_rcar_gen3_whitelist)) return false; - /* By default, do not allow use of IPMMU */ + /* Check whether this slave device can work with the IPMMU */ + for (i = 0; i < ARRAY_SIZE(rcar_gen3_slave_whitelist); i++) { + if (!strcmp(dev_name(dev), rcar_gen3_slave_whitelist[i])) + return true; + } + + /* Otherwise, do not allow use of IPMMU */ return false; }