Skip to content

Commit 815cdd8

Browse files
shimodayjoergroedel
authored andcommitted
iommu/ipmmu-vmsa: Refactor ipmmu_of_xlate()
Refactor ipmmu_of_xlate() to improve readability/scalability. Signed-off-by: Yoshihiro Shimoda <[email protected]> Link: https://lore.kernel.org/r/1611838980-4940-2-git-send-email-yoshihiro.shimoda.uh@renesas.com Signed-off-by: Joerg Roedel <[email protected]>
1 parent 6ee1d74 commit 815cdd8

File tree

1 file changed

+18
-31
lines changed

1 file changed

+18
-31
lines changed

drivers/iommu/ipmmu-vmsa.c

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -734,54 +734,41 @@ static int ipmmu_init_platform_device(struct device *dev,
734734
return 0;
735735
}
736736

737-
static const struct soc_device_attribute soc_rcar_gen3[] = {
738-
{ .soc_id = "r8a774a1", },
739-
{ .soc_id = "r8a774b1", },
740-
{ .soc_id = "r8a774c0", },
741-
{ .soc_id = "r8a774e1", },
742-
{ .soc_id = "r8a7795", },
743-
{ .soc_id = "r8a77961", },
744-
{ .soc_id = "r8a7796", },
745-
{ .soc_id = "r8a77965", },
746-
{ .soc_id = "r8a77970", },
747-
{ .soc_id = "r8a77990", },
748-
{ .soc_id = "r8a77995", },
737+
static const struct soc_device_attribute soc_needs_opt_in[] = {
738+
{ .family = "R-Car Gen3", },
739+
{ .family = "RZ/G2", },
749740
{ /* sentinel */ }
750741
};
751742

752-
static const struct soc_device_attribute soc_rcar_gen3_whitelist[] = {
753-
{ .soc_id = "r8a774b1", },
754-
{ .soc_id = "r8a774c0", },
755-
{ .soc_id = "r8a774e1", },
756-
{ .soc_id = "r8a7795", .revision = "ES3.*" },
757-
{ .soc_id = "r8a77961", },
758-
{ .soc_id = "r8a77965", },
759-
{ .soc_id = "r8a77990", },
760-
{ .soc_id = "r8a77995", },
743+
static const struct soc_device_attribute soc_denylist[] = {
744+
{ .soc_id = "r8a774a1", },
745+
{ .soc_id = "r8a7795", .revision = "ES1.*" },
746+
{ .soc_id = "r8a7795", .revision = "ES2.*" },
747+
{ .soc_id = "r8a7796", },
761748
{ /* sentinel */ }
762749
};
763750

764-
static const char * const rcar_gen3_slave_whitelist[] = {
751+
static const char * const devices_allowlist[] = {
765752
};
766753

767-
static bool ipmmu_slave_whitelist(struct device *dev)
754+
static bool ipmmu_device_is_allowed(struct device *dev)
768755
{
769756
unsigned int i;
770757

771758
/*
772-
* For R-Car Gen3 use a white list to opt-in slave devices.
759+
* R-Car Gen3 and RZ/G2 use the allow list to opt-in devices.
773760
* For Other SoCs, this returns true anyway.
774761
*/
775-
if (!soc_device_match(soc_rcar_gen3))
762+
if (!soc_device_match(soc_needs_opt_in))
776763
return true;
777764

778-
/* Check whether this R-Car Gen3 can use the IPMMU correctly or not */
779-
if (!soc_device_match(soc_rcar_gen3_whitelist))
765+
/* Check whether this SoC can use the IPMMU correctly or not */
766+
if (soc_device_match(soc_denylist))
780767
return false;
781768

782-
/* Check whether this slave device can work with the IPMMU */
783-
for (i = 0; i < ARRAY_SIZE(rcar_gen3_slave_whitelist); i++) {
784-
if (!strcmp(dev_name(dev), rcar_gen3_slave_whitelist[i]))
769+
/* Check whether this device can work with the IPMMU */
770+
for (i = 0; i < ARRAY_SIZE(devices_allowlist); i++) {
771+
if (!strcmp(dev_name(dev), devices_allowlist[i]))
785772
return true;
786773
}
787774

@@ -792,7 +779,7 @@ static bool ipmmu_slave_whitelist(struct device *dev)
792779
static int ipmmu_of_xlate(struct device *dev,
793780
struct of_phandle_args *spec)
794781
{
795-
if (!ipmmu_slave_whitelist(dev))
782+
if (!ipmmu_device_is_allowed(dev))
796783
return -ENODEV;
797784

798785
iommu_fwspec_add_ids(dev, spec->args, 1);

0 commit comments

Comments
 (0)