[PATCH] soc: imx: check ls1021a

Arnd Bergmann arnd at arndb.de
Mon Jul 20 08:33:34 EDT 2020


On Mon, Jul 20, 2020 at 11:01 AM Peng Fan <peng.fan at nxp.com> wrote:
> > Subject: Re: [PATCH] soc: imx: check ls1021a
> > On Mon, Jul 20, 2020 at 8:30 AM Peng Fan <peng.fan at nxp.com> wrote:
> > > > Subject: Re: [PATCH] soc: imx: check ls1021a

> > 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.

> @@ -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



More information about the linux-arm-kernel mailing list