Re: [PATCH] soc: imx: check ls1021a
From: Arnd Bergmann <arnd@arndb.de>
Date: 2020-07-20 12:35:44
On Mon, Jul 20, 2020 at 11:01 AM Peng Fan [off-list ref] wrote:
quoted
Subject: Re: [PATCH] soc: imx: check ls1021a On Mon, Jul 20, 2020 at 8:30 AM Peng Fan [off-list ref] wrote:quoted
quoted
Subject: Re: [PATCH] soc: imx: check ls1021a
quoted hunk ↗ jump to hunk
quoted
If you cannot do that here (e.g. because you need the soc_device to be present very early), then you have to manually check for some DT node and property to determine whether you run on an i.MX machine and do the silent 'return 0' if not. This is roughly what you did when you checked for one specific non-i.MX machine, but since you cannot provide an exhaustive list of all non-i.MX machines (a denylist) you have to provide some for of allowlist.Is the following diff ok for you? Actually all i.MX SoCs will set __mxc_cpu_type. If it is not a valid one, just return.diff --git a/drivers/soc/imx/soc-imx.c b/drivers/soc/imx/soc-imx.c index 01bfea1cb64a..e55225a85592 100644 --- a/drivers/soc/imx/soc-imx.c +++ b/drivers/soc/imx/soc-imx.c@@ -33,9 +33,6 @@ static int __init imx_soc_device_init(void) u32 val; int ret; - if (of_machine_is_compatible("fsl,ls1021a")) - return 0; - soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); if (!soc_dev_attr) return -ENOMEM;
This means the driver still has to allocate and then free the structure, as well as lookup some DT properties.
quoted hunk ↗ jump to hunk
@@ -131,6 +128,8 @@ static int __init imx_soc_device_init(void) break; default: soc_id = "Unknown"; + ret = 0; + goto free_soc; } soc_dev_attr->soc_id = soc_id;
I took a closer look at where this information comes from. As the
__mxc_cpu_type variable seems to just be initialized to zero until
set explicitly, I guess the easiest way would be to change the
of_machine_is_compatible() check to 'if (!__mxc_cpu_type)'.
Arnd
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel