mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-01 02:33:57 +00:00
iommu/ipmmu-vmsa: Refactor ipmmu_of_xlate()
Refactor ipmmu_of_xlate() to improve readability/scalability. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Link: https://lore.kernel.org/r/1611838980-4940-2-git-send-email-yoshihiro.shimoda.uh@renesas.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
6ee1d745b7
commit
815cdd8603
@ -734,54 +734,41 @@ static int ipmmu_init_platform_device(struct device *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct soc_device_attribute soc_rcar_gen3[] = {
|
||||
static const struct soc_device_attribute soc_needs_opt_in[] = {
|
||||
{ .family = "R-Car Gen3", },
|
||||
{ .family = "RZ/G2", },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
static const struct soc_device_attribute soc_denylist[] = {
|
||||
{ .soc_id = "r8a774a1", },
|
||||
{ .soc_id = "r8a774b1", },
|
||||
{ .soc_id = "r8a774c0", },
|
||||
{ .soc_id = "r8a774e1", },
|
||||
{ .soc_id = "r8a7795", },
|
||||
{ .soc_id = "r8a77961", },
|
||||
{ .soc_id = "r8a7795", .revision = "ES1.*" },
|
||||
{ .soc_id = "r8a7795", .revision = "ES2.*" },
|
||||
{ .soc_id = "r8a7796", },
|
||||
{ .soc_id = "r8a77965", },
|
||||
{ .soc_id = "r8a77970", },
|
||||
{ .soc_id = "r8a77990", },
|
||||
{ .soc_id = "r8a77995", },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
static const struct soc_device_attribute soc_rcar_gen3_whitelist[] = {
|
||||
{ .soc_id = "r8a774b1", },
|
||||
{ .soc_id = "r8a774c0", },
|
||||
{ .soc_id = "r8a774e1", },
|
||||
{ .soc_id = "r8a7795", .revision = "ES3.*" },
|
||||
{ .soc_id = "r8a77961", },
|
||||
{ .soc_id = "r8a77965", },
|
||||
{ .soc_id = "r8a77990", },
|
||||
{ .soc_id = "r8a77995", },
|
||||
{ /* sentinel */ }
|
||||
static const char * const devices_allowlist[] = {
|
||||
};
|
||||
|
||||
static const char * const rcar_gen3_slave_whitelist[] = {
|
||||
};
|
||||
|
||||
static bool ipmmu_slave_whitelist(struct device *dev)
|
||||
static bool ipmmu_device_is_allowed(struct device *dev)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* For R-Car Gen3 use a white list to opt-in slave devices.
|
||||
* R-Car Gen3 and RZ/G2 use the allow list to opt-in devices.
|
||||
* For Other SoCs, this returns true anyway.
|
||||
*/
|
||||
if (!soc_device_match(soc_rcar_gen3))
|
||||
if (!soc_device_match(soc_needs_opt_in))
|
||||
return true;
|
||||
|
||||
/* Check whether this R-Car Gen3 can use the IPMMU correctly or not */
|
||||
if (!soc_device_match(soc_rcar_gen3_whitelist))
|
||||
/* Check whether this SoC can use the IPMMU correctly or not */
|
||||
if (soc_device_match(soc_denylist))
|
||||
return false;
|
||||
|
||||
/* 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]))
|
||||
/* Check whether this device can work with the IPMMU */
|
||||
for (i = 0; i < ARRAY_SIZE(devices_allowlist); i++) {
|
||||
if (!strcmp(dev_name(dev), devices_allowlist[i]))
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -792,7 +779,7 @@ static bool ipmmu_slave_whitelist(struct device *dev)
|
||||
static int ipmmu_of_xlate(struct device *dev,
|
||||
struct of_phandle_args *spec)
|
||||
{
|
||||
if (!ipmmu_slave_whitelist(dev))
|
||||
if (!ipmmu_device_is_allowed(dev))
|
||||
return -ENODEV;
|
||||
|
||||
iommu_fwspec_add_ids(dev, spec->args, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user